From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

I have two same VI run at the same time, They are used to read the data from serial port and displays the data.
they are permitted to select serial port at will, but prevent to select the same port.
 
I think  error should display when they select the same port, but they can run synchronously.
If I used other serial port reader builded by other programming language such as VB,  which runs with the above VI, ERROR -1073807246  would display.
 
How can I prevent  two VIs read the same VISA serial port? Thanks.
 
 
   
0 Kudos
Message 1 of 31
(3,203 Views)
Hello,

Why don't you use only one VI that will communicate on the serial port ? You could call that VI from different part of your application.


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

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 31
(3,191 Views)
I hope they can work independently. In my program ,there will be more than two same VIs run, it depends on how many devices I want to detect. 
0 Kudos
Message 3 of 31
(3,188 Views)
Hmmm... I am not sure I understand exactly what you need.. Smiley Indifferent

Correct me if I miss something :
 you want your application to communicate with more than one device,
 you will used VISA function to communicate,
 each device will be connected to a different serial port ( >> that means as many serail ports as devices)

Is this correct or not ?

Trying to help...


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

Epictetus

Antoine Chalons

0 Kudos
Message 4 of 31
(3,182 Views)
correct.
0 Kudos
Message 5 of 31
(3,162 Views)
Well, then I suggest you make one VI for each device, each VI being a Functional Global Variable, have a look at the example attached.

Make sure the "init" state is run once at the begining of the soft and the shift register will hold the VISA session port the port. 😉

Hope this helps

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

Epictetus

Antoine Chalons

0 Kudos
Message 6 of 31
(3,157 Views)

sorry, I am still not clear now.

I think there are at least two VIs when the read conflict occures.

Each VI has VISA Configure Serial Port 、VISA Read and VISA Close . 

After the first VI ran using the com1, if  the second VI  runs and still using the com1, the second VI should appear error.

Thanks you very much.  Sorry for my poor expression.

 

0 Kudos
Message 7 of 31
(3,154 Views)
 
Smiley Indifferent Smiley Surprised Smiley Indifferent

I said "
each device will be connected to a different serial port ( >> that means as many serail ports as devices)" and you said it was correct.
So you just need to make as much VI as the one I sent as you have devices and change the port (one vi with COM1, one with COM2, ...)

And every time you want to communicate with a device just call the VI corresponding to the port. Like this :


Message Edité par TiTou le 07-14-2006 09:18 AM


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

Epictetus

Antoine Chalons

0 Kudos
Message 8 of 31
(3,152 Views)

I agree with TiTou, if you dont actually close the Port after opening it any Vi that attempts to initalise/contact the port will get an error.

If the instruments are all on seperate ports you could make the port/Visa resource default for each one.

0 Kudos
Message 9 of 31
(3,143 Views)
I made two VIs as attached(mycom1.vi &mycom1_2.vi). they both used com1.
 
Run the two VIs, I found they two can run synchronously, and didn't disappear error. I want one of them would disappear error, so that two VIs read the same serial port can be prevent.
 
 
Download All
0 Kudos
Message 10 of 31
(3,142 Views)