07-12-2024 04:58 PM
I'm trying to communicate with an instrument via serial. According to the instrument's manual, when I write "SP", the instrument should respond with with "Maximum Speed: [value]". When I try this in NI MAX, however, what I read is "SP \r \r Maximum Speed: [value]". It seems the command I write is still in the buffer when I read from the buffer. Is this typical for serial communication? Is there a way to avoid this? I can't clear the buffer after I write "SP" because the instrument responds immediately, so then I'd be clearing the information I'm trying to read.
Solved! Go to Solution.
07-12-2024 05:57 PM
It may be typical for some instruments to echo the command along with the response. Check your instrument manual if that is expected.
07-15-2024 08:48 AM
Also, is this 2-wire RS-485? I rarely deal with RS-485, but I remember reading what I sent before being able to read the response when I did.
You need to give a lot more information on your setup before we can really tell you if this is expected. What is the instrument? What is the protocol being used (RS-232, RS-422, RS-485, etc.)?
07-15-2024 12:52 PM
I determined this was the expected behavior for the instrument I was communicating with (which was via RS-422 by the way). I had it in a mode where it echoed every command it received. I was able to change the operating mode so that this echo is disabled.
07-15-2024 01:29 PM
@jrdwight wrote:
I determined this was the expected behavior for the instrument I was communicating with (which was via RS-422 by the way). I had it in a mode where it echoed every command it received. I was able to change the operating mode so that this echo is disabled.
That is common for instruments that want to interface with a terminal program such as Putty. Thank you for letting us know what you found.