LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bluetooth: how to keep listen without timeout if there are incoming data

I have to use bluetooth module in Labview (not VISA with the virtual COM) and check continuously if there are incoming data. With the VISA module I have the "Byte at Port" property node which tell me if there are incoming bytes. Is there an equivalent function for the bluetooth module? Otherwise, how can I keep listen if there is a data without get an timeout read error?

0 Kudos
Message 1 of 3
(2,364 Views)

Keep your listing program inside the loop. Something just like this,

 

images.png

 

 

 

 

 

 

 

 

 

 

0 Kudos
Message 2 of 3
(2,321 Views)

You don't! You have to learn that a timeout error is usually not a bad thing when communicating with external devices. It's important to know that you had a timeout in order to go back and retry or do something else but it is in most cases not an error on which you should abort your loop.

You also don't want an infinite timeout because that would hang your software when the user wants to terminate it. So you keep reading with a reasonable short timeout value that the application can react to termination requests but long enough to not starve your CPU. On return of the read you have really three cases:

1) no error: data was received process it

2) timeout error: no data or not enough data available, clear error

3) other error: something bad happened, report the error, unless your app is some headless system that needs to retry even on error, abort the loop otherwise clear error

After these decisions, check the application exit state and abort loop if the application wants to shutdown, otherwise continue unless you had case 3).

 

Basically the diagram from Sabari is almost right, you just have to add a VI in the error cluster after the VISA Read that checks for the timeout error and if that was the case then clear the error and loop again.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 3
(2,270 Views)