LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Are Visa serial vi's rentrant?

I have a few of serial devices I need to talk to.  In some cases there are multiple devices on a port (I'm using a serial device that acts as a bridge to a bus based scheme called SDI-12).  In this case, non rentrancy in the vi's with the embeded visa routines keeps me out of trouble. 

In other cases, I have routines that call single device per port serial stuff.  In this case I'd like to use the same set of vi's to talk to more than one device at a time, without collisions.  Will making all of the access routines for these types of devices rentrant allow this to happen?  What sort of ways can I inadvertantly shoot myself in the foot in doing this?

Thanks
LV 8.6 on Windoze XP
0 Kudos
Message 1 of 6
(3,776 Views)
You can't set the VISA functions to be reentrant. That concept applies to VI, and not primitives/functions. I believe what you're looking for is discussed in this article.
Message 2 of 6
(3,748 Views)
Look at the Action Engine (AE) concept. If you have an AE with the serial read and write inside and actions such as Initialize, Write, Read, Write then Read, and Release Port, and only use that VI to access the serial port, then no conflict is possible. This VI is not reentrant.

Lynn
Message 3 of 6
(3,742 Views)
But what If I want to allow parallel access of different ports?

 Do I have to write an AE for each port access? 

i.e. SerialAE_com1.vi, SerialAE_com2.vi, etc?

Also, if the Visa vi's are not rentrant, then how can I access different ports in parallel?

Thanks

Message Edited by Clueless1 on 10-11-2007 01:17 PM

LV 8.6 on Windoze XP
0 Kudos
Message 4 of 6
(3,738 Views)
I had not thought about that. My first thought is that a separate VI for each port would work as far as LV is concerned. I do not know whether the VISA functions or the OS will allow truly parallel access. If you were careful with Bytes at Port and waits, I suspect that you could achieve a "pseudo-parallel" operation which would be fast enough to avoid port buffer overflows.

Perhaps you can put together some simple test VIs and see if things block too much to work in your application.

Lynn
0 Kudos
Message 5 of 6
(3,726 Views)

To pevent multiple threads that use unique devices on a sinlge serial port ---> Use Lynn's AE suggestion.

To allow multiple thread to access unique ports, make sure the VI's that call the VISA functions are

1) unique VI's or

2) Are not unique but are set as reentrant

AND

The VISA calls are set as "Async".

Notes:

GPIB does not require the above protection UNLESS you have multiple thread accessing the SAME device. In that case use the AE approach to makes sure you get the response that goes with the queury.

Make sure you use the latest and greatest versin of NI-VISA. In about LV 7.0 there was a bug that forced an application to run in the UI thread (single threaded) when the VISA call was happening. This apprears to have been fixed.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 6
(3,722 Views)