10-23-2018 01:19 PM
Hi there
I have a strong from TCP port being read, which I'm converting to a byte array. Now this byte array has various types of data in it. I need to convert specific bytes to different data types. For eg.
4 bytes to unsigned INT
8 bytes to float
8 bytes to unsigned long long etc.
Can someone please help me with the unpacking of the bytes.
Shall be highly grateful
Thanks
10-23-2018 01:32 PM
This message is a year and a half old. You probably should have started a new thread.
What is "a strong"? Maybe you meant "string"?
Did you try following the advice of earlier messages in this thread to use the Typecast function?
If you need more specific help, then you should attach a VI with the string saved as a constant, and the list of data types you need.
10-23-2018 01:47 PM
We would also need to know the specific format/protocol for the data your are receiving. It is defined somewhere. Without that are advice would be very general.
10-23-2018 02:16 PM
I recommend using Unflatten From String to decode your data.
10-23-2018 07:33 PM
Hi Mark
Thank you for your revert. It's a huge data packet wherein the data type varies depending on the packet type and hence needs to be unpacked accordingly. For now I just need to know if I have a 8 bytes of UINT (an array) , how do I convert that to a double value?
10-23-2018 07:37 PM
Hi
Thank you so much for your revert. Yes that's a typo. I meant "string". My bad.
I'm aware of the type cast function, just that not too sure of how to use in this case. Could you please help me with an example?
I have 8 bytes of UINT byte array which I need to convert into a double float.
10-23-2018 07:40 PM
Hi crossrulz
Thank you for your revert. Since it's a large chunk of data, I'm not too sure how would un flatten from string be helpful. I converted the string to an UINT byte array so that I can parse the bytes (different types and lengths of packets) and unpack them accordingly. Could you please help me out with this?
Thanks a ton!
10-24-2018 01:10 AM
10-24-2018 07:10 AM
What the heck is a "revert"?
10-25-2018 06:46 AM - edited 10-25-2018 06:47 AM
@sakshi14 wrote: Since it's a large chunk of data, I'm not too sure how would un flatten from string be helpful.
You can do all of the conversion with just one call by unflattening a cluster. I also prefer to use the Unflatten From String since it has an option for Endianness (how the bytes are arranged in a multi-byte data type).
