LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Does Serial Write split a string into individual bytes

For one-way rs232 transmission, will Serial Write take a string of arbitrary length and split it into individual bytes for transmission?  For instance, if I want to send "1023" at 8n1, when converted into binary it would be over 8 bits, so i would have to split this into two bytes for transmission.  How would I best do this?

 

I have experience with the basic serial read write example vi's, but I am not sure exactly how strings are handled by Serial Write...   I am not sure if I need to manually take my string, convert it to hex or binary, pad the left w/ zeros to equal 16 bits, and then split this into two strings to send sequentially through serial write  OR maybe serial write will do this for me automatically....?

 

I have posted a similar question in NI hardware (GRIB) thread but I have attemted to clarify my question and have reposted here. 

 

Thank you very much,

 

Jeff

0 Kudos
Message 1 of 5
(3,358 Views)
If you send ASCII '1023', that is four bytes and all you have to do is wire it the the VISA Write. If you want to send hex 1023 (2 bytes) right click on your string control/constant and select 'Hex display'. Wire that to the VISA Write. There are other methods to send hex such as Type Cast, Byte Array to String, Flatten to String, etc. Talked about and documented many times in many, many other threads.
0 Kudos
Message 2 of 5
(3,355 Views)

thank you dennis, yes i know that this is a simple concept, thank you for emphasizing that.

 

 

I will be transmitting ASCII 1023 or hex 3FF, either way since the hardware that is recieving this transmission will be looking for 8n1 and will be converting back to hex, I will probably need to use byte array to string to manipulate the data.  I am under the impression that if I give VISA write a 2 byte string, it will only send the first byte, and ignore the rest.  So i think that I will need to use byte array to string and send it one byte at a time.   I am not sure if you have clarified that point or not, either way I will experiment w/ this and hopefully clarify this for myself.

 

 

thank you.

 

 

0 Kudos
Message 3 of 5
(3,346 Views)

If you give VISA Write a 2 byte string, it will send 2 bytes.

 

p.s. ASCII 1023 is not the same thing as hex3FF. ASCII means sending the characters '1', '0', '2', and '3'. Each of those is a byte.

Message Edited by Dennis Knutson on 03-11-2010 10:31 AM
0 Kudos
Message 4 of 5
(3,342 Views)

okay thank you for clarifying! 

0 Kudos
Message 5 of 5
(3,336 Views)