LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bluetooth function Create Listener only works in certain case

Solved!
Go to solution

The Create Bluetooth Listener function outputs a listener ID which can be used to wait for an incoming Bluetooth connection. For every time you run a VI containing this function, it has to create a new listener ID, otherwise the following block Wait On Listener will crash.

 

I have now found that for the Create Listener function to work properly the input Service Description has to be connected to a control element. If its connected to a constant, it will only run once, creating a new listener id, but then keep this id indefinitly. In this case you have to close all VIs and reopen them to be able to run the function again.

 

(See attached VI for an example.)

 

Can anyone tell me, why this is? Is there a difference in compiling/running VIs using control elements instead of constants?

 

Thanks!

 

0 Kudos
Message 1 of 5
(2,744 Views)

hi!

When you say crash and "close all VIs and reopen them to be able to run the function again."

do you mean the function does not respond anymore, or is there an error written to the error cluster?

Generally there is no difference between passing a value from a control or a constant, as long as the

data is the same. Maybe you can use the Equal function to check if the preconditions are the same?

Regards,

  Georg

0 Kudos
Message 2 of 5
(2,722 Views)

 

By "crashing" I mean it produces an error, in this case error 1 (invalid input parameter).

 

This error is produced by the block Wait On Listener because it receives the same listener ID  from the Create Listener block as before. Therefore you can run the VI once without an error but after that you always get an error 1 because the listener ID never changes. That is why you have to close all open VIs (or close LabVIEW) and reopen.

 

The curious thing is that this error only occurs if the Service Description is a constant. If it's a control element it works fine, meaning there's a new listener ID on every VI run and no error from Wait On Listener function.

 

I never thought there was a difference between control elements and constants either. Until now...

 

0 Kudos
Message 3 of 5
(2,715 Views)
Solution
Accepted by topic author pixeL

I could reproduce the error. I submitted a report to R&D. I'll let you know when I hear back from them.

For the moment you can try using a control instead of a constant and make it invisible in the frontpanel.

Regards,

  Georg

0 Kudos
Message 4 of 5
(2,711 Views)

Dear pixeL,

 

This advice is very valuable, I can confirm that the problem still exists in LabVIEW 2016 and even in 2018.

Sadly it is happening right in the Bluetooth example that comes with LabVIEW (Simple Bluetooth.lvproj). Without your suggestion I don't know how long I would have needed to find the solution. Thanks a lot!!!!

Suggestion to NI: until the bug is fixed, the example project should explain this bug and the workaround to solve it. It happens when the "Simple Bluetooth - Server.vi" is started for the second time.

0 Kudos
Message 5 of 5
(2,167 Views)