How to read from serial in c ? (under linux)

If you are sending integers only, it may be easiest to send them as binary data, though there are still some quirks you have to take care of:

  • Check if the Arduino and your Linux computer share the same byte order (little endian vs. big endian). If not, you need to convert to/from the network byte order when sending/receiving the integers. (Check htons/ntohs man pages on Linux).
  • "int" is 16 bits on the Arduino and probably 32 bits on your Linux computer. Use "short" on Linux instead.