LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Empty serial port buffer?

Is it possible to empty the buffer of the serial input port without reading from it?
0 Kudos
Message 1 of 5
(4,386 Views)
Yes it is. If you are using VISA (and you should, its better) you can use the "VISA empty buffer" VI under the "advanced" palette in the VISA commands.

If not using VISA, simply get the number of bytes at the port, read them and discard the contents.

Shane

PS my version is in german, and I forget what the exact names of the VIs are in english.... My translations may not coincide with those of NI.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 2 of 5
(4,386 Views)
hi

use VISA FLUSH I/O BUFFER

regards
wha
Message 3 of 5
(4,386 Views)
izze wrote in news:5065000000080000002B8B0000-
1042324653000@exchange.ni.com:

> Is it possible to empty the buffer of the serial input port without
> reading from it?

You have several options.

Old standard serial VI's
----------------------
Use "Bytes at Serial Port" to get number of byte present and wire it to
"Serial Port Read" and don't use the data from the VI.

VISA flush buffer
----------------------
The function "VISA Flush I/O Buffer".
This did not work for me, it took to long time.

VISA eqvivalent of number of bytes at serial port.
----------------------
There is a VISA property to read number of bytes on the receive buffer of
the serial port. Use this to get number of bytes and wire this number to
the VISAread function.
The pro
blem is that this only works for serial port.

Use VISA read
-------------
-1- Get VISA timeout value (VISA property node)
-2- Set VISA timout to 0 (VISA property node)
-3- make a while loop with
VISA read function with e.g 1000 bytes to read.
End the while loop when number of bytes read is 0
-4- Set VISA timeout back to the value set in step 1

--
Rolf
Message 4 of 5
(4,386 Views)
Excellent!
I have the same experience with the VISA flush buffer.
Will try the Use VISA read option.
Thanks
0 Kudos
Message 5 of 5
(4,386 Views)