Does Qt serial port supports the QbitArray . I need to transmit the data in bit form. how am i suppose to send .
Unsolved
General and Desktop
-
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.
@AnilReddy said:
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);
Otherwise:
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
-
Hi,
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.
-
Hi,
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.