i have seen a few examples but i havn't found my answer yet.
i am trying to send a string of hex bytes out a serial port the format
being A123D4FF
my problem is that i don't understand how to send A1h out the port and
not 'A' '1"
can someone point me in the right direction or show me a vi that does
something similar??
|
|
0
|
|
|
|
Reply
|
x9561 (148650)
|
7/31/2003 8:39:50 PM |
|
The string that you give to VISA can be viewed as an array of U8 data
(there is a handy conversion vi that goes back and forth).
However if you have a string of ASCII that you want to transmit as
hex, then you need to convert the string from ASCII to "raw data" and
then send that out. I recently had to do this for a serial number vi
that I wrote which took a serial number from the user as ASCII then
write it to a EEPROM as hex.
I did this by first breaking the ASCII string into chunks of two
characters each (so 'A12BC3' would be broken into chunks of 'A1',
'2B', and 'C3') then converting each chunk into a number via a scan
from string vi. The output gets placed into a new array which, in
your case, would then be written out of the serial port.
There may be a better way, but this worked quite well and was fast to
write.
Hope this helps!
|
|
0
|
|
|
|
Reply
|
x9561 (148650)
|
7/31/2003 9:07:44 PM
|
|
Right-click on the string constant and select Hex display...now write
in A123D4FF...wire that to the serial write and you are now sending
the correct binary string, not the readable version of it.
If you build the strings dynamically from e.g. numbers all you need to
do is to type cast them to a string. If e.g. you have a U32 value of
45 type casting it to a string will give you a binary string...if you
look at it in hex display it will look like this:
0000 002D
The type cast can be found on the advanced -> data manipulation
palette. On the string-> string conversion palette you can also find a
function to convert an array of bytes to a string so if you already
have the data as an array of byte values just use that to get the
string to send.
|
|
0
|
|
|
|
Reply
|
x9561 (148650)
|
8/1/2003 11:20:20 AM
|
|
Turn the Hex display on by right click your string control then select
Hex display. You can type in hex value directly.
Hope this help
|
|
0
|
|
|
|
Reply
|
homing.pang (5)
|
8/1/2003 4:28:33 PM
|
|