[SOLVED] ofSerial not working (but work outside of OF)

Hi there !

I’m working on a small software, nothing complicated.
I have button from ofxDatGui. When I press the button, it trigger myserial.writeByte(). And of course mySerial is an instance of ofSerial.

Thank you in advance for any help :wink:

My setup

  • System is virtualized over VMWare, host under Windows 10
  • Ubuntu 18.04
  • OF cloned and compiled from GITHUB
  • Branch Stable
  • QT Creator 4.6.1
  • Serial adapter : CP2102 - Silicon Labs

see here :

ofApp.h :

class ofApp : public ofBaseApp{


   	ofSerial mySerial;

ofApp.cpp :

void ofApp::setup(){
    mySerial.setup("/dev/ttyUSB0", 115200);
    unsigned char myByte = 225;
    bool byteWasWritten = mySerial.writeByte(myByte);
    if ( !byteWasWritten )
        ofLog(OF_LOG_ERROR, "Byte was not written to serial port");
void ofApp::onButtonEvent(ofxDatGuiButtonEvent e)
    printf("Hit button");
    cout << e.target->getName() << endl;

    bool byteWasWritten = mySerial.writeByte('t');

    if( !byteWasWritten)
        printf("byte was not written to serial port");
  • Nothing appear on my serial port (I have an oscilloscope connected to my Tx serial adapter.
  • ( writeByte(‘t’) returned True ) and I don’t see “Byte was not written to serial port” message in terminal.
  • Strange thing : mySerial.isInitialized(); return 0 when I try to put it in a while() loop before writeByte(). So everything is blocked. Removed.
  • My user is part of dialout user group.
  • I tried to launch my app in root, changed nothing.

i tried the Example/oFserial compile, run, it find my /dev/ttyUSB0 but can’t writeByte neither.


When I use CuteCom software (not in root) I can send data on my serialPort and I can see it on my scope.

As I said, thank you for your help !


Tested with Arduino plugged and this way create a serial device. This device is also /dev/ttyUSB0. Same behaviors… Not working in OF but work in cuteCom. So problem seems not to be in the usb serial adapter or device driver.


Very strange behaviors : If i launch serialExample, it does not work as usual. If i launch cuteCom it work as usual. But if I launch the both at the same time, serialExample try to open the com port : success, cuteCom open : success, and now serialExample si working as expected. Click make serial frames visible on my scope…

I found solution.

I figured out when using minicom (different form cuteCom) software nothing working until I switch off FLOW_CONTROL.

So I tried to switch off flow control on ofSerial but no method to to that.

I used ofxSerial library instead. Switched to development branch over it.

This library is able to switch on/off flow control. But worked out of the box.

By the way I came across this bug recently, and finally fixed it by turning off flow control in ofSerial. It’s been recently merged into the master branch on Github.