====== Linux Serial Programming ====== There is ''%%termios%%'' which is the linux library of accessing the serial port. It is super fucking complicated. There are some concepts to keep in mind. **1. Canonical mode**: This is most useful when dealing with real terminals, or devices that provide line-by-line communication. The terminal driver returns data line-by-line. **2. Non-canonical mode:** In this mode, no special processing is done, and the terminal driver returns individual characters. **3. "Blocking"**: sets whether a read() on the port waits for the specified number of characters to arrive. Setting no blocking means that a read() returns however many characters are available without waiting for more, up to the buffer limit. The man page ([[http://man7.org/linux/man-pages/man3/termios.3.html|link]]) for ''%%termios%%'' is actually pretty useful. This is not that complicated. I, and you, can friggin do this. There is an interesting function called ''%%cfmakeraw%%'' that sets the terminal to what I want I think I want. ===== General Programming Serial Stuff ===== If you use ''%%printf%%'' to print to the terminal be aware that ''%%stdout%%'' is buffered! That means that it doesn't just instantaneously print to the terminal. It either waits for a new line, has a timeout (i think) or a buffer fills up. To get ''%%printf%%'' to print immediately either call ''%%fflush(stdout)%%'' or do the following to make the buffer size smaller: // printf which uses stdout is buffered. The larger the buffer, the slower it // will post to the terminal. I can either set the buffer to smaller size like // the following, or call fflush(stdout) to force a write to the terminal char buffer[10]; setvbuf(stdout, buffer, _IOFBF, sizeof(buffer)); ===== General OS Serial Stuff ===== To list the USB devices by dev path use this script ([[http://unix.stackexchange.com/questions/144029/command-to-determine-ports-of-a-device-like-dev-ttyusb0|link]]). I have added this script to ''%%paul_scripts%%'' and added an alias called ''%%listusb%%'' to my ''%%.zshrc%%'' file.