LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array to word

Solved!
Go to solution

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

0 Kudos
Message 1 of 6
(3,357 Views)
Solution
Accepted by topic author q-bertsuit

Something like this?

 

U8 to U16.PNG

Message 2 of 6
(3,345 Views)

You can/have to use following two major functions;

1. Reshape array (Array Palette)

2. ByteArray to String

 

Regards,

Yogesh Redemptor

Regards,
Yogesh Redemptor
0 Kudos
Message 3 of 6
(3,344 Views)

Brilliant! Works like a charm!

 

Thanks!

0 Kudos
Message 4 of 6
(3,333 Views)

Here's what I would do.

 

 

Message 5 of 6
(3,321 Views)

@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.)

Message 6 of 6
(3,315 Views)