#ifndef _JXCT_PROTOCOL_H_ #define _JXCT_PROTOCOL_H_ #include "uart_dev.h" #include "pdebug.h" #include "timer.h" #include "comm_types.h" #ifdef __cplusplus extern "C" { #endif /* 精讯畅通雨量modbus传感器协议 */ /* 功能码 */ typedef enum { FRT_FUNCTION_CODE_READ_REGISTER = 0x03, /* 读寄存器 */ FRT_FUNCTION_CODE_WRITE_REGISTER = 0x10, /* 写寄存器 */ } FRT_MsgFunctionCode_e; /* 寄存器地址 */ typedef enum { FRT_REGISTER_MIN_WIND_DIRECTION = 0, /* 最小风向 */ FRT_REGISTER_AVERAGE_WIND_DIRECTION = 1, /* 平均风向 */ FRT_REGISTER_MAX_WIND_DIRECTION = 2, /* 最大风向 */ FRT_REGISTER_MIN_WIND_SPEED = 3, /* 最小风速 */ FRT_REGISTER_AVERAGE_WIND_SPEED = 4, /* 平均风速 */ FRT_REGISTER_MAX_WIND_SPEED = 5, /* 最大风速 */ FRT_REGISTER_TEMPERATURE = 6, /* 大气温度 */ FRT_REGISTER_HUMIDITY = 7, /* 大气湿度 */ FRT_REGISTER_PRESSURE = 8, /* 大气压 */ FRT_REGISTER_RAIN = 9, /* 雨量 */ FRT_REGISTER_PRECIPITATION_INTENSITY = 10, /* 总辐射 */ FRT_REGISTER_DEVICE_ADDR = 20, /* 设备地址 */ FRT_REGISTER_COMMU_BAUDRATE = 21, /* 波特率 */ FRT_REGISTER_SPEED_AVERAGE_TIME = 22, /* 风速平均时间 */ FRT_REGISTER_TEMPHUM_UPDATE_TIME = 23, /* 温湿度更新时间 */ FRT_REGISTER_RAIN_POWER_CONTROL = 24, /* 雨量电源控制 */ FRT_REGISTER_RAIN_REST = 25, /* 雨量复位 */ FRT_REGISTER_SOFT_REST = 26, /* 软件复位 */ FRT_REGISTER_REST_DEFAULT_SETTING = 27, /* 恢复出厂设置 */ FRT_REGISTER_PROTOCOL_SETTING = 28, /* 设置协议:0-ASCII;1-MODBUS协议 */ }FRT_MsgRegister; #pragma pack(push,1) typedef struct _frt_climate_pack{ unsigned char addr; unsigned char func; unsigned char addr_begin_high_byte; unsigned char addr_begin_low_byte; unsigned char regnum_begin_high_byte; unsigned char regnum_begin_low_byte; unsigned char crc_low_byte; unsigned char crc_high_byte; }frt_climate_pack; #define FRT_CLIMATE_PACK_SIZE(x) (sizeof(frt_climate_pack)) #define FRT_CLIMATE_PACK_CRC16(x) ((x->crc_low_byte)|(x->crc_high_byte<<8)) typedef struct _frt_climate_pack_resp{ unsigned char addr; unsigned char func; unsigned char data_len; unsigned char data[1]; }frt_climate_pack_resp; typedef void (*MsgProcFunc)(device_handle device, void*); /* 功能码处理函数 */ typedef struct _FRT_FunctionMsgProcTable_s{ u_int32_t msgId; MsgProcFunc pMsgProc; } FRT_FuncionMsgProcTable_s; typedef u_int16_t (*RegProcFunc)(void*); /* 寄存器处理表 */ typedef struct _FRT_RegProcTable_s{ u_int32_t regId; RegProcFunc pRegProc; } FRT_RegProcTable_s; void read_and_process_uart_data(device_handle uart_handle); #pragma pack(pop) #ifdef __cplusplus } #endif #endif