Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Does Qt serial port supports the QbitArray . I need to transmit the data in bit form. how am i suppose to send .
AnilReddy last edited by
Does Qt serial port supports the QbitArray . I need to transmit the data in bit form. how am i suppose to transit the 8-bit data to control robotic arm.
A Former User last edited by A Former User
how am i suppose to transit the 8-bit data
If you need to write only a single byte:
const char c = 0x23; port.write(&c, 1);
const QByteArray ba("Hello"); port.write(ba);
Bit manipulation is provided by the language:
c |= (1<<4); // set bit #4 c &= ~(1<<2); // clear bit #2
No QSerialPort doesn't support that. However it's not complicated to send a QBitArray. Something like:
QBuffer buffer; buffer.open(QIODevice::WriteOnly); QDataStream stream(&buffer); stream << bitArray; serialPort.write(buffer.buffer());
should do the job.
ChrisW67 last edited by
@ChrisW67 Good point ! That's indeed something to take into account when reading the data on the other side of the connection.