LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to prevent the same serial port read by two VISA Read?

I just can double chipies findings. I also made to vis (none was posted here) and accesses the same port. I just got a timeout error - quite strange...
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 11 of 31
(1,318 Views)

Were the two Vi working synchronously or one after the other?

Also are you sure you communicated with the correct post - you usually get a timeout error when nothing is connected to that particular port, or the instrument is not turned on.

And did you close the Visa resource at the end of each of them?

 

0 Kudos
Message 12 of 31
(1,317 Views)
Why do you want 2 VIs to use the same serial port ? This is not a good idea, this can be source of error !

Use one VI for port COM1, one other VI for port COM2, and so on...
Also you can check the error cluster to see what it says, maybe you just haven't set the correct parameters (baud rate, etc...) and this might be the source of the error.

Have you already managed to read data from your devices ? If not, I suggest you go to Help >> Find Examples >> search for "visa" and open the VI called "advanced visa read", this might help you.
For some device, before reading you have to write a comand line.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

Message 13 of 31
(1,315 Views)
Of course they ran synchronously - otherwise it wouldn't make sense, right? 😉
 
And of course I connected them both to the same port.
 
No, I did not close the resource, as this also wouldn't make sense, because then the port is available again.
 
I open a port and use it (basically in a while loop) and close it afterwards. While there is processing (in the while loop mentioned) I start a second vi, accessing the same port and I don't get a "port in use" error...
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 14 of 31
(1,308 Views)
I don't want  2 VIs access the same serial port.  On the contrary,  I hope to forbid they to access the same port.
 
Labview allows they access the same port and can't produce any error, so I can't know they are accessing the same port and forbid them.
 
The method I used to make two VIs run synchronously is same as becktho.
0 Kudos
Message 15 of 31
(1,303 Views)
Well you have the option of setting the different COM ports to Default Value on the VISA Resource. This will stop this from happening. 
0 Kudos
Message 16 of 31
(1,299 Views)
As I understood the whole thing, chipie wants to iterate over the com-ports to access some kind of device. If the port is not in use, he wants to access it.
So you need to get a "port in use" error, otherwise you don't know if you can access the port or not.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 17 of 31
(1,294 Views)
so a simple flag system using a shift register can be used then, with the Vi setting the flag when in use, and unsetting the flag when its finished.
Message 18 of 31
(1,291 Views)
A semaphore... yes... is it not to complicated for such a simple function ?

As Chipie confirmed earlier, there is several device, but each device is connected to a different serial port ; what's wrong with having one VI for each port Smiley Surprised ???

We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 19 of 31
(1,285 Views)
@Titou: I just can say it's to static
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 20 of 31
(1,281 Views)