Does Qt serial port supports the QbitArray . I need to transmit the data in bit form. how am i suppose to send .
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.
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 Good point ! That's indeed something to take into account when reading the data on the other side of the connection.