07-02-2010 10:51 AM
@Jeff Bohrer wrote:
Generally, use some form of flow control. a temination character is one common approach so that you read until a specific character is seen (0x0A, linefeed is very common). the RS-232 recommendation (RS stands for Recommended Standard) allows for several handshaking method of flow control as well. Perhaps your equipment uses one of these methods?
Yeah, the device I'm communicating with does end each string it returns with a Line Feed. I think the problem I've been having, and this may explain why the VISA events aren't working right, is that I'm not taking time into account. The default mode of these read and write functions is asynchronous. So, if I send something out via a write and then immediately try to listen to the port, things get scrambled because the write function hasn't completed.
07-02-2010 10:58 AM
@rolfk wrote:
Seems like your expected string is actually terminated by a linefeed character. VISA supports character terminated reads and even enables that for serial ports by default.
The entire loop in the middle and the "wait for event "can be simply replaced by a single VISA Read when you let VISA use read termination mode. It even uses line feed by default as termination character but you can easily modify that at the VISA Serial Init function.
I don't see the ability to specify a termination character in the VISA read functions, but this does sound very useful, or is that in the VISA setup?
07-02-2010 11:24 AM
It is on the connector panel of the VISA Configure Serial Port function. Look at the Basic Serial Write and Read example. It useds the Configure Serial Port function. At the top between Timeout and Enable Termination Character. Unfortunately in the example, they didn't wire up that connector making it not so obvious. But in the example, they disabled the termination character which meant there was no reason to wire something to the termination character input.
Make sure you have Context Help turned on (Ctrl-H) and hover over those functions.