finxing a bug in QtSerialPort



  • Please, could somebody advise how to download, modify and recompile QtSerialPort?
    There is a bug on the library for linux.
    It doesn't detect parity error because ::readPerChar and ::setParity methods has not been correctly written and must be modified.
    I have found the issues and I know how to resolve it. I would also like to collaborate programming if I am welcome to do that.

    Please, I hope your help
    Thank you very much


  • Qt Champions 2016

    Hi
    You can open a bug report

    http://doc.qt.io/qt-5.5/bughowto.html

    Source from here
    https://github.com/qtproject/qtserialport
    or via
    https://wiki.qt.io/Qt_Serial_Port
    also build instructions here.



  • It doesn't detect parity error because ::readPerChar and ::setParity methods has not been correctly written and must be modified.

    Now, this has not sense, because the ParityError, FramingError and BreakConditionError will be deprecated, since 5.6:

    https://codereview.qt-project.org/#/c/125517/

    Idea is: If you want to detect the parity errors, then you should use QSerialPort::handle() and to reconfigure the port to receive the byte-stuffed stream. In this case you need just parse it correctly, manually.

    Things is that this feature can no be implemented for all devices/drivers/platforms, and you should to use it if you know that the your device support it for this platform.



  • First of all, thank you very much for all responses. I need a little bit more help!

    1. So, what I understanded is: Because is not possible to implement parity checking in all platforms so it is going to be deprecated for all, included the ones that do support it.? Is that correct? Please, help me to understand. It is actually working on Windows, it is going to be unusefull too? I mean, newer releases of QtSerialPort library will not support parity checking even in windows?

    2. If I need to check parity input I should use QSerialPort::handle() in order to access the file descriptor and to set parity checking as it is documented on termios? (I need my app running in linux)


  • Lifetime Qt Champion

    Hi,

    Just to correct one thing: the official code repositories are available at http://code.qt.io. github is just a mirror



  • So, what I understanded is: Because is not possible to implement parity checking in all platforms so it is going to be deprecated for all, included the ones that do support it.?

    Yes. If you know that your device support it. then you should implement it himself.

    Is that correct?

    I think - yes. Because it simplifies 90% of code in QtSerialPort.

    It is actually working on Windows, it is going to be unusefull too?

    This never worked on Windows correctly. Because we do not know what of a received byte is damaged.

    Maybe need to use another approach, using IOCTL_SERIAL_LSRMST_INSERT control code on the handle:
    https://msdn.microsoft.com/en-us/library/windows/desktop/aa363403(v=vs.85).aspx

    In this case, maybe, the input stream will be byte-stuffed (by analogy with Linux), and then we can try to detect any of damaged byte (just parse an input stream).
    But a problem is that this way is undocumented (I did not found any responsible documentation), and I have no devices which are support this ioctl on Windows.

    I mean, newer releases of QtSerialPort library will not support parity checking even in windows?

    Yes, see above.

    If I need to check parity input I should use QSerialPort::handle() in order to access the file descriptor and to set parity checking as it is documented on termios? (I need my app running in linux)

    Yes, after opening and configuring the device, you should to use specific flags with termios, that will allows to enable a byte-staffing feature on the input stream. In this case you should just parse an input stream with the markers to detect of damaged bytes.

    UPD:

    The deprecation reason is in fact that we need to read byte-per-byte, that increases an CPU loading and so on, that is unacceptable in some cases. Also, since it is complicates a code, does not supported for many devices/drivers/platforms.

    A good way, IMHO, it is to add an additional API for QSerialPort to allow to user to enable/disable this feature (with the Parity/Framing errors detection).. But this is a hard to implement in current time.. maybe in Qt 6 it will be added, because it is seldom used feature (1% of usage, IMHO).



  • You have been very clear, thank you very much:

    However, trying to do what you explained, I have failed to complete because,.. including termios.h in my class in order to call ::tcsetattr(ps->handle(), TCSANOW, &tio);
    then a lot of variables in my class (called B50, B200) match macro definitions in termios, i.e.
    #define B50 0000001
    so compiler tells me
    sas.h:140: error: expected unqualified-id before numeric constant bool B50;
    I think I need to wrap termios.h inside a namespace, but: I dont know if this is correct and if it is, how to do that.

    Thank you again


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.