Modules§
Structs§
- Coil
- Coil 结构体(FC01)
- Hreg
- Ireg
- IREG(输入寄存器)结构体(FC04)
- Ists
- ISTS(离散输入)结构体(FC02)
- Modbus
Ctx - ModbusCtx,用于沟通上下文
- Req03
Traits§
- BitRead
- 支持 01/02 的位读取(Coil/ISTS)
- Register
Read - RegisterRead:支持 is_valid(addr) 用于越界检查
Functions§
- build_
exception_ resp - 组装异常响应:Function=03|0x80 + ExceptionCode(1) + CRC(2)
- build_
resp03 - 组装 03 响应帧:Unit(1)+Func(1)+ByteCount(1)+Reg(2*quantity)+CRC(2)
- build_
resp04 - 组装 FC04 响应(与 FC03 类似,只是 Func=0x04)
- build_
resp_ bit_ reads - 组装 FC01 / FC02 响应:
- crc16_
modbus - Modbus RTU CRC16,用于生成CRC16验证码
- parse_
req03 - 解析固定 8 字节 Modbus RTU 03 请求
- random
- 生成闭区间 [min(start_val,end_val), max(…)] 内的随机 u16