LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I write this string to a file as the ASCII representation in Hex format?

I need to convert a number ( say 16000 ) to Hex string ( say 803E = 16,000) and send it using Visa Serial with the string control in Hex Mode. I have no problem with the conversion (see attached). My full command in the hex display must read AA00 2380 3E...
 
I can easily get the string together when in Normal mode to read AA0023803E... but how can I get this to hex mode without converting? (i.e. 4141 3030 3233 3830 3345 3030 3030 3031 )
0 Kudos
Message 1 of 6
(4,873 Views)

If your number is 2 bytes (803E) you should not start out with a DBL, but with a U16. Now just flatten it to a string in little endian format as follows:



Message Edited by altenbach on 11-16-2007 09:39 AM
0 Kudos
Message 2 of 6
(4,870 Views)
Of course you need to concatenate your other strings at the end. Easiest would be to use string diagram constants set to hex display (right-click...hex display"), then enter the desired text.
0 Kudos
Message 3 of 6
(4,858 Views)
Is that instruction available in 7.1? The only one I can find is Variant to flattened string whcih doesn't allow me to select Little Endian. I get Hex = 3E80 instead of 803E. FYI - I'm not very smart.
0 Kudos
Message 4 of 6
(4,845 Views)
Sorry, The little endian option was probably introduced in 8.0 (?).
 
In this special case it's simple, just reverse the string before concatenating with the rest.
 
It should be in the string palette, probably under "additional string functions".
 
 
(note that this only works in this special case flattening a single number as we do here. If the stat structure is more complex (array, cluster, etc.) you would need to do a bit more work. 😉
 
Actually, you might just use typecast as follows. Same difference.


I only used the flatten operation because of the little endian option in my version.



Message Edited by altenbach on 11-16-2007 11:53 AM
Download All
0 Kudos
Message 5 of 6
(4,827 Views)
Perfect. Thank you.
0 Kudos
Message 6 of 6
(4,813 Views)