From a72ab76f401598ef36a95107a4298292b6c36d8e Mon Sep 17 00:00:00 2001 From: zhaohe Date: Wed, 7 Aug 2024 15:15:43 +0800 Subject: [PATCH] init --- zscanprotocol.hpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 zscanprotocol.hpp diff --git a/zscanprotocol.hpp b/zscanprotocol.hpp new file mode 100644 index 0000000..4c4873e --- /dev/null +++ b/zscanprotocol.hpp @@ -0,0 +1,47 @@ +#pragma once +#include + +#pragma pack(1) + +/** + * @brief 消息格式 12bit from,1bit emergency + * H L + * [1] [4bit] [8bit] [8bit] [4bit/4bit] + * , from to frameNum/frameId + */ + +// 数值越大优先级越低 + +typedef enum +{ + kcmd, + kreceipt, + kerror_receipt, + kreport, +} packet_type_t; + +typedef enum +{ + kpriority_emergency_report = 7, + kpriority_cmd = 8, + kpriority_receipt = 9, + kpriority_report = 10, +} priority_t; + +typedef struct +{ + uint8_t frameNumAndFrameId; + uint8_t to; + uint8_t from; + uint8_t pad; +} zcanid_t; + +typedef struct +{ + uint8_t ptype; + uint8_t index; + uint16_t function_id; + uint8_t params[]; +} zcanbus_packet_t; + +#pragma pack()