LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Special ASCII characters to equivalent Hex code

Solved!
Go to solution

Hello,

I am trying to convert special ascii characters that are being read from a serial port, to a data type that I can manipulate. To create this scenario, create a empty string constant, then right click on it and change type to "Hex". Now enter a value in it, say 287F. If you right click again and change the display to "Normal", you should see this value "(", which are special ascii characters.

What I am trying to do is to convert this incoming data into a format where I can manipulate the data to read the binary equivalent of this data. For example, for the incoming data of "287F", I want to be able to convert it to "0010 1000 0111 1111"

I have not been able to find any function that would convert this type of data. Am I overlooking something that is very obvious?? Or is this not possible to do it in Labview. Please advise.

Thanks in advance.

Shoab

0 Kudos
Message 1 of 5
(5,616 Views)

Use String to Byte Array from the String->Conversion Palette.

Then change the radix on the byte array indicator to show binary.

0 Kudos
Message 2 of 5
(5,600 Views)

ASCII is only defined for the first byte (0-127), your code is not ASCII, it's Unicode.

The following code should do the trick.

22729i094A68CDF9589BC1

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 5
(5,579 Views)
Solution
Accepted by topic author Shoab

If it is always exactly 2 Bytes, typecast to U16 and either format to string as binary or set the display format of the U16 to binary.

 

Message 4 of 5
(5,567 Views)
0 Kudos
Message 5 of 5
(5,542 Views)