diff --git a/DeviceHub/device/DeviceBase.cpp b/DeviceHub/device/DeviceBase.cpp index 65c4dce..3e697b4 100644 --- a/DeviceHub/device/DeviceBase.cpp +++ b/DeviceHub/device/DeviceBase.cpp @@ -80,6 +80,10 @@ void DeviceBase::initSerialPort() { int master = SettingConfig::getInstance().MASTER; + if (this->comName.isEmpty()) { + return ; + } + QStringList comNameList = this->comName.split(","); if (comNameList.isEmpty() == true) { diff --git a/DeviceHub/device/DeviceBase.cpp b/DeviceHub/device/DeviceBase.cpp index 65c4dce..3e697b4 100644 --- a/DeviceHub/device/DeviceBase.cpp +++ b/DeviceHub/device/DeviceBase.cpp @@ -80,6 +80,10 @@ void DeviceBase::initSerialPort() { int master = SettingConfig::getInstance().MASTER; + if (this->comName.isEmpty()) { + return ; + } + QStringList comNameList = this->comName.split(","); if (comNameList.isEmpty() == true) { diff --git a/DeviceHub/protocol/TimeReplicatorProtocolBM.cpp b/DeviceHub/protocol/TimeReplicatorProtocolBM.cpp index 598bb3f..fb44606 100644 --- a/DeviceHub/protocol/TimeReplicatorProtocolBM.cpp +++ b/DeviceHub/protocol/TimeReplicatorProtocolBM.cpp @@ -21,19 +21,25 @@ QString outStr = ""; ((TimeReplicatorStatusDto *) frameData)->devStatus = content.at(0); - if (length < 0x30) - { + if (length == 0x2B) { + // 2*8 count = 2; inputByte = content.mid(2, 1).toInt(); outStr = content.mid(3, 8 * count); - } else - { + } else if (length == 0x2C) { + // 4*4 + count = 4; + inputByte = content.mid(2, 2).toInt(); + outStr = content.mid(4, 4 * count); + } else { + // 4*8 count = 4; inputByte = content.mid(2, 2).toInt(); outStr = content.mid(4, 8 * count); } ((TimeReplicatorStatusDto *) frameData)->inCount = count; + int outCount = outStr.length() / count; for (int i = 0; i < count; i++) { qint8 in = inputByte % 2; @@ -41,9 +47,9 @@ inputByte = inputByte / 2; QString output = ""; - for (int j = 0; j < 8; j++) + for (int j = 0; j < outCount; j++) { - output += outStr.at(i * 8 + j); + output += outStr.at(i * outCount + j); output += ","; } ((TimeReplicatorStatusDto *) frameData)->outValid.append(output.mid(0, output.size() - 1));