I'm attempting to set a custom baud rate of 10400 to my device on Linux using Qt. However, when I run the application, the console output keeps reporting that
Baud rate of serial port /dev/ttyUSB0 is set to 10403 instead of 10400: divisor 2307.692383 unsupported
I've also set the data bits to 8, parity to no parity, and stop bits to 1, which are pretty standard.
Here's my code by the way:
serial -> setBaudRate(10400); // Set Baud Rate
serial -> setDataBits(QSerialPort::Data8);
serial -> setStopBits(QSerialPort::OneStop);
serial -> setParity(QSerialPort::NoParity);
When I run the application on Windows however, it works totally fine.
My device isn't able to connect with any other baud rate other than 10400. The application is able to compile and run, however the result is all garbage. I want to know if there's a way where I can specify this baud rate without any problems?
答案 0 :(得分:0)
That's a warning; it means you should fix the code, but the code still happens to work. What you're trying to do is not supported by the hardware you run on. Windows is only quieter about this, it doesn't support it either.
答案 1 :(得分:0)
Relevant bug report here. Basically it means, that the exact baud rate is not available, because the actual thing configured to hardware is an integer divisor of some clock frequency, and there is no exact integer divisor for the requested baud rate. The warning message is pretty descriptive about this.
It shouldn't matter, baud rates have some tolerance, but if it does cause problems (discussion under bug suggests it may...), upgrading to Qt 5.6 is suggested in the bug report.