add status query command.
This commit is contained in:
parent
bd97f3a380
commit
809bca3e91
@ -169,6 +169,13 @@ void ModuleCommunication::uploadImageData(uint32_t offset, const uint8_t *data,
|
|||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModuleCommunication::requestCurrentStatus() {
|
||||||
|
auto [frameData, frameSize] = generateFrame(GetCurrentStatus);
|
||||||
|
m_serialPort->write(reinterpret_cast<const char *>(frameData), frameSize);
|
||||||
|
LOG_CAT(info, GUI) << "发送状态指令: " << protocolDataFormatString(frameData, frameSize);
|
||||||
|
LOG_CAT(info, GUI) << Separator;
|
||||||
|
}
|
||||||
|
|
||||||
ModuleCommunication::MessageId ModuleCommunication::currentMessageId() const {
|
ModuleCommunication::MessageId ModuleCommunication::currentMessageId() const {
|
||||||
return m_currentMessageId;
|
return m_currentMessageId;
|
||||||
}
|
}
|
||||||
@ -294,6 +301,12 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
|
|||||||
case UploadImageData: {
|
case UploadImageData: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GetCurrentStatus: {
|
||||||
|
LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size);
|
||||||
|
LOG_CAT(info, GUI) << "模组当前状态: " << static_cast<int>(data[7]);
|
||||||
|
LOG_CAT(info, GUI) << Separator;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
LOG(warning) << "unknown reply command: 0x" << (static_cast<int>(replyId) & 0xff)
|
LOG(warning) << "unknown reply command: 0x" << (static_cast<int>(replyId) & 0xff)
|
||||||
<< ", data: " << protocolDataFormatString(data, size);
|
<< ", data: " << protocolDataFormatString(data, size);
|
||||||
|
@ -20,6 +20,7 @@ public:
|
|||||||
Reply = 0,
|
Reply = 0,
|
||||||
Note = 0x01,
|
Note = 0x01,
|
||||||
Reset = 0x10,
|
Reset = 0x10,
|
||||||
|
GetCurrentStatus = 0x11,
|
||||||
Verify = 0x12,
|
Verify = 0x12,
|
||||||
EnrollSingle = 0x1D,
|
EnrollSingle = 0x1D,
|
||||||
EnrollGetImage = 0x1E,
|
EnrollGetImage = 0x1E,
|
||||||
@ -154,6 +155,7 @@ public:
|
|||||||
|
|
||||||
void uploadImageInfo(const UploadImageInformation &info);
|
void uploadImageInfo(const UploadImageInformation &info);
|
||||||
void uploadImageData(uint32_t offset, const uint8_t *data, uint32_t size);
|
void uploadImageData(uint32_t offset, const uint8_t *data, uint32_t size);
|
||||||
|
Q_INVOKABLE void requestCurrentStatus();
|
||||||
|
|
||||||
MessageId currentMessageId() const;
|
MessageId currentMessageId() const;
|
||||||
static std::string protocolDataFormatString(const uint8_t *data, int size);
|
static std::string protocolDataFormatString(const uint8_t *data, int size);
|
||||||
|
@ -122,6 +122,10 @@ ColumnLayout {
|
|||||||
text: "复位"
|
text: "复位"
|
||||||
onClicked: App.module.reset()
|
onClicked: App.module.reset()
|
||||||
}
|
}
|
||||||
|
Button {
|
||||||
|
text: "状态查询"
|
||||||
|
onClicked: App.module.requestCurrentStatus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user