Hello,
I'm using the QextSerial to receive ascii lines from a serial connection. Even if the documentation seems to be broken (a lot of file are not found) I'm able to set and open the serial port and to receive some data.
What I can't do is generate en event when a new line is ready to read.
I set the serial port like this:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
serial = new QextSerialPort();
serial->setBaudRate(BAUD9600);
serial->setParity(PAR_NONE);
serial->setDataBits(DATA_8);
serial->setStopBits(STOP_1);
serial->setFlowControl(FLOW_OFF);
serial->setQueryMode(QextSerialPort::EventDriven);
serial->setPortName(cboSerial->currentText());
if (!serial->open(QIODevice::ReadOnly)) {
QMessageBox msgBox;
msgBox.setText("Warning: COM port is unavailable.");
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
}
connect(serial, SIGNAL(readyRead()), this, SLOT(Receive()));
|
The Receive slot should handle incoming data:
|
Source code
|
1
2
3
|
char data[64];
int bytesRead = serial->readLine(data, 64);
txtRx->setText(data);
|
But I get corrupted lines, that is it doesn't read whole lines. I guess because the readyRead signal is emitted when some data is available and the readLine return just what is into the buffer, but it doesn't wait for the newline.
I tried to check the canReadLines (not documented) but with no effect.
What should I do to make the trick?
Thanks
Marco Trapanese
italy