LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can detect the serial port is active

I made a program. It can read datas via serial port. But the datas wont came all the time, so the other part of the program not need to run. I want to put before the "reading serial port" a detection about the serial port is get a data. So the reading is wont start before datas are not coming. Can anybody help me how can i solve this problem?
0 Kudos
Message 1 of 9
(3,340 Views)
Hi Zoyo, if you use the VISA- VIs, the functionyou need is "VISA Bytes at serial port". It shows, how many Bytes are available in the input buffer. You can find it here:



greets, Dave

Message Edited by daveTW on 11-22-2006 02:01 PM

Greets, Dave
0 Kudos
Message 2 of 9
(3,328 Views)
You can also use events along with the bytes at port so you don't have to poll the bytes at port so often.  see the attached image
 
 
-James
 
 

Message Edited by James R on 11-22-2006 09:06 AM

- James

Using LV 2012 on Windows 7 64 bit
0 Kudos
Message 3 of 9
(3,317 Views)
What function is that coming after the cluster in the Rx Data Loop?
0 Kudos
Message 4 of 9
(3,294 Views)
This example uses queues to store the data until it is processed in the parallel loop.  the function after the cluster is enqueue element found in programming>synchronization>queue operations
 
-James
- James

Using LV 2012 on Windows 7 64 bit
0 Kudos
Message 5 of 9
(3,286 Views)
Thx for all. I try to do it now.
0 Kudos
Message 6 of 9
(3,267 Views)
James:
Can U attach the vi file about serial_interrupt ?
0 Kudos
Message 7 of 9
(3,242 Views)
daveTM: So it's mean if the VISA Bytes at serial port value is 0, than the datas are not coming? Because if it's true I can put my whole program int Case Structure and i can say if the value is 0 do not doing anything, and if the value is bigger than 0, than wich program must to work.
0 Kudos
Message 8 of 9
(3,234 Views)
Sorry for the late answer.
Yes, you're right, if this function gives a value back greater than zero, there was something received by your serial port. The NI- serial driver handles the serial protocol for you automatically and stores the received bytes in a buffer. When you use "VISA Read" this function only gives back the data of this buffer. So you don't have to read every single byte by byte but can wait until a certain amount of bytes are received and read them in one.
Greets, Dave
Greets, Dave
0 Kudos
Message 9 of 9
(3,198 Views)