Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

IRP_MJ_WRITE completion problem with VISA (UMDF)

Ok, this is a bit of an advanced question.  I'm creating a device driver (using UMDF) to emulate a COM Port.

This device functions perfectly in Hyperterm - open/read/write/ioctl/flush/close, etc.

 

VISA, on the other hand, isn't a happy camper.

 

Here's my quandary:

  • If I complete a Write request without information (pWdfRequest->Complete( S_OK ); ) then VISA will rapidly and repeatedly re-send the same IRP_MJ_WRITE request with the same data until my buffer fills up and I return an error.  VISA then returns from the write with VI_ERROR_SYSTEM_ERROR.
  • If I complete that Write request with information (pWdfRequest->CompleteWithInformation( S_OK, BytesWritten ); ) - that information being the actual number of bytes written - then the VISA write immediately returns VI_ERROR_IO.

These are the only two methods I know of (and that are documented) to complete an IRP in UDMF.  I haven't tried canceling the IRP since that would be coutnerproductive.

 

Any clues?

0 Kudos
Message 1 of 8
(4,653 Views)

Forgot to supply version information: (Multiple computers)

 

NI-VISA 4.3

LabVIEW 8.2.1, 8.5.1, 8.6

MAX 4.4.1, 4.5

0 Kudos
Message 2 of 8
(4,639 Views)

Hey tonykaegis,

 

On this issue, I suggest using a port monitoring program, such as portmon, to analyze the lower-level calls being made to hyperterminal and then to analyze the same call to VISA one line at a time. You can then compare the two and you can try and replicate the behavior.

 

Thank you,

Ryan

National Instruments
Applications Engineer
0 Kudos
Message 3 of 8
(4,590 Views)

Ryan,

 

Thanks for the suggestion.  I used Portmon (from SysInternals a.k.a Microsoft) extensively in making the device driver function correctly in HyperTerm.  I was attempting to do the same with VISA when I ran into this problem.  (Attach Portmon to a serial port, use VISA Interactive Control to excersize the port, etc.)

 

One slight issue I have with Portmon was that I couldn't figure out how to make it decode the contents of some of the input/output data to ioctls.  (e.g. IOCTL_SERIAL_GET_COMMSTATUS, IOCTL_SERIAL_GET_HANDFLOW, IOCTL_SERIAL_GET_CHARS, etc...)  Some of the ioctls' data are enumerated, but not all.

 

Additionally, I have been unable to get Portmon to attach to my UMDF driver.  this isn't a big issue since it's rather unnecessary.  This is, after all, my own driver that I'm developing and debugging, therefore I have complete access to debug logs, breakpoints, WinDbg, etc., but having a Portmon log for 1-to-1 comparison would be nice.

 

Everything seems to be working nicely - except for the write IRP completion.  If I ignore the error returned by VISA, the virtual port functions just fine.  Every other major VISA operation completes correctly.

 

However, this error (spawned from a successfully completed write operation) will break any and every correctly written program.

 

Is there any sort of detailed VISA debug log that might give me a clue as to just WHY I'm getting this VI_ERROR_IO?

 

Thanks again,

 

Tony

0 Kudos
Message 4 of 8
(4,586 Views)

Hey Tony,

 

So you have questions on specifically you are getting error VI_ERROR_IO. If you look into the NI-VISA help from Start >> All Programs >> National Instruments >> VISA >> Documentation, you will find the following information in the NI-VISA Help. The error VI_ERROR_IO (Hex BFFF003Eh) Could not perform operation because of I/O error. This shows that this a direct problem with the I/O. 

 

The following KnowledgeBase 3VLAULIZ: Why Does My Serial Instrument Work in Hyperterminal But Not in LabVIEW or VI... gives a little bit of information into the differences between how Hyperterminal works and NI-VISA. It also shows some of the problems you could be running into. I would recommend looking through this to see if one of these maybe the root of the issues you are seeing.

 

Thanks

Sarah S.
Applications Engineering
National Instruments
0 Kudos
Message 5 of 8
(4,548 Views)

Sarah,

 

Thanks for the reply!

 

Yes, I completely understand the documented meaning of VI_ERROR_IO.  I guess what I should be asking is: under what circumstances will VISA return this error code?  Unfortunately, this error message is much like the widely loved BSOD or STOP errors.  It simply indicates that some error occured and there is either insufficient information to detail exactly what happened or the developers were not expecting an error of this type or at this location.

 

Well, I caused that error by doing what it looks like the documentation says I should do.  So what am I doing wrong?  There is no other documentation (that I have been able to find) that says 'look at this file for a log of what VISA was doing when the error occured.' or any other method of determining what's going wrong within the depths of VISA.  BSODs give memory dumps.  A running application can be attached to with a debugger and exceptions caught.  VISA... is a black box.  (Rightfully so, except when very low level things do not work right...)

 

As to the link you sent - it contains good information, but it is much too high-level. 

 

Yes, Hyperterm and VISA act differently in that Hyperterm sends characters as they are pressed while VISA can send an entire string at once.  However, when using my driver, VISA returns VI_ERROR_IO if any write request occurs, even if empty.  All other requests function correctly.  IOCTL handling is valid and consistent.  (IOCTL_SERIAL_GET_CHARS and IOCTL_SERIAL_SET_CHARS access the same data and when using software flow control, the driver does send the appropriate XOn/XOff char, etc.)

 

I thought NI would be the proper place to ask around for this question since they're one of the larger players in the now-defunct VXI PnP Alliance and IVI Foundation.  Should I be taking this incredibly technical question elsewhere?  Should I create a support request?

 

Thanks,

 

Tony

0 Kudos
Message 6 of 8
(4,526 Views)

Hello Tony

 

I know your last post about this issue was years ago. Unfortunately I have exactly the same problem with my UMDF driver. Have you been able to solve the issue?

 

Thanks,

Andy

0 Kudos
Message 7 of 8
(3,416 Views)

You might want to try creating a new thread so that the community can see and help with your issue. It's unlikely that the community will see this post and respond. 

Rob S
Applications Engineer
National Instruments
0 Kudos
Message 8 of 8
(3,389 Views)