if (serialPort.open(QIODevice::ReadWrite))
{
qDebug() << "串口打开成功";
}
else
{
qDebug() << "串口打开失败";
return;
}
}
void sendCommand(const QByteArray &command)
{
if (serialPort.isOpen())
{
serialPort.write(command);
}
}
private slots:
void receiveResponse()
{
while (serialPort.canReadLine())
{
QByteArray response = serialPort.readAll();
qDebug() << "收到响应:" << response;