From e588d4abdf0e7f9246d67bd5fd324acac1c4bcfc Mon Sep 17 00:00:00 2001 From: luocai Date: Mon, 1 Jul 2024 15:07:13 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E8=AF=86=E5=88=AB=E8=80=97?= =?UTF-8?q?=E6=97=B6=E7=BB=9F=E8=AE=A1=E6=98=BE=E7=A4=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Analyser/Application.cpp | 17 +++-------------- Analyser/Application.h | 4 +--- Analyser/ModuleCommunication.cpp | 23 +++++++++++++++++------ Analyser/ModuleCommunication.h | 13 ++++++++++--- Readme.md | 4 +--- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/Analyser/Application.cpp b/Analyser/Application.cpp index 760091e..a19c284 100644 --- a/Analyser/Application.cpp +++ b/Analyser/Application.cpp @@ -41,11 +41,11 @@ Application::Application(int &argc, char **argv) : m_app(std::make_shared &data) { void Application::onCommandStarted(ModuleCommunication::MessageId messageId) { using namespace std::chrono; - if (messageId == ModuleCommunication::Verify) { - m_verifyStartTime = system_clock::now(); - } emit isVerifyingChanged(); } @@ -306,14 +303,6 @@ void Application::onCommandFinished(ModuleCommunication::MessageId messageId, ModuleCommunication::MessageStatus status) { // LOG(info) << m_persistenceMode << " " << m_persistenceModeStarted << " " << m_persistenceVerifyInterval; using namespace std::chrono; - if (messageId == ModuleCommunication::Verify) { - m_verifyElapsed = duration_cast(system_clock::now() - m_verifyStartTime); - LOG(info) << "verify elapsed " << m_verifyElapsed; - if (m_verifyElapsed > hours(10 * 1000)) { - m_verifyElapsed = milliseconds(100); - } - } - if (messageId == ModuleCommunication::UploadImageInfo) { m_communication->uploadImageData( m_uploadImageSendedSize, (const uint8_t *)m_uploadBuffer.data() + m_uploadImageSendedSize, ImageSliceSize); diff --git a/Analyser/Application.h b/Analyser/Application.h index 6ceb084..a237e66 100644 --- a/Analyser/Application.h +++ b/Analyser/Application.h @@ -70,7 +70,7 @@ signals: protected: Application(int &argc, char **argv); - void onNewVerifyResult(uint16_t userid, const QString &username); + void onNewVerifyResult(uint16_t userid, const QString &username, uint16_t elapsed); void onNewPalmFeature(const PalmFeature &feature); void onErrorOccurred(const QString &error); void onNewEnrolledImageInfo(uint32_t size, const uint8_t *md5); @@ -88,8 +88,6 @@ private: bool m_persistenceModeStarted = false; int m_persistenceVerifyInterval = 1; QTimer *m_verifyTimer = nullptr; - std::chrono::system_clock::time_point m_verifyStartTime; - std::chrono::milliseconds m_verifyElapsed; uint32_t m_enrolledImageSize = 0; QByteArray m_enrollYImageBuffer; diff --git a/Analyser/ModuleCommunication.cpp b/Analyser/ModuleCommunication.cpp index f94b51e..4e29de1 100644 --- a/Analyser/ModuleCommunication.cpp +++ b/Analyser/ModuleCommunication.cpp @@ -200,19 +200,25 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) { if (result == Success) { auto info = reinterpret_cast(data + 7); uint16_t userid = ntohs(info->userid); + uint16_t elapsed = ntohs(info->elapsed); LOG_CAT(info, GUI) << "用户ID: " << userid - << ", 用户名: " << std::string_view(reinterpret_cast(info->username)); - emit newVerifyResult(userid, reinterpret_cast(info->username)); + << ", 用户名: " << std::string_view(reinterpret_cast(info->username)) + << ", 耗时: " << elapsed << "ms"; + emit newVerifyResult(userid, reinterpret_cast(info->username), elapsed); } else if (result == Failed4Timeout) { LOG_CAT(info, GUI) << "识别超时。"; } else if (result == Rejected) { LOG_CAT(info, GUI) << "模组拒绝该命令。"; } else if (result == Failed4UnknownUser) { - LOG_CAT(info, GUI) << "未录入用户。"; - emit newVerifyResult(InvalidUserId, ""); + auto info = reinterpret_cast(data + 7); + uint16_t elapsed = ntohs(info->elapsed); + emit newVerifyResult(InvalidUserId, "", elapsed); + LOG_CAT(info, GUI) << "未录入用户, 耗时: " << elapsed << "ms"; } else if (result == Failed4UnknownReason) { - LOG_CAT(info, GUI) << "未知错误。"; - emit newVerifyResult(InvalidUserId, ""); + auto info = reinterpret_cast(data + 7); + uint16_t elapsed = ntohs(info->elapsed); + emit newVerifyResult(InvalidUserId, "", elapsed); + LOG_CAT(info, GUI) << "未知错误, 耗时: " << elapsed << "ms"; } else { LOG_CAT(info, GUI) << "未知错误(" << static_cast(result) << ")。"; } @@ -299,6 +305,11 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) { break; } case UploadImageData: { + if (result == Success) { + auto info = reinterpret_cast(data + 7); + LOG_CAT(info, GUI) << "图片下发注册成功,用户ID: " << ntohs(info->userid); + LOG_CAT(info, GUI) << Separator; + } break; } case GetCurrentStatus: { diff --git a/Analyser/ModuleCommunication.h b/Analyser/ModuleCommunication.h index 96972c3..d1f4dec 100644 --- a/Analyser/ModuleCommunication.h +++ b/Analyser/ModuleCommunication.h @@ -108,8 +108,9 @@ public: struct VerifyDataReply { uint16_t userid; - uint8_t username[UsernameSize]; // 32Bytes uint8_t admin; - uint8_t unlockStatus; + uint8_t username[UsernameSize]; // 32Bytes + uint8_t admin; + uint16_t elapsed; // 此时识别耗时时间 }; struct PalmFeatureHeader { @@ -160,7 +161,13 @@ public: MessageId currentMessageId() const; static std::string protocolDataFormatString(const uint8_t *data, int size); signals: - void newVerifyResult(uint16_t userid, const QString &username); + /** + * @brief newVerifyResult + * @param userid + * @param username + * @param elapsed ms毫秒 + */ + void newVerifyResult(uint16_t userid, const QString &username, uint16_t elapsed); void newPalmFeature(const PalmFeature &feature); void newEnrolledImageInfo(uint32_t size, const uint8_t *md5); void newImageSliceData(const std::vector &data); diff --git a/Readme.md b/Readme.md index e37a750..7f7d95b 100644 --- a/Readme.md +++ b/Readme.md @@ -57,9 +57,7 @@ HOST_TOOLS := /opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin ```shell ./rebuild-app.sh y L015 V200 R002 # 编译烧录固件 -./rebuild-app-ota.sh y L015 V200 R002 11 # 编译OTA固件,11为OTA版本号 +./rebuild-app-ota.sh y L015 V200 R002 12 # 编译OTA固件,11为OTA版本号 600X800 - -./rebuild-app.sh n L021 V901 R001 # 测试新分支的CDC ```