LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

normal string convert to hex string

I have to convert a normal display mode string to hex display mode string, but the value need to be the same. For example:

string one (in normal display) show "20"

after convertion to string two (which is in hex display mode) still show "20"


the whole effort is to duplicate a program called "windows serial downloader" come with analog device. the program has labview style user interface, but has a whole lot of problems when I tried to run on our pc. It basically read a hex file, format based on its protocol, and send to microprocessor through serial port. If anyone has done similar program, and can share with me, I would really appreciated!
0 Kudos
Message 1 of 6
(5,483 Views)


DGU wrote:

string one (in normal display) show "20"

after convertion to string two (which is in hex display mode) still show "20"


A normal string display shows a string as normal characters.  Hex display shows the ASCII code of the characters.  They are not and never will be showing the same thing.  What you are asking does not make sense.  The ASCII code for 2 in hex is 32, for 0 it is 30.  So your hex display will show 3230.  A hex display of 20 is the space character.  Maybe you could explain your problem a little better, or post your code.


- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 6
(5,480 Views)
ok, I have a hex file on my PC. when I write these hex code using visa write, the string should be hex mode. for example, hex "10" as one byte, the visa write will write one byte "10"
however, when I read the file using "read text file", pc automatically use dec mode. for example, my hex file contain "10", but when pc read, it will read "1" as one char, and "0" as another char, so in hex mode, it become "31" "30"

so all i need is to convert back to hex "10", so I can use visa write directly. Hope I explain it better this time.
thanks,
0 Kudos
Message 3 of 6
(5,474 Views)
I hope this is what you want:  Convert the hex string into a number, then convert the number into an ASCII character as follows:
 

Message Edited by tbob on 03-31-200601:50 PM

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 6
(5,462 Views)

Sorry, should have converted numeric to U8 (byte).  Look at picture below.  I converted the last string to a byte array to insure that the value is hex 10 (dec 16).

Message Edited by tbob on 03-31-200602:00 PM

- tbob

Inventor of the WORM Global
Message 5 of 6
(5,454 Views)
It works! Thank you very much!!
0 Kudos
Message 6 of 6
(5,443 Views)