Jason:
The part that's causing problems for you is that you can't have 2
simultaneous asynchronous write/read calls in progress on the same VISA
session. So there are 3 solutions I can come up with that might help:
1) Use 2 different VISA sessions. Make sure to explicitly call VISA Open
before calling Configure Serial Port, and make sure that 'open duplicate
session' is set to True. In this case, make sure you close both session
refnums when you are done, with VISA Close. (The default to 'open
duplicate session' is False, which lets LabVIEW recycle sessions. But when
you explicitly open duplicate sessions, you're in charge of releasing
them.)
2) Use the 'VISA Bytes at Serial Port' property node to check for data
having arrived, in a loop, before you call VISA Read. That way it won't
block in the asynchronous node.
3) Use the 'VISA Wait on Event' function to wait for the 'Serial-Character'
or 'Serial-TermChar' event (make sure you enable it first.) before you call
VISA Read.
Suggestions 2 and 3 are pretty much the same, except the fact that in case
#2, you'll need to create a while loop with a sleep, whereas in case #3,
VISA basically does exactly that for you.
To be honest, the choice of synchronous versus asynchronous I/O is pretty
much irrelevant since LabVIEW 7.0 came out. Because each execution system
contains multiple threads, synchronous I/O on one thread doesn't prevent
other LabVIEW execution paths within the same execution system. It's still
useful if, for example, you wanted to read from 16 different serial ports,
all in parallel (no pun intended). With synchronous I/O, there wouldn't be
enough LabVIEW threads to handle them all simultaneously. But with
asynchronous I/O, it works reasonably well. (Yes, this case has come up.)
I hope this explanation helps.
Dan Mondrik
National Instruments
|---------+-------------------------------->
| | "Jason Dunham" |
| | <[EMAIL PROTECTED]> |
| | Sent by: |
| | <[EMAIL PROTECTED]|
| | .nhmfl.gov> |
| | |
| | |
| | 06-04-2004 01:44 PM |
|---------+-------------------------------->
>--------------------------------------------------------------------------------------------------------------|
|
|
| To: "Info LabVIEW Mailing List" <[EMAIL PROTECTED]>
|
| cc:
|
| Subject: Asyncrhonous Serial VISA
|
>--------------------------------------------------------------------------------------------------------------|
Is anyone having success at running asynchronous VISA calls for serial port
reads and writes?
I made a simple test VI to read one byte from COM1, and write a continuous
stream of bytes out of the same port in a parallel while loop.
The write loop stalls until the read command times out. I even tried
moving the read to a subvi and changing itâs execution system, but to no
avail.
If I read and write from different ports it the read and write are
independent, even if the VISA nodes are set to run synchronously.
Iâm just not getting the whole asynchronous concept, I guess. I have yet
to create a VI which behaves different with sync or async VISA calls.
Iâm using LV 7.1, VISA 3.1 and Windows XP.
Jason Dunham
SF Industrial Software, Inc.