Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Session BeginWrite Waits

Based on the VB.NET SimpleAsynchronousReadWrite example, I'm able to perform BeginRead for my VISA session (TCP/LAN instrument, VXI-11). As expected, BeginRead returns immediately and then my callback gets called when the instrument responds or when a timeout error occurs. I'm even able to use the session Terminate method to abort the operation using the IAsyncResult returned by BeginRead.


But calling BeginWrite doesn't return immediately. It waits for the operation to finish or time out. My callback does get called and the operation does execute and complete properly but the overall behavior isn't async. What is going on?


I'm using Measurement Studio 2013 for Visual Studio 2010, NET Framework 4.

0 Kudos
Message 1 of 6
(4,840 Views)

Hi ray_martin, 

 

Could you give us a little clarification on how you expect the program to work? It sounds like everything is working, just not the way you would like it to, is that correct?

 

Are you reading before you write?

 

A little more information about what you expect will be helpful.

 

Thank you, 

Rachel M.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(4,813 Views)

For VXI-11, a VISA session BeginWrite turns into a RPC device_write request to the instrument's core port. The instrument is supposed to respond with a device_write reply. You can see these packets using a protocol analyzer like Wireshark. What should happen is BeginWrite should wait asynchronously (return immediately) for the device_write reply, allowing the host to perform other processing (Windows GUI etc). During this time, I should also be able to use the VISA session Terminate function to cancel the pending write (host sends RPC device_abort request to instrument's abort port).

 

For VISA async reads, BeginRead ends up sending a RPC packet device_read request then asynchronously waits for the instrument to send a device_read reply. Unlike BeginWrite, BeginRead does return immediately allowing the host PC to do other things. If the instrument fails to send the device_read reply, VISA correctly waits in the background and allows my application code to send VISA terminate (correctly sends packet to abort port) or terminates on its own due to a timeout.

 

So it appears BeginWrite doesn't implement the correct async behavior for the initial RPC device_write request but instead synchronously waits for the device_write reply. I would like BeginWrite to have the same behavior as BeginRead.

0 Kudos
Message 3 of 6
(4,799 Views)

Hi ray_martin,

 

I believe what you are seeing is expected behavior. Unfortunately since this is the expected behavior of the function, we can't really change that behavior.

 

You could write your own VISA protocol, and implement the behavior you would like to see.

Rachel M.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(4,763 Views)

How can synchronous waiting by an asynchronous function be the expected behavior? The present implementation of BeginWrite doesn't take advantage of the instrument's capabilities or the VXI-11 protocol but BeginRead does. NI is halfway there so take this as friendly encouragement to cross the finish line!

0 Kudos
Message 5 of 6
(4,759 Views)

Hi ray_martin, 

 

That is really good feedback, thank you! You should post your suggestions to our Idea Exchange forums. Here is the link: http://forums.ni.com/t5/NI-Idea-Exchange/ct-p/ideas

Rachel M.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 6
(4,743 Views)