02-15-2010 02:00 PM - edited 02-15-2010 02:07 PM
Hello, I have a device which I am trying to communicate with using UDP. The device returns the data in Hex strings but I don't have very good documentation on the format of these strings. Here is what I do have:
00 - Command type / BYTE
01 - Response Code / BYTE
02 - Task ID / BYTE
03 - Channel / BYTE
04-07 - PS Current / Float
08-11 - PS Current Aux / Float
12-15 - DAC Voltage / Float
16-19 - PS Current ripple / Float
20-23 - PS Ground Current / Float
24-27 - Temperature / Float
28-31 - PS Volts / Float
32-35 - Spare channel volts / Float
A sample data return might look like this:
c8:00:10:00:7f:8d:f1:ba:ff:ed:22:39:f8:ff:1f:41:4c:41:52:39:ff:57:63:38:3d:f1:a7:42:ff:35:be:39:7f:49:a7:3a
The value I really care about right now is the PS current in Byte 04 - 07. So I did an offset of 4 and a lenght of 4 on string subset which would return something like 7f8d f1ba. But I have not had success turning this in to an actual number using the Hexadecimal to number VI trying every possible representation.
Does anyone have any idea how I can convert this? I added a screenshot of what I have now. Thank you in advance for any help.
On edit, in case this is helpful a current of 1.00005 would return 96:01:80:3f or the full response incase I have the offsets wrong:
c8:00:1f:00:96:01:80:3f:ff:57:63:38:c2:00:80:3f:ef:8c:ed:3a:ff:57:02:38:0a:25:c8:42:34:e3:7f:3e:bf:4f:88:ba
Solved! Go to Solution.
02-15-2010 02:27 PM - edited 02-15-2010 02:28 PM
Note: I am assuming you put in the colons for readability, and that you are not actually getting that from the UDP.
What you are actually getting is a string of bytes, not a string of characters representing hex values. In other words, you are not getting the character 'F' to indicate a hex value of F. You are getting a byte of value decimal 15. Additionally, the characters are in reverse order. To convert it you have to chop off the section you want, reverse the string, and then use the Type Cast function:
02-15-2010 02:36 PM
02-15-2010 02:46 PM - edited 02-15-2010 02:47 PM
The Unflatten From String will also work.
06-06-2016 02:16 AM
Hi all.
I did the first example but I received another answer.
Where is error ?
Best regards
Iskander
06-06-2016 06:44 AM
What is the reprsentation for the constant wired into the typecast?
If you look at S-Mercurio's solution, you can see it is a Single Precision Float.
I bet you wired in a double precision constant.
06-06-2016 06:57 AM
Thanks
Yes, I use S-Mercurio's solution.
I wired a double precision constant.
I didn't receive correct answer " 1,00005"
Regards
06-06-2016 07:58 AM
Most likely the problem is the representation on the string, not on the numeric - in the original example, the display style is almost definitely in hex. In the new one, it's not. Iskander, make the display style on the string visible, change it to hex and then type in the text again and it should probably work.
06-06-2016 08:20 AM
@Iskander wrote:Thanks
Yes, I use S-Mercurio's solution.
I wired a double precision constant.
I didn't receive correct answer " 1,00005"
Regards
I'm confused by your message.
So if you did wire a double precision constant, and did not get the correct answer of 1.00005,
then I can only assume you went back and fixed it with the single precision constant? And did you get the correct answer then?
06-08-2016 01:29 AM
Thanks all for the attention and help
I changed "const" to control and do "Hex".
All work.
Best regards.