我需要通过modbus发送自定义十六进制来自定义QModbusDataUnit
,在我的代码下面,我正在尝试自定义帖子,但我不明白该怎么做。
我应该发送以下值:0x01,0x08,0x00,0x00,0x00,0x00,0xE0,0x0B
void connessione::clickButton(){
QModbusDataUnit readUnit(QModbusDataUnit::HoldingRegisters, 1, QVector<quint16>({0x01,0x08,0x00,0x00,0x00,0x00,0xE0,0x0B}));
qDebug() << "readUnit" << clientX->state();
if (auto *reply = clientX->sendReadRequest(readUnit, 255)) // client id 255
{
if (!reply->isFinished())
{
// connect the finished signal of the request to your read slot
qDebug() << "connected" << reply->errorString();
connect(reply, &QModbusReply::finished, this, &connessione::readReady);
}
else
{
qDebug() << "Errore" << reply->errorString();
delete reply; // broadcast replies return immediately
}
}
else
{
qDebug() << "Errore" << reply->errorString();
// request error
}
}
但我的回答是:
D / libmodbusMobile.so(15006):( null):0((null)):qt.modbus:(TCP client)发送TCP PDU:0x0300080008,tId:0
哪里设置0x03? 这不对,它不等于我的QVector发送,如何解决?