From 81e5d4c18295ebc8e79e14a7ea072efe7fb62b4a Mon Sep 17 00:00:00 2001 From: zhaohe Date: Sat, 21 Oct 2023 14:10:38 +0800 Subject: [PATCH] update --- api/api.hpp | 3 ++- api/i_cmdparser.hpp | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/api/api.hpp b/api/api.hpp index bf96cf1..a72db9c 100644 --- a/api/api.hpp +++ b/api/api.hpp @@ -6,4 +6,5 @@ #include "zi_xymotor.hpp" #include "packet_interface.hpp" #include "i_zcan_cmder.hpp" -#include "i_zcan_cmder_master.hpp" \ No newline at end of file +#include "i_zcan_cmder_master.hpp" +#include "i_cmdparser.hpp" \ No newline at end of file diff --git a/api/i_cmdparser.hpp b/api/i_cmdparser.hpp index 590a1d2..61bf245 100644 --- a/api/i_cmdparser.hpp +++ b/api/i_cmdparser.hpp @@ -31,9 +31,23 @@ class ICmdParserACK { } return (int32_t *)rawdata + index; } + + int32_t getAckInt32Val(int index) { + if (index < 0 || index >= rawlen / sizeof(int32_t)) { + return 0; + } + return *((int32_t *)rawdata + index); + } + + int32_t getAckInt32Num() { + if (rawlen != sizeof(int32_t)) { + return 0; + } + return *((int32_t *)rawdata); + } }; -typedef function ICmdFunction_t; +typedef function ICmdFunction_t; class ICmdParser { public: