I'm writing a command-line tool (Mac OS X, NI VISA 15.5) to pipe arbitrary data in and out of a GPIB device via an NI GPIB-USB-HS+ controller.
It seems to be working fine if I read the entire buffer at one time, but I'd like to make it more flexible and repeatedly read in smaller chunks until the read gets an end-of-transmission. When I do this, the last byte seems to be getting lost. If I do a 1-byte-at-a-time loop (as a proof-of-concept), every other byte is lost.
If sizeof(s_data_buf) == 64, I get the following response to my *IDN? query:
ICS Electronics, 4867, S/N 1603049, Rev X0.00 Ver 11.08.16
If sizeof(s_data_buf) == 1, I get this response:
ISEetois 87 / 634,RvX.0Vr1.81
Stepping through the code and watching the status on the GPIB device, it looks like the GPIB device is only queried once, and the result is buffered in the GPIB-USB-HS+. Each call to viRead pulls data from the buffer. Is there an extra pointer increment going on somewhere in the VISA/488.2 chain?