Unsolved QSerialPort problem for sending data
-
Hello,
I have a problem for sending data through serial port, my code is working well except if I add a sleep() after sending the data. bytesWritten() return 1 but the byte is not sent (I check with my scope).
Here is my code :connect(m_port, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWritten(qint64))); while(1) { char startByte = 0x7f; m_port->putChar(startByte); m_port->waitForBytesWritten(-1); sleep(1); /* code is working if I comment this line */ }
What I am doing wrong ?
Thanks for your help. -
Hi,
You have a infinite loop that is blocking Qt's event loop thus Qt can't process anything.
If you want to use your serial port in an infinite loop, you have to move that code in it's own thread.
-
Hi,
Thank you for your answer.
That code is already in a thread.
Maybe it's hardware problem with my board because I just realized that this code is working with 9600baud and not with 115200 ... -
Are you configuring the serial port correctly ?
Does your device have any limitation ?