Files
Leakage-Control/leakage_system/usr/protocol/proto_modbus_master_leakage.h
2026-02-24 09:58:06 +08:00

48 lines
1.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _PROTO_MODBUS_MASTER_LEAKAGE_H_
#define _PROTO_MODBUS_MASTER_LEAKAGE_H_
#include "main.h"
#include "app_com.h"
#define COMM_SENSOR_NUM_MAX (32) /*最大的通讯数量*/
/*通讯状态*/
#define PROTO_LEAKAGE_COMM_STATE_INIT (0U) /*初始化 */
#define PROTO_LEAKAGE_COMM_STATE_CURR_DATA_GET (1U) /*获取实时数据*/
#define PROTO_LEAKAGE_COMM_STATE_DEFAULT PROTO_LEAKAGE_COMM_STATE_CURR_DATA_GET
#define PROTO_LEAKAGE_STATE_CODE_TIME_OUT (30U) /*通讯超时*/
typedef struct
{
struct /*通讯相关参数*/
{
u8 id; /*modbus通讯id*/
u8 state; /*传感器当前的通讯状态*/
u8 leakage_data_index; /*漏液子控索引*/
u16 state_send_time; /*当前通讯状态发送次数*/
u16 tx_time_out_count; /*协议指令发送次数*/
u32 sensor_state_code; /*传感器状态码为对应位为1代表异常*/
}comm;
}proto_sensor_class_t;
typedef struct proto_leakage_t proto_leakage_t;
struct proto_leakage_t
{
u16 sensor_index; /*当前与哪个传感器通讯*/
u16 sensor_num; /*总共通讯的传感器数量*/
proto_sensor_class_t sensor[APP_LEAKAGE_SUB_DEVICE_NUM]; /*传感器状态*/
void (*init)(proto_leakage_t *);
void (*tx_task)(proto_leakage_t *);
void (*uart_send)(u8 *,u16);
};
extern proto_leakage_t modbus_leakage[APP_COM_NUM];
#endif