diff --git a/api/errorcode.cpp b/api/errorcode.cpp index 4e761bd..e06f1de 100644 --- a/api/errorcode.cpp +++ b/api/errorcode.cpp @@ -74,8 +74,9 @@ const char* error2str(int32_t code) { ERR2STR(kSMTP2_TipAlreadyLoad); ERR2STR(kSMTP2_TipLoadFail); default: + return "known"; break; } } } // namespace err -} // namespace iflytop \ No newline at end of file +} // namespace iflytop diff --git a/api/packet_interface.hpp b/api/packet_interface.hpp index 98e0e04..368cefc 100644 --- a/api/packet_interface.hpp +++ b/api/packet_interface.hpp @@ -15,10 +15,10 @@ typedef struct { #pragma pack(pop) typedef enum { - kpt_cmd = 0, - kpt_ack = 1, - kpt_error_ack = 2, -} packet_type_t; + kptv2_cmd = 0, + kptv2_ack = 1, + kptv2_error_ack = 2, +} zcan_cmd_packet_type_t; } // namespace zcr } // namespace iflytop diff --git a/protocol_parser.cpp b/protocol_parser.cpp index c12b326..d04b568 100644 --- a/protocol_parser.cpp +++ b/protocol_parser.cpp @@ -4,14 +4,14 @@ using namespace iflytop; using namespace std; #define TAG "ZIProtocolParser" -#define PROCESS_PACKET_BEGIN(var_cmdid, var_moduleType) \ - int32_t* param = (int32_t*)data; \ - int paramNum = (len - sizeof(cmd_header_t)) / sizeof(int32_t); \ - if (cmdid == var_cmdid) { \ - auto* mod = dynamic_cast(module); \ - if (mod == nullptr) { \ - m_cancmder->sendErrorAck(rxcmd, err::kce_operation_not_support); \ - return; \ +#define PROCESS_PACKET_BEGIN(var_cmdid, var_moduleType) \ + int32_t* param __attribute__((__unused__)) = (int32_t*)data; \ + int paramNum __attribute__((__unused__)) = (len - sizeof(cmd_header_t)) / sizeof(int32_t); \ + if (cmdid == var_cmdid) { \ + auto* mod = dynamic_cast(module); \ + if (mod == nullptr) { \ + m_cancmder->sendErrorAck(rxcmd, err::kce_operation_not_support); \ + return; \ } #define CHECK_PARAM_NUM(num) \ @@ -30,11 +30,13 @@ using namespace std; } #define PROCESS_PACKET_XX(var_cmdid, var_moduleType, var_funcname, XP, XACK, ...) \ - PROCESS_PACKET_BEGIN(var_cmdid, var_moduleType) \ - CHECK_PARAM_NUM(XP) \ - int32_t ack[XACK + 1] = {0}; \ - int32_t ecode = mod->var_funcname(__VA_ARGS__); \ - PROCESS_PACKET_XX_END(XACK) + { \ + PROCESS_PACKET_BEGIN(var_cmdid, var_moduleType) \ + CHECK_PARAM_NUM(XP) \ + int32_t ack[XACK + 1] = {0}; \ + int32_t ecode = mod->var_funcname(__VA_ARGS__); \ + PROCESS_PACKET_XX_END(XACK) \ + } #define PROCESS_PACKET_00(var_cmdid, var_moduleType, var_funcname) PROCESS_PACKET_XX(var_cmdid, var_moduleType, var_funcname, 0, 0) #define PROCESS_PACKET_01(var_cmdid, var_moduleType, var_funcname) PROCESS_PACKET_XX(var_cmdid, var_moduleType, var_funcname, 0, 1, &ack[1]) diff --git a/zmodule_device_script_cmder_paser.cpp b/zmodule_device_script_cmder_paser.cpp index 2b13e07..38384e0 100644 --- a/zmodule_device_script_cmder_paser.cpp +++ b/zmodule_device_script_cmder_paser.cpp @@ -1,4 +1,7 @@ #include "zmodule_device_script_cmder_paser.hpp" +#include +#include +#include using namespace iflytop; using namespace std; @@ -9,6 +12,8 @@ using namespace std; ack->rawlen = XACK * 4; \ }); + + #define PROCESS_PACKET_00(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 0, 0) #define PROCESS_PACKET_01(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 0, 1, ack->getAck(0)) #define PROCESS_PACKET_02(var_funcname, cmdhelp) PROCESS_PACKET_XX(var_funcname, cmdhelp, 0, 2, ack->getAck(0), ack->getAck(1))