From e8f1bf27941f432c968aa9c029e6493664204eda Mon Sep 17 00:00:00 2001 From: zhaohe Date: Fri, 26 Apr 2024 14:18:04 +0800 Subject: [PATCH] update --- iflytop_canbus_protocol.hpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/iflytop_canbus_protocol.hpp b/iflytop_canbus_protocol.hpp index d72a4c9..23e33d0 100644 --- a/iflytop_canbus_protocol.hpp +++ b/iflytop_canbus_protocol.hpp @@ -6,6 +6,20 @@ extern "C" { #pragma pack(1) +/** + * @brief 消息格式 12bit from,1bit emergency + * + * [1] [4bit] [8bit] [8bit] [4bit/4bit] + * , from to frameNum/frameId + */ + +typedef struct { + uint8_t pad; + uint8_t from; + uint8_t to; + uint8_t frameNumAndFrameId; +} zcanid_t; + typedef struct { uint8_t ptype; uint8_t index; @@ -20,7 +34,6 @@ typedef enum { kreceipt, kerror_receipt, kreport, - kheat, // 心跳 } packet_type_t; typedef enum { @@ -41,6 +54,7 @@ typedef enum { typedef enum { kerr_noerror = 0, + kerr_overtime = 1, // 驱动器错误 kerr_motorReset = 100, @@ -53,6 +67,28 @@ typedef enum { } ErrorCode_t; + +static const char *ErrorCodeToString(uint32_t code) { + switch (code) { + case kerr_noerror: + return "no error"; + case kerr_motorReset: + return "motor reset"; + case kerr_motorUnkownError: + return "motor unkown error"; + case kerr_AirBlowerError: + return "air blower error"; + case kerr_HeaterError: + return "heater error"; + case kerr_BlowerError: + return "blower error"; + case kerr_ProportionalValveError: + return "proportional valve error"; + default: + return "unkown error"; + } +} + typedef enum { /***********************************************************************************************************************