Serial port determinism

Posted by Matt Green on Stack Overflow See other posts from Stack Overflow or by Matt Green
Published on 2010-03-18T16:14:11Z Indexed on 2010/03/18 16:31 UTC
Read the original article Hit count: 357

Filed under:
|

This seems like a simple question, but it is difficult to search for. I need to interface with a device over the serial port. In the event my program (or another) does not finish writing a command to the device, how do I ensure the next run of the program can successfully send a command?

Example:

  1. The foo program runs and begins writing "A_VERY_LONG_COMMAND"
  2. The user terminates the program, but the program has only written, "A_VERY"
  3. The user runs the program again, and the command is resent. Except, the device sees "A_VERYA_VERY_LONG_COMMAND," which isn't what we want.

Is there any way to make this more deterministic? Serial port programming feels very out-of-control due to issues like this.

© Stack Overflow or respective owner

Related posts about serial-port

Related posts about linux