03-20-2012 06:42 AM
Hi,
I have an array of 28 U8's in decimal form that contain data collected trough a serial port. The data is really words, where byte 1 is more significant than byte 0.
My question is, is there an elgant way of combining these pairs of bytes into words? So, 14 words, should be arranged like so: byte1byte0 byte3byte2 byte5byte4 and so on.
Thanks for your time
Solved! Go to Solution.
03-20-2012 06:59 AM
Something like this?
03-20-2012 07:00 AM
You can/have to use following two major functions;
1. Reshape array (Array Palette)
2. ByteArray to String
Regards,
Yogesh Redemptor
03-20-2012 07:45 AM
Brilliant! Works like a charm!
Thanks!
03-20-2012 10:05 AM - edited 03-20-2012 10:05 AM
03-20-2012 10:24 AM - edited 03-20-2012 02:09 PM
@q-bertsuit wrote:
I have an array of 28 U8's in decimal form that contain data collected trough a serial port. The data is really words, where byte 1 is more significant than byte 0.
If the data comes in via serial port, it is probably originally a raw string. All you need is "unflatten from string" with option "little endian" to convert it to the desired U16 array. You don't really need the detour over U8.
(Also note that U8 are not decimal, hex, or anything else. That is just a display format for human consumption. The underlying data is the same.)