#pragma pack(1)
typedef struct DataFrameStruct
{
uint8_t version;
uint8_t type;
uint8_t code;
uint16_t id;
uint16_t reserve;
}DataFrame;
#pragma pack()
void MainWindow::on_pushButton_19_clicked()
{
uint8_t dataBuf[7] = {0};
DataFrame dataFrame;
int version = 1;
uint16_t id = 0xaa55;
uint8_t type = 2;
uint8_t code = 3;
uint8_t qos = 4;
uint8_t data = 5;
dataFrame.id = id;
dataFrame.type = type;
dataFrame.code = code;
dataFrame.reserve = (qos<<8 & 0xff00) + (data & 0x00ff);
dataFrame.version = version;
memcpy(dataBuf, &dataFrame, sizeof (dataFrame));
for(int i=0; i<7; i++)
{
qDebug() << "data:" << dataBuf[i];
}
qDebug() << "end";
}