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.

53 lines
1.4 KiB

#pragma once
#include <stdint.h>
#define ZCANCMD_PACKET_MAX_LEN 64
namespace iflytop {
typedef enum {
khbot_module = 1, // hbot模块
ktemperature_ctrl_module = 3, // 温度控制
kfan_ctrl_module = 5, // 风扇控制
kcode_scaner = 6, // 扫码器
kpipette_ctrl_module = 7, // 移液体枪控制
ka8000_optical_module = 8, // a8000光学模组
ktmc_step_motor = 10, // 步进电机
kmini_servo_motor_module = 11, // 舵机
kboard = 12, // 板子
ka8000_idcard_reader = 13, // id卡读卡器
ka8000_plate_code_scaner = 14, // 反应板条扫码器
} module_type_t;
namespace zcr {
#pragma pack(push, 1)
typedef struct {
uint8_t packetType;
uint16_t cmdid;
uint8_t moduleId;
uint8_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 < sizeof(zcr_cmd_header_t)) return false;
if ((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