Reputation: 387
Is there a way to send a byte to serial with QT. I only found a function for sending chars.
serialport->write(const QByteArray &data)
I want to send a array with these three bytes in Hex: 0xF0 0x02 0x0D
Upvotes: 1
Views: 4963
Reputation: 2832
You send 8-bit values. "Hexadecimal" is just a form of notation of integer values.
QByteArray ba;
ba.resize(3);
ba[0] = 0xF0;
ba[1] = 0x02;
ba[2] = 0x0D;
serialport->write(ba);
or:
char arr[3] = {0xF0, 0x02, 0x0D};
QByteArray ba(arr, 3);
serialport->write(ba);
Upvotes: 1
Reputation: 928
Do you have something like
serialport->write(QByteArray::fromHex("F0020D"));
in mind ?
Upvotes: 2