I need to finish 02-control from yesterday.
I also need to write a Linux program for communicating with it. A simple version would do the following:
- Take a directive via command-line, e.g. to get pin status, or change it.
- Open a connection to the device (i.e.
open("/dev/ttyACM0", ...)
). - Write a check byte (e.g.
A
). - Read a byte back to make sure it's working (which will be the status of pins).
- Write the actual requested command-line command.
- Read back the status, and output it to
STDOUT
in a meaningful format.
Note that steps 4 and 6 will need a timeout.
More info: https://stackoverflow.com/questions/6947413/how-to-open-read-and-write-from-serial-port-in-c
...and: https://stackoverflow.com/questions/11100630/receive-one-byte-from-serial-port-in-linux