ofSerial strange behavior

Hi.
I’m not sure what’s going on with my code but I’m slowly loosing my mind trying to figure it out.
I have a FTDI connected to USB, using minicom I can see data transmission and everything looks OK. Each frame looks like this:
68 10 01 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 00 02 00 00 00 00 00 00 00 00 00 00 f9 57 16

Starts with 68, ends with 16, some data in-between.
At this point my code is simple:

void afApp::setup(){
serialConnection.setup("/dev/ttyUSB0", 115200);
serialConnection.flush();
serialConnection.drain();
}
void ofApp::update(){
lastByte=serialConnection.readByte();
ofLog(OF_LOG_NOTICE, "Last byte: " + ofToHex(lastByte));
}

…and I expect to see each byte in separate line but the 16 at the end is missing everytime.

[notice ] Last byte: 68 [notice ] Last byte: 10 [notice ] Last byte: 01 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 0a [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 02 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: 00 [notice ] Last byte: f9 [notice ] Last byte: 57 [notice ] Last byte: 68 [notice ] Last byte: 10 [notice ] Last byte: 01 [notice ] Last byte: 00 [notice ] Last byte: 00 ...

Fixed. What you need to do:

  1. run minicom and configure it so it read from serial port.
  2. quit minicom WITHOUT reseting port (CTRL-A, Z, Q, enter).
  3. save current port config with stty -g < /dev/ttyUSB0 >ttyUSB0.settings
  4. add at the beginning of your program
    ofSystem("stty < /dev/ttyUSB0 cat /root/ttyUSB0.settings");