I am communicating with a motor controller via the serial port, and through search I've solved most of my problems. However, I'm getting some behavior I don't understand with the buffer and serial read.
For every command I send, there is a response. What I'd like to do is essentially this:
SEND command
SEND command
READ response
where the first command is just an initialization to which I'm not terribly interested in the response, and the second is a query. If I do it as above, I end up reading a different response every time as it seems to cycle through the buffer of input strings.
SEND command
FLUSH buffer
SEND command
READ response
exhibits the same behavior, but with some empty strings mixed in.
SEND command
READ response
SEND command
READ response
also cycles through various inputs, while:
FLUSH buffer
SEND command
READ response
SEND command
READ response
seems to work ok. I must be misunderstanding what VISA flush buffer actually flushes, because I feel like {SEND FLUSH SEND READ} should work for me. I'm sure there are far more grevious inefficiencies in my code than extra serial read commands, but I'd rather not depend on matching them up so precisely in order to be reading the correct status.