03-04-2010 04:45 AM
Hello,
I am trying to communicate my system by a TCP/IP connection using VISA. I have two vi's running in parallel.
The first one reads messages received and enqueues. [ VISA read with a timeout of 2 seconds]
The second one sends a message and waits the answer from the queue where the first VI puts the messages.
I can see a timing problem. When the first VI is reading (with a timeout of 2 seconds), the second one can not send anything. So, if "sender" VI sends one command per second, "VISA Read" makes a sample time of 2 seconds (timeout).
Maybe I have not explained very well my system, but my question is: is there any way to make VISA write/read functions at the same time ?
[I know my problem will be solved decreasing the read timeout]
Thanks you
03-06-2010 05:41 PM
03-07-2010 02:02 PM
Dennis Knutson wrote:
What are you reading/writing? Is it the same instrument? If so, what is the instrument? Instruments will typically send data only after you have written a query to it so you have to sequentially do a write and then a read.
I have found that the VISA read and write VIs do not allow parallel processing. Once it is waiting for either the read or the write the other Vi is blocked. This has been confirmed with NI. The work around that we use is to have a state machine that will switch between the read and write operations. The write functions are driven by a queue and the read operations post all data to a queue for a parallel task to process.
03-08-2010 03:30 AM
Escrito por Mark Yedinak:
Dennis Knutson wrote:
What are you reading/writing? Is it the same instrument? If so, what is the instrument? Instruments will typically send data only after you have written a query to it so you have to sequentially do a write and then a read.I have found that the VISA read and write VIs do not allow parallel processing. Once it is waiting for either the read or the write the other Vi is blocked. This has been confirmed with NI. The work around that we use is to have a state machine that will switch between the read and write operations. The write functions are driven by a queue and the read operations post all data to a queue for a parallel task to process.
Dennis: I read and write ASCII messages. But the instrument does not only send me answers of my commands. It sends me also asyncronous messages. So I have to read with a "while" if there is any new message and enqueue the messages received. By other way, I send my commands and wait the answer. The problem is, if I wait for a 5 seconds with "Read VISA" I can not send any command, because "Write VISA" is blocked these 5 seconds.
so, Mark, I think you have answered my question. "Read VISA" blocks "Write VISA" when it has a timeout.
Thanks you!!