Writing a Hex string to a file

Writing a Hex string to a file

Post by BigBod » Fri, 24 Mar 2006 02:40:12


I am reading a hex value from the serial port, and I want to write this value to a file.  When I try to write the value now, I get the following:
 
?0XSR?
 
But it should be:
 
8330 0D58 5352 D801 0000 1029 2822 1106 EC00 7F08 0400 5C00 0000 0000 0000 0000 0000 0000 0000 0D0A
 
 
I have tried the various converters in LabView, but have had no success.
 
Any help would be appreciated.
 
 
 

Writing a Hex string to a file

Post by Darre » Fri, 24 Mar 2006 03:10:10

Hello,It seems that what you want are the ASCII characters that *represent* the hex characters in your string.?There may be an easier way to do this, but the first way I thought of is shown below:<img src=" http://www.yqcomputer.com/ "> See if this helps.?I have also saved the VI in LabVIEW 7.1 format and attached it below.Good luck,-DMessage Edited by Darren on 03-22-200611:53 AM


Convert_String_to_ASCII_Hex.jpg:
http://www.yqcomputer.com/


Convert_String_to_ASCII_Hex.vi:
http://www.yqcomputer.com/

 
 
 

Writing a Hex string to a file

Post by altenbac » Fri, 24 Mar 2006 04:10:09

Well, it really depends how you want to look at it. ;)
 
You could just write the raw hex string to a file, then look at the file in a hex editor. :o
 
It seems you want ASCII formatted text showing each double octet with 4 digits (0...F), followed by a space. If your string always contains an even number of digits, you could just cast it as U16. This would simplify the code a bit. See attached modification of Darren's example (LabVIEW 7.1).


Convert_String_to_ASCII_HexMOD.vi:
http://www.yqcomputer.com/


HEXtoASCII.png:
http://www.yqcomputer.com/