int main() { Serial serial; serial.open("/dev/ttyUSB0", 38400); // might need to change to your USB port // read and parse one line at a time while (true) { string s = serial.readBytesUntil('\n'); parse(s); } return 0; }