Serialport: Check parity problem
-
Hello,
I installed qtSerialport (Qt 4.8) in a pc with Ubuntu 12.04 a few days ago.
I can send and receive commands through a serialport, but I cannot check the parity of the received data.Here is my code. Should I check some flag o something else?
@
bool configurarPuerto(QString *msg){this->serialPort->close(); this->serialPort->setPort("ttyS3"); *msg="Configuracion del puerto serie: "; if (!this->serialPort->open(QIODevice::ReadWrite)) { *msg+="Error abriendo el dispositivo"; return false; } /* I choose the configuration policy - SkipPolicy: Ignora los comandos invalidos - PassZeroPolicy: Lee 0 - IgnorePolicy: Ignora el bit de paridad - StopReceivingPolicy: Deja de recibir datos */ if (!this->serialPort->setDataErrorPolicy(SerialPort::StopReceivingPolicy)){ qDebug()<<"Configuration error"; } if (!this->serialPort->setParity(SerialPort::EvenParity)) { *msg+="Error seteando paridad par"; return false; } return true;
}
@
-
nicorepetti,
The fact that the on *.nix you can identify the parity error only in the process of reading.
Therefore, to solve this problem, try while receiving readyRead() call QtSerialPort::error(). This method should return the last error, if it occurred. In your case it will QtSerialPort::ParityError.
I would also note that the idea of the politicy processing, parity errors catch and etc. has not been fully thought out and implemented.
So try until this workaround, maybe it is help for you.
-
Thanks for helping me,
I just test the error function, but doesnt work (always returns 0 [no error]) -
We made some commits to library.
Now, please try connect to signal errorChanged(QtSerialPort::PortError).
In principle, this should help in the event that if we have implemented correctly for catching parity error. But can not work, because no one has tested implementation. :)
Please update library and check now.