LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Port read questions

I am new in Labview 7, and I use it for serial port communication.
I use LF as termination char in RS232 write, but
I need to turn off termination char in RS232 Read since
the read buffer has several lines of Ascii text which
include LF char.
My first question is how to turn termination char off
in ReadMode?
My second question is that I need to read all text in
readbuffer but I did not know how many bytes they are,
How can I set the readbuffer count?
0 Kudos
Message 1 of 4
(2,931 Views)
There is a LV API for checking serial count.

rjmiller
0 Kudos
Message 2 of 4
(2,931 Views)
The example found at the link below shows how to transfer binary data. One of the cases is suitable for serial instruments and shows how to turn off termination characters before the binary data transfer.
The example assumes a specific format where the byte count is known. In your case you would use the VISA property note "Number of Bytes at Serial Port" to determine the byte count for the read. You can find this property in the following palette hierarchy: Instrument I/O>>VISA>>VISA Advanced>>Interface Specific>>Serial.

Example for binary instrument transfers:
Waveform Encoding and Scaling
for Instrument Control Applications

0 Kudos
Message 3 of 4
(2,931 Views)
Hello,

You can enable or disable termination characters by using the Config Serial Port VI in your flow of programming. See the LabVIEW <-> Serial.vi example that ships with LabVIEW (go Help -> Find Examples...)for proper use of this VI.

Note that the termination character specified in the config serial port VI applies only to reads and not to writes. This stems from the fact that this Vi sets the "VI_ATTR_ASRL_END_IN" attribute only. Thus, it will not be appended to a write buffer.

In your application, it seems that you should disable the termination character on this VI (or at least change it to something besides LF). You can do a "get bytes at port" as others have mentioned to find out how many bytes to read in, and then read exactly this
many bytes from the port. As long as your device sends all its data before you do this read, you will not lose any data with this method. On the other hand, if you device sends, say 10 out of the total 25 bytes, then your Get Bytes at Port will only return 10 and you will only read 10 bytes; you will need to be careful with this "no termination character" approach.

If any of this is unclear, please respond by posting here.

Scott B.
Applications Engineer
National Instruments
Message 4 of 4
(2,931 Views)