16,202
社区成员
发帖
与我相关
我的任务
分享
void MyClass::openSerial()
{
serial = new QSerialPort("COM1");
serial->setBandrate(QSerialPort::Baud9600);
...
connect(serial, SIGNAL(dataReady()), this, SLOTS(receiveData()));
}
void MyClass::receiveData()
{
QByteArray data = serial->read(1);
switch(data.at(0) & 0xff)
{
// 判断包头、包数据和包尾
}
}