String ASCII move as HEX to string table

Hi all,

I am working on converting my string table values into hex format and then pushing them back into a string table for further data conversion. Here is the raw string received from a wireless sensor via serial communication:

, Once I click the format from ascii to hex, I am able to see the correct data needed for parsing:

Does anyone know how to convert a string table into a hex table or a string hex table? I’ve looked through the available commands but couldn’t find anything that works for this purpose. Any suggestions or guidance would be greatly appreciated!

Searching the forums for ‘hex’ gives some good results you might find helpful.

But in short, I would have a loop that simply spins through your table using the unpack command.

1 Like

How did you get the data in the table that way? It will be easier to work with (and to use the Unpack command) if it was in a single string variable.

Are you sure you need to convert it to ASCII Hex prior to your end result? If you can share a bit more on what you need extracted, I/we can then give more specific advice.

2 Likes

The string table width is set to 1. This allowed me to arrange the data in the desired order. I can receive the data as a string, but converting it from the table seems much easier than parsing it from a single continuous string.

For example, here’s how the data would be parsed:

Raw Data:
7E 00 19 90 00 13 A2 00 41 A2 70 EA FF FE C2 7F 00 05 03 FF 01 00 01 00 0D 7A 0A 56 4F

Payload:
7F 00 05 03 FF 01 00 01 00 0D 7A 0A 56

Field Breakdown:

  • 7F – Header
  • 00 – Node ID
  • 05 – Firmware Version
  • 03, FF – Battery Voltage
  • 01 – Transmission Counter
  • 00, 01 – Sensor Type
  • 00 – Reserved
  • 0D, 7A – Humidity = (0D * 256) + 7A = 3450 (DEC) / 100 = 34.50%
  • 0A, 56 – Temperature = (0A * 256) + 56 = 2646 (DEC) / 100 = 26.46°C
1 Like

Keep the payload binary, don’t convert to a hex string.

Using a single string will be easier - treat it as an array of bytes:

Here is the difference:

//As a string
fHumidity = (sPayload[24] * 256 + sPayload[25]) / 100.0;

//As a string table
fHumidity = (GetNthCharacter(stPayload[24], 0) * 256 + GetNthCharacter(stPayload[25], 0)) / 100.0;
2 Likes