QSerialPort Custom BaudRate
-
I am trying to communicate with a Gyro of serial using QSerialPort. I need a baudrate of 375000bps. However, when I scope my output it always rounds the baudrate to the closest standard rate. How can i change this so i can see the data at the proper baudrate.
-
What platform do you use?
-
I am using ubuntu
-
I'd like to bump this thread, can't find an answer to this anywhere. I need to use 416000 Bd. Anyone got any ideas?
-
Currently QSerialPort allow to setup any custom BR which are suported by HW/driver. You can try to download latest sources from Git, build it and try.
-
It doesn't seem to work. I check the baud rate using myPort.baudRate() and the return value of setBaudeRate() and for 416000 it returns 9600 resp. false.
It does accept 400000 and 500000, but not numbers in between.
I've checked the setBaudRate function in qserialport.cpp, and it does not contain any check of valid values. It simply sets the BR. My only idea is that some other control function listens to the emitted signal and immediately sets it to default value again. ???
I can communicate over serial interface in 416000 Bd using a python script so it's not a hardware issue. -
bq. I check the baud rate using myPort.baudRate() and the return value of setBaudeRate() and for 416000 it returns 9600 resp. false.
What version of QSerialPort do you use?
This behavior can be occured in QSerialPort < 5.3, when you try to setup baud rate if a device is not open. You can get error code to see what happens.
-
I have Qt 5.3.1 installed and I set the baud rate after I've called open() function. I tried checking the error like this, just after I set the BR:
@QSerialPort::SerialPortError e1 = myPort.error();@But I don't get any error message. It just returns 0.
I do get the communication working through the port, but all data is just gibberish.
-
Here's an printout of all baud rates accepted by setBaudRate() between 0 and 600000 in steps of 100.
600000
576000
500000
480000
460800
400000
375000
320000
300000
250000
240000
230400
200000
192000
187500
160000
150000
125000
120000
115200
100000
96000
80000
75000
64000
62500
60000
57600
50000
48000
40000
38400
37500
32000
30000
25000
24000
20000
19200
16000
15000
12800
12500
12000
10000
9600
8000
7500
6400
6000
5000
4800
4000
3200
3000
2500
2400
2000
1800
1600
1500
1200
1000
800
600
500
400
300
200
100 -
Then you can try latest 5.3.3 sources of QtSerialPort (you should build it manually), there are added some patches to improve detection of custom divider and so on.
-
I can confirm that the latest sources for QtSerialPort work with custom baud rate. Thanks for the help.
-
i have Qt 5.5.1 (Clang 6.1 (Apple), 64 bit)
Built on Nov 25 2015 01:02:16.i try to use QserialPort to 62500.
i send QByteArray FF000000000000.
at 115200 work fine with terminal in windows. (FF0000000.. in terminal).But if i add SetBaudRate(62500) before open ,(work return true).
BUT don't work correctly in data.
i connect terminal windows at 62500(works, i have capture correct trame in protocol who work in 62500)
the data in terminal is different. C0 00 000...Can you help me? please.
my project may be abandoned why don't work.i use two same USB-RS232 converter we work in 62500 ( in windows)
USB CONVERTER(pc windows) ==> croissing wire ==> USB CONVERTER (in mac Qt)thank's
-
hi and welcome
Have you tried with other serial program on mac side to see
if qt or USB serial converter driver that is not working as expected with 62500
something like
http://www.macupdate.com/app/mac/31352/coolterm -
cool term not work in 62500, i have test with: stty -f /dev/usb.serial... 62500
invalid argument... (work with 9600)have you a term with we work with custom baud or a solution for testing the hardware?
thank's for your reply
-
@kickoune103
Ok. Im only on win and linux so mac is sort of unknown land to me.
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/stty.1.htmlhere they mention
ispeed number/ ospeed number
Set terminal input baud rate to the number given, if possible. If the input baud rate i
set to zero, the input baud rate is set to the value of the output baud rate.
I wonder if it will allow to set it this way ? -
i have solved this probleme to use qt6 beta.
with Qserialport 6.but problem: setbaudRate(62500) return true before openning port but the open() bug...
the solution: open with standard baud and setBaudRate.
i think it's works, i have 0xFF00....
i have not tested in QT5.5 to setBaudRate(62500) after open().
-
with Qserialport 6.
there are no qt6 beta and Qserialport 6!
but problem: setbaudRate(62500) return true before openning port but the open() bug...
On my side (with the PL2303 and with built in on-motherboard's 16550 chip) all fine, so, please give more info or try to lookup a problem on your side.
-
sorry i use QT 5.6
http://download.qt.io/development_releases/qt/5.6/5.6.0-beta/