QSerialPort and sending bytes (with value > 127?)
I have to communicate with cash-register.
If i send data without polish diacritic chars - it works, but i have to use CP852 encoding (chars (int) value > 127 ie 0xb1 then it does not work.
(i become from cash-register's service an example what to send and i send exacly this same)
QString hex = "0234301c4c49541d4741546f77617220a5a91e42411e43311 e44332c30301e45332c30301e47737a74756b613742413303" ;
QByteArray test = QByteArray::fromHex(hex.toLatin1());
serial = new QSerialPort(this);
serial->setPortName("ttyACM0");
serial->setBaudRate(QSerialPort::Baud9600);
serial->setDataBits(QSerialPort::Data8);
serial->setParity(QSerialPort::NoParity);
serial->setStopBits(QSerialPort::OneStop);
serial->setFlowControl(QSerialPort::NoFlowControl);
if(serial->open(QIODevice::ReadWrite))
{
qDebug()<<"Port is open!";
if(serial->isWritable())
{
qDebug()<<"Yes, i can write to port!";
}
serial->waitForBytesWritten(-1);
serial->write(test.data());
serial->flush(); // Port Error 12 (timed out???)
serial->close()
}
Re: QSerialPort and sending bytes (with value > 127?)
What does it mean "does not work" ?
Re: QSerialPort and sending bytes (with value > 127?)
Quote:
Originally Posted by
Lesiok
What does it mean "does not work" ?
if i send data without (hex 0xA5, 0xA9) i become proper cash-register answer...in other case - i become nothing
how to send unsigned char (values 0-255)?
Re: QSerialPort and sending bytes (with value > 127?)
Are you sure thar the sequence is correct (in accordance with the printer protocol) ? QSerial is only a pipe - does not analyze transmitted data.
1 Attachment(s)
Re: QSerialPort and sending bytes (with value > 127?)
i am sure i send correctly and exactly that what give me cash-register service (i have succesed send my own data (with proper response) but only if they don't have chars with (int) > 127)
i thing something is wrong with sending this data (Debian 8.0/64bits)
1. chars, witch make problem
2. check sum - correcty calculatedAttachment 11469
Re: QSerialPort and sending bytes (with value > 127?)
Maybe some problem similar to this ? Can You make test on another platform ?
Re: QSerialPort and sending bytes (with value > 127?)
yes, but only on 32 bit platform