LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert a normal display string to a hex display string

Hi everyboby,

 

I am a new LabViewer, now I am doing a project about serial communication. And I need to transmit hex command from the computer to the component and vice versa. However, I got some troubles with converting a hex string in normal display into a hex string with hex display. For example, my 10 bytes string now is "0A 00 00 A0 00 00 00 00 FF FF" in normal display, and I want to convert into hex display with the format: " 0A00 00A0 0000 0000 FFFF".

 

I very appreciate for anyone can help me solve this problem.

:))

0 Kudos
Message 1 of 3
(4,326 Views)

Typing a hex string in normal display and then selecting hex display is not the correct way to enter hex data. What will happen is that each of those characters will be changed to it's hex value (i.e. 'A' = 0x41).  Simply clear the control and enter your data as hex.

0 Kudos
Message 2 of 3
(4,322 Views)

Right click on the control or constant and select "Hex Display" and reenter your data.  That would be the easiest way to handle it.  Otherwise, you would need to take 2 characters at a time (use a for loop), use the Hex String to Number with a U8 data type (autoindex out the numbers), then use the Byte Array to String.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 3
(4,320 Views)