add status query command.

This commit is contained in:
luocai 2024-06-21 15:11:18 +08:00
parent bd97f3a380
commit 809bca3e91
3 changed files with 19 additions and 0 deletions

View File

@ -169,6 +169,13 @@ void ModuleCommunication::uploadImageData(uint32_t offset, const uint8_t *data,
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 {
return m_currentMessageId;
}
@ -294,6 +301,12 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) {
case UploadImageData: {
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:
LOG(warning) << "unknown reply command: 0x" << (static_cast<int>(replyId) & 0xff)
<< ", data: " << protocolDataFormatString(data, size);

View File

@ -20,6 +20,7 @@ public:
Reply = 0,
Note = 0x01,
Reset = 0x10,
GetCurrentStatus = 0x11,
Verify = 0x12,
EnrollSingle = 0x1D,
EnrollGetImage = 0x1E,
@ -154,6 +155,7 @@ public:
void uploadImageInfo(const UploadImageInformation &info);
void uploadImageData(uint32_t offset, const uint8_t *data, uint32_t size);
Q_INVOKABLE void requestCurrentStatus();
MessageId currentMessageId() const;
static std::string protocolDataFormatString(const uint8_t *data, int size);

View File

@ -122,6 +122,10 @@ ColumnLayout {
text: "复位"
onClicked: App.module.reset()
}
Button {
text: "状态查询"
onClicked: App.module.requestCurrentStatus()
}
}
}
}