From 174e22ea79b437e981fc3cab549d3855c5e108d2 Mon Sep 17 00:00:00 2001 From: luocai Date: Wed, 19 Jun 2024 16:02:58 +0800 Subject: [PATCH] add request image. --- Analyser/Application.cpp | 9 ++++++++- Analyser/Application.h | 1 + Analyser/ModuleCommunication.cpp | 6 +----- Analyser/ModuleCommunication.h | 4 +--- Analyser/qml/OperationItem.qml | 13 +++++++++++++ Readme.md | 2 ++ 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Analyser/Application.cpp b/Analyser/Application.cpp index 5b9e1ce..634fe91 100644 --- a/Analyser/Application.cpp +++ b/Analyser/Application.cpp @@ -154,7 +154,7 @@ void Application::enroll(const QString &username, uint8_t timeout) { if (m_communication->currentMessageId() != ModuleCommunication::Idle) { m_communication->reset(); } - m_communication->enroll(username, timeout); + m_communication->enroll(username.toStdString(), timeout); } void Application::deleteUser(uint16_t userid) { @@ -171,6 +171,13 @@ void Application::deleteAll() { m_communication->deleteAll(); } +void Application::getEnrolledImage(const QString &username, uint8_t timeout) { + if (m_communication->currentMessageId() != ModuleCommunication::Idle) { + m_communication->reset(); + } + m_communication->enrollEx(username.toStdString(), timeout); +} + ModuleCommunication *Application::module() const { return m_communication.get(); } diff --git a/Analyser/Application.h b/Analyser/Application.h index 6cf76c6..c197148 100644 --- a/Analyser/Application.h +++ b/Analyser/Application.h @@ -46,6 +46,7 @@ public: Q_INVOKABLE void enroll(const QString &username, uint8_t timeout); Q_INVOKABLE void deleteUser(uint16_t userid); Q_INVOKABLE void deleteAll(); + Q_INVOKABLE void getEnrolledImage(const QString &username, uint8_t timeout); ModuleCommunication *module() const; bool connected() const; bool uvcOpened() const; diff --git a/Analyser/ModuleCommunication.cpp b/Analyser/ModuleCommunication.cpp index f66d047..d78cd76 100644 --- a/Analyser/ModuleCommunication.cpp +++ b/Analyser/ModuleCommunication.cpp @@ -67,10 +67,6 @@ void ModuleCommunication::enroll(const std::string &username, uint8_t timeout) { LOG_CAT(info, GUI) << Separator; } -void ModuleCommunication::enroll(const QString &username, uint8_t timeout) { - return enroll(username.toStdString(), timeout); -} - void ModuleCommunication::enrollEx(const std::string &username, uint8_t timeout) { EnrollData data = {0}; data.timeout = timeout; @@ -78,7 +74,7 @@ void ModuleCommunication::enrollEx(const std::string &username, uint8_t timeout) auto [frameData, frameSize] = generateFrame(EnrollGetImage, reinterpret_cast(&data), sizeof(data)); m_serialPort->write(reinterpret_cast(frameData), frameSize); - LOG_CAT(info, GUI) << "发送注册指令: " << protocolDataFormatString(frameData, frameSize); + LOG_CAT(info, GUI) << "发送获取注册照片指令: " << protocolDataFormatString(frameData, frameSize); LOG_CAT(info, GUI) << "用户名: " << username << ", 超时时间: " << static_cast(timeout) << "s"; LOG_CAT(info, GUI) << Separator; } diff --git a/Analyser/ModuleCommunication.h b/Analyser/ModuleCommunication.h index 6a268bf..048fa04 100644 --- a/Analyser/ModuleCommunication.h +++ b/Analyser/ModuleCommunication.h @@ -83,6 +83,7 @@ public: }; struct EnrolledImageReply { + uint8_t image_format; // 0: 只有Y分量,灰度图 uint16_t width; uint16_t height; uint8_t md5[16]; @@ -120,8 +121,6 @@ public: Q_INVOKABLE void reset(); void enroll(const std::string &username, uint8_t timeout); - Q_INVOKABLE void enroll(const QString &username, uint8_t timeout); - void enrollEx(const std::string &username, uint8_t timeout); Q_INVOKABLE void deleteUser(uint16_t userid); Q_INVOKABLE void deleteAll(); @@ -147,7 +146,6 @@ protected: void onErrorOccurred(QSerialPort::SerialPortError error); std::pair generateFrame(MessageId command, const uint8_t *data = nullptr, uint16_t size = 0); std::string protocolDataFormatString(const uint8_t *data, int size); - private: std::shared_ptr m_serialPort; QByteArray m_receivedBuffer; diff --git a/Analyser/qml/OperationItem.qml b/Analyser/qml/OperationItem.qml index 9fe731a..04b7533 100644 --- a/Analyser/qml/OperationItem.qml +++ b/Analyser/qml/OperationItem.qml @@ -101,6 +101,19 @@ ColumnLayout { } } } + GroupBox { + title: "图片注册" + GridLayout { + columns: 1 + Button { + text: "录入图片上报" + onClicked: App.getEnrolledImage("",60) + } + Button { + text: "图片下发注册" + } + } + } Button { text: "复位" onClicked: App.module.reset() diff --git a/Readme.md b/Readme.md index 08e1d4d..e37a750 100644 --- a/Readme.md +++ b/Readme.md @@ -59,5 +59,7 @@ HOST_TOOLS := /opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin ./rebuild-app.sh y L015 V200 R002 # 编译烧录固件 ./rebuild-app-ota.sh y L015 V200 R002 11 # 编译OTA固件,11为OTA版本号 600X800 + +./rebuild-app.sh n L021 V901 R001 # 测试新分支的CDC ```