Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.10, 6.5.1
-
None
-
Arch linux x64, Qt 5.15.10 (Arch linux packages)
-
-
5
-
430a7464c (dev), 10a4b2acd (6.6), 42461955c (tqtc/lts-6.5), 72bbf89c7 (tqtc/lts-6.2)
-
Foundation Sprint 90, Foundation Sprint 91, Foundation Sprint 92, Foundation Sprint 93
Description
It appears that when a serial port is opened, the baud rate is set but it is not set at the correct moment. Assuming that you have a device with a baud rate of 115200, this baud rate is set so you can communicate with the device, e.g. using the code
QSerialPort gspSerialPort; gspSerialPort.setBaudRate(115200); gspSerialPort.open(QIODevice::ReadWrite);
But unlike other programs, such as minicom, this is either not set persistently or using the same way the e.g. stty does it because upon opening, you receive a bunch of garbage data because the serial port is being opened at the wrong baud rate, so you receive garbage like:
"\x87\xC9\x96\xD9\xB6\xD9\x87\xC9\x87\xD9\x96\xD9\x96\xC9\xB6\xD9\x96\xC9\xC7\xC9\x97\xD9\xB6\xD9\xB6\xC9\x96\xD9\x87\xC9\xEF\x87\xC9
\x87\xC9\x96\xC9\xC7\xC9\x87\xC9\xC7\xC9\x16\xFA\x96\xD9\x87\xC9\x87\xC9\x87\xD9\xEF\x87\xC9\xC7\xC9\x87\xC9\x87\xD9\xEF\xFF\xFF\x16\
xFA\x96\xC9\x96\xD9\x96\xC9\xC7\xC9\x96\xD9\xB6\xD9\x97\xD9\xC7\xC9\x96\xC9\xC7\xC9\x96\xD9\xC7\xC9\xFF\xEF\xC7\xC9\x96\xC9\xEF\xFF\x
F7\xC7\xC9\x86\xD9\xC7\xC9\x87\xC9\xC7\xC9\x87\xD9\x87\xD9\xC7\xC9\x96\xD9\x97\xD9\xC7\xD9\x97\xD9\xB6\xD9\x96\xD9"
"Hello wo"
"rld fr"
So whilst it does change to 115200, it does not start at 115200. This can be confirmed by checking with stty:
stty -F /dev/ttyACM0 speed 9600 baud; line = 0; -brkint -imaxbel
If this is manually used to set the baud rate to 115200 with stty, then opening the port with Qt no longer gives a bunch of garbage at the start before giving correct output but fully gives the correct text. For comparison, the output with stty after having used minicom with a baud rate of 115200:
stty -F /dev/ttyACM0 speed 115200 baud; line = 0; min = 1; time = 5; ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke