07-01-2025 03:30 PM
Hi, I'm trying to communicate with a serial instrument using NI MAX or LabVIEW. Luckily I've got the instrument manual and know working commands and expected responses. Writing commands proceeds without error. However, when I read them I get a VISA timeout error for 2000 ms, or even up to 10000 ms even though I can still get data in the buffer of MAX. With LabVIEW, the VISARead VI just gives up at the timeout error. I have tried reducing the number of bytes to be read to the expected amount, but this didn't stop the timeout.
This is not a situation I have encountered before. How can I resolve the timeout error?
Example below of a successful write/read sequence from MAX. The read result is a "status good, no errors" message from the instrument.
14: Write Operation ($STA3504\r)
Return Count: 9 bytes
15: Read Operation
Return Count: 15 bytes
$STA,0301,2ED1\r
07-01-2025 09:50 PM
Set the termination character to \r properly when setting up your VISA operation.
Highly recommend watching this - https://labviewwiki.org/wiki/VIWeek_2020/Proper_way_to_communicate_over_serial
07-02-2025 08:31 AM
By default, VISA sets the termination character to a Line Feed (\n) as most instruments out there end a message with a Carriage Return and a Line Feed or just a Line Feed. It appears your instrument only uses a Carriage Return (\r). So set your termination character to be the Carriage Return (\r, 0xD, 0d13).