LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

I don´t get your point... What do you mean by "too static" ?


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

Epictetus

Antoine Chalons

0 Kudos
Message 21 of 31
(1,114 Views)
I intend to use a global array to record serial port name in used.
0 Kudos
Message 22 of 31
(1,108 Views)
I think chipie might have special reason, why he needs to get through the ports automatically. For instance, if you have several devices to control but do not know which device is linked to which port and in addition you can not say to which port it has to be linked (although it's not related - nobody cares about where a usb-device is plugged in), you need to iterate over the ports and check what kind of device is there. So if you assume your devices are plugged at com1 and com2 but they are at com3 and com4, your program doesn't work.
 
Ok - now you might say that this could be done by configuring the SW. For me, you're right. But I think, you also like SW that finds a device on its own rather than it has to be told where the device is.
 
Anyway, this discussion won't lead to a helpful point, unless we know what chipie wants to accomplish. So let's wait for further information... 😉
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
Message 23 of 31
(1,108 Views)
Ok becktho, that's quite sensible 😉 !

Chipie, the more you describe what you want, the more people on the forum will be able to help you 😉



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

Epictetus

Antoine Chalons

0 Kudos
Message 24 of 31
(1,100 Views)


@chipie wrote:
I intend to use a global array to record serial port name in used


Ok - so now we know the target. And unfortunately I have to say, I would also try to iterate over the ports (but rather with one vi than two - maybe there's another reason for that). But unless there is no "port in use" error this is quite difficult.
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 25 of 31
(1,095 Views)

Hi Chipie,

I think we still require more information about what you intend to do.

How do you intend to carry out the iteration? Will you do this by calling each port in turn, and then use the error received as a way of verifying the port is in use.

 

0 Kudos
Message 26 of 31
(1,087 Views)
I have more than one VI, they all have the same Block Diagram as attached file.
 
It is so strange that when I make them run at the same time, no error appears though they access the same serial port.
 
I need to know when there are more than one VI access the same serial port, and forbid they do it.
 
 
 
 
0 Kudos
Message 27 of 31
(1,076 Views)
The OS will prevent different applications from accessing the same port. So, if you have Hyperterminal running, you cannot open a VISA session. In your case though, you only have VISA running so the OS doesn't do anything. I think you can get what you want by using the VISA Lock. After opening a session, you can lock it and if another VI attempts to open a session to the same resource, you'll get a lock error. Look at the shipping example called Locking.vi.
Message 28 of 31
(1,072 Views)

I thought VISA has a built in semaphor lock, when you open a VISA session a lock is aquired for the resource (ie COM1) and if another session tries to use this resource an error will occur.  Visa will manage your resources for you to prevent conflicts.

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 29 of 31
(1,065 Views)
Not that I know of. If you do something like the attachment or in two different VIs, no error will be generated. If a second VISA open happens on the same resource, it does not create a new reference, it just uses the already existing one. In older versions of VISA, each VISA Open did create a new reference and badly written programs that did a VISA Open without a VISA Close could have hundreds of references open to the same resource. This would create other problems (such as running out of memory) but there was never any error message generated.
0 Kudos
Message 30 of 31
(1,055 Views)