Error -1073807298 Occurs after a VISA Read/Write

Updated May 3, 2018

Reported In

Driver

  • NI-VISA

Issue Details

I am trying to write to and read from an instrument using NI-VISA, and I continue to get Error -1073807298 (Hex 0xBFFF003E) occurred at an unidentified location. Why is this happening? Is there a work around?

Solution

1. Make sure your code opens and closes all VISA session references. Most VISA LabVIEW code will follow the pattern: 1.Open VISA reference 2. Perform reads and writes 3. Close VISA reference.  For an example of this code structure see the example program Simple Serial.vi in LabVIEW by going to help >> Find Examples.

2. Ensure that there are no processes interfering with the I/O ports of your device (Modbus I/O, I/O Servers, etc.). You can verify this in Distributed System Manager.

3. The problem may come from the VISA Write IRP_MJ_FLUSH_BUFFER request causing an INVALID DEVICE REQUEST response from the device. By default, each VISA Read and Write is followed by a VISA Flush call when communicating via RS-232. You can change the VISA Buffer setting to keep VISA from executing the flush call to avoid this error.

If you call the VISA Set I/O Buffer function at the beginning of your application (after the VISA Open, before any reads or writes) and set the mask to 48 (16 + 32, where 16 is the mask for receive buffer and 32 is the mask for transmit buffer) and the size to some value between 4k and the largest amount of data you ever expect to read or write, that will cause the flush command to not be executed. 

IMPORTANT: Be sure of the upper limit when you set them. If it is not large enough for the data that you are transmitting or receiving it can cause your computer to crash.

Additional Information

If you do not call the flush function, NI-VISA will segment all writes into 500 millisecond chunks and call flush after every write. By telling NI-VISA that you will never use more than 4k or the value to which you set the size, NI-VISA in turn will not call the flush. 
 

WAS THIS ARTICLE HELPFUL?

Not Helpful