Thanks for the help, LoganS. Is there a special trick to attaching .spy files to these posts? Since .zip files are allowed I zipped up two .spy files and attached that. I'm on a PC at work and I don't have easy access to other file compression programs, so I hope that works OK for you. The first file is called EARG.spy and documents the EARG error.
After starting NI-Spy, I
1) Start VB and open my project
2) Run the project
3) Get the error
4) Close the the project, stopping program execution
5) Re-run the project
6) Successfully collect the data
7) Close the project
😎 Exit VB
In this project there are two instruments.
ud0: SR850 Lock-in amplifier
ud1: Diode laser
Here is what is going on at the different lines in the spy file:
1-59: Set up both instruments for a scan
60-61: Set up lock-in to start the scan with a Trigger()
62: Send Trigger() to all instruments. Previously, I had two lock-in amplifiers collecting data simultaneously so I started them both with a GPIB trigger. To simplify debugging of this problem, I completely removed all code relating to the second lock-in.
63-586: Wait around for the scan to complete. During this time, I send "STB?" to the lock-in to query its status byte to see if the scan is done. I am also monitoring the temperature of the diode laser with ":SENS:TEMP..." queries.
587-590: The status byte changes to "1". The scan is complete.
591-598: Some "clean-up" stuff and allocation of arrays to hold the trans from the lock-in.
599-609: ERROR. Here is where I ask the lock-in how many points it has and attempt to read those points with the "TRCA?" query.
610-621: Recovery from error, graceful exit from scan subroutine.
622-623: Close connections to instruments on exit from application with ionl().
624-1287: Do the whole thing again, this time without an error. The "TRCA?" query is on line 1236.
The second file is called vbcrash.spy and documents the steps necessary to crash VB6. Basically I run everything as before and, as before, get an EARG (4) error on line 567. This time I DO NOT shut down the program after error recovery. Lines 570-599 show a bunch of commands sent to the laser and lock-in for recovery and a re-run of the scan. Note that nothing is a query and there are no ibrd() calls. The first query is on line 602 and it is a request for a status byte, i.e. "STB?". The buffer for this query is set with:
Dim buf As String * 255
so the buffer size should be 512 bytes. Line 604 shows the ibrd() operation reading 510 bytes. The buffer fills with the data from the "TRCA?" query which exited with EARG (4). I don't know whether this is data that was in the output buffer of the lock-in or if this was data that was read off of the lock-in, was sitting around in the ni dll's, and got copied into buf on the next ibrd() call. After that, the scan exits because the value read is not a boolean. When I end the program, I get a "vb6.exe Application Error" with the message:
The instruction at "0x77aa48e4" referenced memory at "0x37363952". The memory could not be "read".
and VB then exits upon closing the dialog.
This really looks to me like the ni drivers are writing past the end of the buffer, but I don't have a debugger installed on this machine so I can't check that. Or maybe I just want to believe that there is a problem with someone else's code instead of mine 😉
Thanks agian for all the help,
-Forrest