feat: RS485透传改为Modbus RTU Master轮询寄存器41161报警信号

This commit is contained in:
2026-05-27 17:15:57 +08:00
parent 0bc39b7944
commit 5318c35d37
17 changed files with 380 additions and 4373 deletions

View File

@ -74,6 +74,10 @@ extern "C" {
// | 月
// 年
#ifndef HEARTBEAT_PACKET
#define HEARTBEAT_PACKET 1 /* 启用心跳包上报 */
#endif
#ifndef USE_W5500
#define USE_W5500 1 /* 默认启用W5500以太网模块 */
#endif
@ -93,13 +97,14 @@ extern "C" {
#define PROTO_TYPE_IO 0x10
#define PROTO_TYPE_NET 0x55
#define PROTO_TYPE_485 0x48
#define PROTO_TYPE_MODBUS_RTU 0x4D
#define PROTO_TYPE_HB 0xAA
/* =========================================================
🚀 核心身份标识:烧录不同设备时,请务必修改这个数字!
比如设备A烧录时改为 0x01设备B烧录时改为 0x02
========================================================= */
#define MY_DEVICE_ID 101
#define MY_DEVICE_ID 105
/* =========================================================
🚀 开发调试开关

View File

@ -0,0 +1,34 @@
#ifndef __MODBUS_RTU_MASTER_H
#define __MODBUS_RTU_MASTER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stm32f1xx_hal.h"
#define MODBUS_RTU_SLAVE_ADDR 1
#define MODBUS_RTU_TARGET_REG 1160
#define MODBUS_RTU_REG_QTY 1
#define MODBUS_RTU_POLL_INTERVAL 1000
#define MODBUS_RTU_RESP_TIMEOUT 500
#define MODBUS_RTU_INTER_CHAR_TIMEOUT 10
#define MODBUS_RTU_TX_ECHO_MARGIN 10
#define NORIS_FIRE_ALARM(reg) (((reg) >> 4) & 0x01)
#define NORIS_DOOR_ALARM(reg) (((reg) >> 5) & 0x01)
#define NORIS_BILGE_ALARM(reg) (((reg) >> 6) & 0x01)
#define NORIS_GAS_ALARM(reg) (((reg) >> 7) & 0x01)
#define MODBUS_RTU_MAX_RX_BUF 64
void ModbusRTU_Master_Init(void);
void ModbusRTU_Master_Task(void);
void ModbusRTU_FeedRxByte(uint8_t byte);
uint8_t ModbusRTU_GetAlarmState(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -14,7 +14,7 @@
/* Modbus TCP 配置 */
#if TEST_A701
#define MODBUS_SERVER_IP {192, 168, 0, 6} /* A701 测试服务器 */
#define MODBUS_SERVER_IP {192, 168, 6, 156} /* A701 测试服务器 */
#else
#define MODBUS_SERVER_IP {192, 168, 0, 1} /* 现场生产服务器 */
#endif