Qt Serial Port Baud Rate

Qt Serial Port Baud Rate Average ratng: 3,5/5 2376 votes

I faced a strange problem using serial port. I can't write on serial port by a thread loop!! However I can write on it by thread constructor! I can read from serial port in thread but I can't write on it.

I don't know where is the problem but by my personal experience in using QSerialPort I think Serial port in Qt have some issues with thread! Because it's not my firs problem with QSerialPort and QThread together. Maybe I'm wrong but I wrote this code before with c# and this sort of things are not issue there!

Apr 10, 2017 - Serial(port, baudrate=baudrate, timeout=0) # 0 for. This is the function that will be called from the Qt library to update the active window. I am trying to rig up some basic serial communications in QT I am getting the port COM19 from QSerialPortInfo, and I speaking successfully to the port via Arduino. However, I cannot get anything back via QT. This is not his fault. CanReadWrite() as true only QT Serial Port will work. If QTSerialPort is working fine, then CanReadWrite() will return value as true. Ie the proof. So why it is returned as false? Whether he again claims that His serial port baud rate or his on off of device, or no data had come?

Thanks in advices. Creating your serial port instance in the constructor of the QThread subclass means it's created in the thread calling the constructor (in your case probably the main thread). The run method is running in the thread managed by QThread which means that you are using a serial port which has affinity with a different thread than the one that runs 'run'.

The moveToThread function moves a QObject from the thread that created the object to the thread that is handled by QThread. 's documentation shows the worker object approach. In your case create an object that will contain your QSerialPort (don't forget to set it as the parent of the QSerialPort) and that will handle the communication/processing you need for your application. Thank you dear SGaist for your answers. I did this as you said but it seems it not the problem. Maybe I'm doing this wrong.

Qt Serial Port Baud Rate

Serial Baud Rates

Working with serial port in qt became a huge trouble for me! I can't figure out how to do this correctly! I need to read from arduino and write missions on it but in both sides I stocked! In reading I have run time errors after 2 or 3 hours and I had no success on writing! Someone told me to not use thread and use Qt examples but managing serial port in this baud rate is a blocking operation and I have to use thread! And no matter how many times I try it's not working as it expected!! I'm saying again maybe I'm doing it all wrong but I can't find an example for this!:(.

Yes I used QThread and QSerialPort wrong together but it's not mean that I don't know what I'm doing! I'm newbie in qt and still have trouble to use some of qt libraries. But you are right. Using thread was wrong at the first place! I didn't need it. Thanks to SGaist I realize it now! I tried without thread before and it has delay.

Today I figured out using readyRead signal is not my solution! I used QTimer and 10 milliseconds for connecting to parser function(slot) and it's solved my problem for good. Thank you for your response.:).

Posted :