Hi,
I'm working on a Qt5.7 application cross-compiled for my device. I added the serialport module to read and write to the serialport.
After opening the QSerialPort, when I try to write to it, the following error message (attached to the thread) appears in the GUI: "Permission error while locking the device", and the message is not sent to the serial port.
This is the way I open and try to write to the serial port:
serialport->setPortName("/dev/ttymxc2");
serialport->setBaudRate(QSerialPort::Baud9600);
serialport->setDataBits(QSerialPort::Data8);
serialport->setParity(QSerialPort::NoParity);
serialport->setStopBits(QSerialPort::OneStop);
serialport->setFlowControl(QSerialPort::NoFlowControl);
//serial->setFlowControl(QSerialPort::HardwareControl);
//opened
serialport->setPortName("/dev/ttymxc2");
serialport->setBaudRate(QSerialPort::Baud9600);
serialport->setDataBits(QSerialPort::Data8);
serialport->setParity(QSerialPort::NoParity);
serialport->setStopBits(QSerialPort::OneStop);
serialport->setFlowControl(QSerialPort::NoFlowControl);
//serial->setFlowControl(QSerialPort::HardwareControl);
if (serialport->open(QIODevice::ReadWrite))
//opened
To copy to clipboard, switch view to plain text mode
...
The write section:
ba.resize(50);
...
const qint64 bytesWritten = serialport->write(ba);
QByteArray ba;
ba.resize(50);
...
const qint64 bytesWritten = serialport->write(ba);
To copy to clipboard, switch view to plain text mode
Could anyone help to find the solution? What am I missing?
Thank you!
Bookmarks