08-30-2010 02:10 PM
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
Solved! Go to Solution.
08-30-2010 02:27 PM
Use String to Byte Array from the String->Conversion Palette.
Then change the radix on the byte array indicator to show binary.
08-30-2010 02:48 PM
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.
Ton
08-30-2010 03:03 PM - edited 08-30-2010 03:04 PM
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.
08-30-2010 04:22 PM - edited 08-30-2010 04:23 PM