How can I write and read hex data when I open serial port?
if (serial->isOpen()) {
qDebug() << "seccus: " ;
static const char buff[] = {0xA1, 0xFF, 0xFF, 0x00,97};
serial->write(buff,sizeof(buff));
}
if (serial->bytesAvailable()) { // If there are bytes available
QByteArray f_data; // data container
f_data.clear();
if (serial->open(QIODevice::ReadWrite)) { // Try to open the port
while(serial->bytesAvailable()) { // Reading loop
f_data.append(serial->readAll());
}
serial->flush();
}
qDebug()<< "the result" << f_data; // Check the result
}
if(!serial->isOpen())
qDebug() << "carte disconnect"<<serial->errorString();
serial->open(QIODevice::ReadWrite)
go before the call toserial->write(buff,sizeof(buff));
? – Johnny Mopp0x
on the last element of the array. Is that on purpose? – Johnny Mopp