序列化:
QByteArray buffer;
QBuffer bufferDevice(&buffer);
bufferDevice.open(QIODevice::WriteOnly);
QDataStream out(&bufferDevice);
out.setVersion(QDataStream::Qt_5_13);
反序列化:
void deserialize(const QByteArray &buffer) {
QBuffer bufferDevice(const_cast<QByteArray*>(&buffer));
bufferDevice.open(QIODevice::ReadOnly);
QDataStream in(&bufferDevice);
in.setVersion(QDataStream::Qt_5_13);
in >>frameHeader >> packetSeq >> dataLength >> batteryLevel >> channelCount
>> pitchAngle >> rollAngle >> yawAngle >> ecg >> spo2
>> reserved1 >> reserved2 >> reserved3 >> reserved4;
dataBlock.resize(dataLength);
in.readRawData(dataBlock.data(), dataLength);