LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read everything on serial port

I utilize the following steps to read data from a sensor:
1) Write the acquisition command to the serial port
2) Wait 100 ms
3) Read the first line which gives me the command
4) Read the second line which gives me the status of the sensor
5)
If status indicates that the data is valid, read everything on the serial port
Else, do not read the serial port. Clear the receive buffer and restart from step 1

In order to read everything on the serial port, I use a while loop and continously read everything on the serial port until there are no bytes left (see attached image). The sensor will not give me anymore data until I send the next command.

While everything works nicely, I would like to lower the time that it takes to read everything on the serial port (~75 ms). I noticed that it took 22 iterations until it finished. Is there a more efficient way to read everything on the serial port (ie so that I can read the serial port once)?

Message Edited by elliot.ee on 06-06-2007 12:59 PM

0 Kudos
Message 1 of 2
(2,294 Views)

Hi Elliot,

I would suggest that you put a wait in your while-loop. You should always do that if your loops time can be very short.

Did you calculate how much time it actually takes to transmit the data ? You can't get it any faster then that  Smiley Wink

Message Edited by K C on 06-06-2007 09:57 PM

0 Kudos
Message 2 of 2
(2,261 Views)