Qt World Summit: Register Today!

Simple Terminal about serialport bug on mac 10.10.1

  • build Qt Creator "terminal" Example,and run it.
    Set Serialport baudRate:921600 Data Bits:Data8 Parity:NoParity
    then open the support serialport and send any data

    serialport recvied all 00

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    That's a bit vague, you should add which version of Qt you are running, what hardware you are using and how do you know that you get only 00

  • Thanks your answer

    This's Qt 5.4.
    Use USBtoUart connect mac anther too but the system is windows,in windows use any serialport helper listen

  • Lifetime Qt Champion

    Are you sure you are using the same com port parameters on both sides ?

  • I' m very sure! I used Qextserialport,it 's ok, but why qt does not?

  • I verify it that It's qt's bug and fix it .

    in qserialport_unix.cpp replice

    const qint32 unixBaudRate = QSerialPortPrivate::settingFromBaudRate(baudRate);

    const QSerialPort::SerialPortError error = (unixBaudRate > 0)
        ? setStandardBaudRate(unixBaudRate, directions)
        : setCustomBaudRate(baudRate, directions);
    if (error == QSerialPort::NoError)
        return updateTermios();


    if (setBaudRate_helper(baudRate,directions)==QSerialPort::NoError)
    return updateTermios();

    It's run well!!!!

  • Qt Champions 2020

    A problem that on OSX/BSD (at least on v10.9.4 with XCode v6.1) the B921600 speed are not defined in termios.h. There are defined standard speeds up B0 to B230400.

    Thus, apparently, you were lucky that your modification works because in BSD/OSX, the macroes of Bxxx have values of real speeds (i.e. it is not a bit flags as in Linux). Therefore your code works with miracle. :)

    But it is strange, why it does not working via IOSSIOSPEED (as custom baud rate).

    In your case, the setBaudRate(921600) method returns true without an errors?

    PS: Perhaps, QtSerialPort need to correct somehow for specifics OSX in the future.

  • Qt Champions 2020

    bq. In your case, the setBaudRate(921600) method returns true without an errors?

    Probably, up to Qt 5.4.0 the setBaudRate() will not return an error (this is a bug: https://qt.gitorious.org/qt/qtserialport/commit/93717299150149646d7f1546c8cc86fe54d9319e) . But in Qt 5.4.1 it is fixed (you should get an error from the Terminal example).

Log in to reply