Problem on Raspberry PI 2B serial port /dev/ttyAMA0 write timeout
-
Hello guys.
I have a problem taking the hair.
I do not know have gone for it, but what happens is that I made an application that works correctly in Windows , but when port this application in Qt 5.7.1 for Linux using a Raspberry PI 2B and its UART GPIO port.
It is called /dev/ttyAMA0
bool NetMaster485::open(const QString &port, qint32 baudRate) { serialPort.setBaudRate(baudRate); serialPort.setDataBits(QSerialPort::Data8); serialPort.setParity(QSerialPort::NoParity); serialPort.setStopBits(QSerialPort::OneStop); serialPort.setFlowControl(QSerialPort::NoFlowControl); serialPort.setPortName(port); return serialPort.open(QIODevice::ReadWrite); }
QByteArray tx; ... serialPort.write(tx); serialPort.flush(); if ( serialPort.waitForBytesWritten(timeoutTX) ) { return true; } return false; <<<
This aways emit error signal QSerialPort::SerialPortError(TimeoutError)
-
Solved removed flush();
After:
serialPort.flush(); if ( serialPort.waitForBytesWritten(timeoutTX) ) {
Before:
if ( serialPort.waitForBytesWritten(timeoutTX) ) {
-
Hi,
Out of curiosity, why are you not using the asynchronous mechanism ?
-
Hello friend , I am developing a RS485 communication protocol , and the communication would be the master layer. Ie it need to write on the bus and wait for the slave answer below , if not reply consider timeout . Ie is in a half duplex connection. This will be a free API compatible with Qt , Arduino , Microchip PIC .
Follow the project on this link: