refactor: Modbus 缓冲大小用宏替换硬编码 250

- rs485_modbus.h: +MB_MAX_READ_REGS(125) / MB_MAX_DATA_BYTES(250) / MB_RESP_BUF_SIZE(255)
- rs485_modbus.c: data_buf[250]→data_buf[MB_MAX_DATA_BYTES]
                   buf[5+250]  →buf[MB_RESP_BUF_SIZE]
                   quantity>125→quantity>MB_MAX_READ_REGS
This commit is contained in:
wangfq
2026-07-30 15:28:11 +08:00
parent c7176b93f2
commit df6e38f118
2 changed files with 11 additions and 6 deletions
@@ -36,6 +36,11 @@
* addr(1) + fc(1) + byte_cnt(1) + data(38) + crc(2) = 43 */
#define MB_FULL_DATA_FRAME_LEN 43
/* FC 0x03/0x04 读寄存器缓冲 (Modbus 标准: max qty = 0x007D = 125) */
#define MB_MAX_READ_REGS 125 /* 单次读取最大寄存器数 */
#define MB_MAX_DATA_BYTES 250 /* 125 × 2 字节 */
#define MB_RESP_BUF_SIZE (5 + MB_MAX_DATA_BYTES) /* addr+fc+bc+data+crc */
/*===========================================================================
* API
*===========================================================================*/