/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2024-09-10 RuoFeng the first version */ #ifndef APPLICATIONS_RS485_H_ #define APPLICATIONS_RS485_H_ /*********************↓ define ↓************************/ #define rs_buf_max 64 // 串口接收缓存 #define MAX_SENSOR_NUM 5 // 决定处理要素模型条数 #define stemp "stemp" #define humi "humi" #define airpre "airpre" #define lux "lux" #define rain "rain" /*********************↑ define ↑************************/ /** * * * * * */ /*********************↓ include ↓************************/ /*********************↑ include ↑************************/ /** * * * * * */ /*********************↓ extern ↓************************/ /*********************↑ extern ↑************************/ /** * * * * * */ /********************↓ declaration ↓***********************/ typedef struct { char eKey[5]; //传感器通道号 uint8_t sensor_addr; //从机地址 uint16_t start_reg; //寄存器起始位置 uint8_t count; //读取寄存器数量 uint8_t d_pos; //数据偏移量 int factor; //修正因子 uint8_t d_length; //数据长度(单位uint16) int32_t value; //传感器数值 char eName[15]; //传感器名称 char eValue[10]; //传感器字符串形式数据 // char eNum[5]; //服务器端 传感器代号 uint8_t cfged; //参数已配置 uint8_t online; //是否在线 // uint8_t en_corr; //是否使能要素修正 // int16_t plus; // + // int16_t minus; // - // int16_t times; // * // int16_t divide; // / }Sensor; typedef enum { s_Temp = 0, s_Humi , s_Airpre, s_Lux , s_Rain , s_ALL , s_TypeMAX }Sensor_Read_Type; void RS485_SEND(uint8_t *buf, uint16_t size); Sensor_Read_Type get_sensor_num(char *cmd); int8_t READ_MODBUS_DATA_1(Sensor_Read_Type srt); /********************↑ declaration ↑***********************/ /** * * * * * */ /*********************↓ global variables ↓************************/ /*********************↑ global variables ↑************************/ /** * * * * * */ #endif /* APPLICATIONS_RS485_H_ */