修改下发解析
This commit is contained in:
parent
43d4d08059
commit
1ede325a3e
|
@ -393,9 +393,9 @@ void MainWindow::readCfgFile()
|
||||||
readCfgPoint += 1;
|
readCfgPoint += 1;
|
||||||
|
|
||||||
/* 数据长度 */
|
/* 数据长度 */
|
||||||
*readCfgPoint = 29 >> 8;
|
*readCfgPoint = 60 >> 8;
|
||||||
readCfgPoint += 1;
|
readCfgPoint += 1;
|
||||||
*readCfgPoint = 29;
|
*readCfgPoint = 60;
|
||||||
readCfgPoint += 1;
|
readCfgPoint += 1;
|
||||||
|
|
||||||
/* 数据内容 */
|
/* 数据内容 */
|
||||||
|
@ -544,9 +544,14 @@ void MainWindow::readCfgFile()
|
||||||
*readCfgPoint = (uint8_t)0x0119;
|
*readCfgPoint = (uint8_t)0x0119;
|
||||||
readCfgPoint += 1;
|
readCfgPoint += 1;
|
||||||
|
|
||||||
|
*readCfgPoint = (uint8_t)(0x011A >> 8);
|
||||||
|
readCfgPoint += 1;
|
||||||
|
*readCfgPoint = (uint8_t)0x011A;
|
||||||
|
readCfgPoint += 1;
|
||||||
|
|
||||||
/* crc校验 */
|
/* crc校验 */
|
||||||
uint16_t tempU16 = 0;
|
uint16_t tempU16 = 0;
|
||||||
tempU16 = modbusCrc(readCfgBuf, (29 * 2 + 12));
|
tempU16 = modbusCrc(readCfgBuf, (60 + 12));
|
||||||
*readCfgPoint = (uint8_t)(tempU16 >> 8);
|
*readCfgPoint = (uint8_t)(tempU16 >> 8);
|
||||||
readCfgPoint += 1;
|
readCfgPoint += 1;
|
||||||
*readCfgPoint = (uint8_t)tempU16;
|
*readCfgPoint = (uint8_t)tempU16;
|
||||||
|
@ -642,28 +647,41 @@ void MainWindow::readCfgFile()
|
||||||
// }
|
// }
|
||||||
// readCfgBuf[10]++;
|
// readCfgBuf[10]++;
|
||||||
|
|
||||||
ui->SerialPortPushButton->setEnabled(false);
|
ui->SerialPortPushButton->setDisabled(true);
|
||||||
ui->readConfigFile->setEnabled(false);
|
ui->readConfigFile->setDisabled(true);
|
||||||
ui->writeConfigFile->setEnabled(false);
|
ui->writeConfigFile->setDisabled(true);
|
||||||
|
|
||||||
serialPort->write(reinterpret_cast<const char*>(readCfgBuf), (29 * 2 + 12 + 3));
|
serialPort->write(reinterpret_cast<const char*>(readCfgBuf), (60 + 12 + 3));
|
||||||
|
|
||||||
// /* 延时1.5S */
|
/* 延时1.5S */
|
||||||
// QThread::msleep(1500);
|
QThread::msleep(1500);
|
||||||
// QByteArray data = serialPort->readAll();
|
QByteArray data = serialPort->readAll();
|
||||||
|
|
||||||
// /* 起始标志 */
|
// if (data.length() < 17) {
|
||||||
|
// goto error;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/* 起始标志 */
|
||||||
|
uint8_t *repData = (uint8_t *)data.data();
|
||||||
|
if (*repData != 'S' || *(repData + 1) != 'L') {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
// /* 地址 */
|
||||||
// if (data.at(0) != 'S' || data.at(1) != 'L') {
|
// if (data.at(0) != 'S' || data.at(1) != 'L') {
|
||||||
// goto error;
|
// goto error;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if (data.at(0) != 'S' || data.at(1) != 'L') {
|
if (*(repData + 9) != 0xD0) {
|
||||||
// goto error;
|
goto error;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
// uint16_t crc16 = modbusCrc(repData, 14);
|
||||||
|
|
||||||
|
|
||||||
|
// return;
|
||||||
|
|
||||||
//error:
|
error:
|
||||||
ui->SerialPortPushButton->setEnabled(true);
|
ui->SerialPortPushButton->setEnabled(true);
|
||||||
ui->readConfigFile->setEnabled(true);
|
ui->readConfigFile->setEnabled(true);
|
||||||
ui->writeConfigFile->setEnabled(true);
|
ui->writeConfigFile->setEnabled(true);
|
||||||
|
|
Loading…
Reference in New Issue