You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#pragma once
#include <stdint.h>
#define ZCANCMD_PACKET_MAX_LEN 64
namespace iflytop {
typedef enum { kboard = 0, // 板子
khbot_module = 1, // hbot模块
kwater_cooling_temperature_ctrl_module = 2, // 水冷温度控制
kfan_ctrl_module = 3, // 风扇控制
kcode_scaner = 4, // 扫码器
ktmc_step_motor = 5, // 步进电机
kmini_servo_motor_module = 6, // 舵机
kpipette_ctrl_module = 7, // 移液体枪控制
ka8000_optical_module = 100, // a8000光学模组
ka8000_idcard_reader = 101, // id卡读卡器
ka8000_plate_code_scaner = 102, // 反应板条扫码器
} module_type_t;
namespace zcr { #pragma pack(push, 1)
typedef struct { uint8_t packetType; uint16_t cmdid; uint8_t moduleId; uint16_t index; uint8_t datalen; uint8_t data[]; /* int8_t checksum;*/ } zcr_cmd_header_t;
#pragma pack(pop)
typedef enum { kptv2_cmd = 0xA0, kptv2_ack = 0xA1, kptv2_error_ack = 0xA2, kptv2_event = 0xA3, } zcan_cmd_packet_type_t;
static inline bool zcr_cmd_checkpacket(const zcr_cmd_header_t* header, int len) { if (len < (int)sizeof(zcr_cmd_header_t)) return false; if ((int)(header->datalen + sizeof(zcr_cmd_header_t) + 1) != len) return false;
uint8_t checksum = 0; for (int i = 0; i < len - 1; i++) checksum += ((uint8_t*)header)[i];
return checksum == ((uint8_t*)header)[len - 1]; }
} // namespace zcr
} // namespace iflytop
|