From 34294c5c8545db855b8c11907b7d8635dc4fe3be Mon Sep 17 00:00:00 2001 From: luocai Date: Sat, 12 Oct 2024 17:06:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=8E=B7=E5=8F=96=E6=8E=8C?= =?UTF-8?q?=E9=9D=99=E8=84=89=E4=BB=A5=E6=B3=A8=E5=86=8Cid.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Analyser/ModuleCommunication.cpp | 21 ++++++++++++++-- Analyser/ModuleCommunication.h | 2 ++ Analyser/qml/Main.qml | 1 - Readme.md | 4 ++- resources/L015掌静脉识别模组串口通信协议.md | 27 +++++++++++++++++++++ 5 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Analyser/ModuleCommunication.cpp b/Analyser/ModuleCommunication.cpp index 655f267..fa604cd 100644 --- a/Analyser/ModuleCommunication.cpp +++ b/Analyser/ModuleCommunication.cpp @@ -283,6 +283,8 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) { } else if (result == Failed4PalmEnrolled) { emit errorOccurred(NoteId::InteractWarning, "手掌已被录入"); LOG_CAT(info, GUI) << "手掌已被录入。"; + } else if (result == Failed4MaxUser) { + emit errorOccurred(NoteId::InteractWarning, "录入", "注册已达上限"); } else { LOG_CAT(info, GUI) << "未知错误(" << static_cast(result) << ")。"; } @@ -350,9 +352,24 @@ void ModuleCommunication::processPackage(const uint8_t *data, uint16_t size) { break; } case GetUniqueID: { - LOG_CAT(info, GUI) << "模组: " << protocolDataFormatString(data, size); auto id = reinterpret_cast(data + 7); - LOG_CAT(info, GUI) << "模组ID: " << std::string_view(id->id, sizeof(id->id)); + int idCount = 0; + std::ostringstream oss; + oss << "["; + for (int byteIndex = 0; byteIndex < sizeof(id->userids); byteIndex++) { + for (uint8_t bitPosition = 0; bitPosition < 8; bitPosition++) { + if (id->userids[byteIndex] & (1 << bitPosition)) { + uint16_t uid = byteIndex * 8 + bitPosition; + if (uid >= 1) { + oss << uid << ", "; + idCount++; + } + } + } + } + oss << "]"; + LOG_CAT(info, GUI) << "模组ID: " << std::string_view(id->id, sizeof(id->id)) << ", user ids[" << idCount + << "]: " << oss.str(); LOG_CAT(info, GUI) << Separator; break; } diff --git a/Analyser/ModuleCommunication.h b/Analyser/ModuleCommunication.h index 22fd0f1..a44fad8 100644 --- a/Analyser/ModuleCommunication.h +++ b/Analyser/ModuleCommunication.h @@ -21,6 +21,7 @@ class ModuleCommunication : public QObject { public: constexpr static uint16_t VendorIdentifier = 0x3346; constexpr static uint16_t ProductIdentifier = 0x0001; + constexpr static uint16_t MaxUserCount = 4000; constexpr static uint16_t InvalidUserId = std::numeric_limits::max(); enum MessageId : uint8_t { Reply = 0, @@ -187,6 +188,7 @@ public: struct ModuleId { char id[32]; + uint8_t userids[512]; // bit位 }; #pragma pack() diff --git a/Analyser/qml/Main.qml b/Analyser/qml/Main.qml index abbb9a3..37a4627 100644 --- a/Analyser/qml/Main.qml +++ b/Analyser/qml/Main.qml @@ -93,7 +93,6 @@ Window { info_bar.showError(tip,2000,detailMessage) } else if (level === 2) { info_bar.showInfo(tip,2000,detailMessage) - resultBrowser.append(tip+":"+detailMessage) } } function onNewVideoFrame() { diff --git a/Readme.md b/Readme.md index 71057df..91bb43e 100644 --- a/Readme.md +++ b/Readme.md @@ -64,7 +64,9 @@ HOST_TOOLS := /opt/Xuantie-900-gcc-elf-newlib-x86_64-V2.6.1/bin ./rebuild-app-ota.sh y L015 V200 R002 05 600X800 -docker run -it --rm --user 1000:1000 -v /opt:/opt -v $(pwd):$(pwd) -w $(pwd) registry.cn-shenzhen.aliyuncs.com/amass_toolset/yoctools:22.04 ./rebuild-app.sh y L015 V200 R002 +docker run -it --rm --user 1000:1000 -v /opt:/opt -v $(pwd)/..:$(pwd)/.. -w $(pwd) registry.cn-shenzhen.aliyuncs.com/amass_toolset/yoctools:22.04 ./rebuild-app.sh y L015 V200 R002 + +docker run -it --rm --user 1000:1000 -v /opt:/opt -v $(pwd)/..:$(pwd)/.. -w $(pwd) registry.cn-shenzhen.aliyuncs.com/amass_toolset/yoctools:22.04 ./rebuild-app-ota.sh y L015 V200 R002 06 ``` diff --git a/resources/L015掌静脉识别模组串口通信协议.md b/resources/L015掌静脉识别模组串口通信协议.md index b829331..12d33e1 100644 --- a/resources/L015掌静脉识别模组串口通信协议.md +++ b/resources/L015掌静脉识别模组串口通信协议.md @@ -1,11 +1,23 @@ ## 1 串口配置 +目前模组支持两种通信接口:UART,USB(CDC)。其中 + +UART: + - 波特率:115200 - 数据位:8 - 停止位:1 - 奇偶检验:无 - 流控制:无 +USB(CDC): + +- 波特率:2000000 +- 数据位:8 +- 停止位:1 +- 奇偶检验:无 +- 流控制:无 + ## 2 消息格式 主控和模块通讯的基本格式如下表所示,字节序为 **大端字节序(Big Endian)**: @@ -35,6 +47,7 @@ | MID_ENROLL_SINGLE | 0x1D | 掌静脉录入(单帧) | | MID_DELUSER | 0x20 | 删除一个已录入的掌静脉 | | MID_DELALL | 0x21 | 删除所有已录入的掌静脉 | +| MID_MODULE_ID | 0xAC | 获取模组ID,唯一标识 | | MID_ENROLL_PALM_FEATUTE | 0xF9 | 主控下发掌静脉特征值给模组进行录入 | | MID_GET_PALM_FEATUTE | 0xFA | 主控请求获取指定用户掌静脉特征值 | @@ -230,6 +243,20 @@ struct msg_deluser_data { - 0x00(MR_SUCCESS):删除成功 - 0x05(MR_FAILED4_UNKNOWNREASON):未知错误 +### 3.7 获取模组ID + +该命令用于获取模组ID,类型为长度为32的字符串。 + +该指令无需携带参数。 + +模组通过消息 MID_REPLY 返回的数据 msg_reply_module_id 定义如下: + +```c++ +struct msg_reply_module_id { + char id[32]; +}; +``` + ### 3.7 掌静脉特征值录入(MID_ENROLL_PALM_FEATUTE) 该命令用于直接将掌静脉特征值下发给模组进行录入。