Modules§
Structs§
- Coil
- Coil 结构体(FC01)
- Hreg
- HREG(保持寄存器)结构体(FC03)
- Ireg
- IREG(输入寄存器)结构体(FC04)
- Ists
- ISTS(离散输入)结构体(FC02)
- Modbus
Ctx - ModbusCtx,用于沟通上下文
Traits§
- BitRead
- 支持 01/02 的位读取(Coil/ISTS)
- BitWrite
- 用于 FC05 写单线圈
- Register
Read - RegisterRead:支持 is_valid(addr) 用于越界检查 支持03/04寄存器的读取(Hreg/Ireg)
- Register
Write - 用于 FC06 写单保持寄存器
Functions§
- Frame
Len4 Func - FrameLen4Func,获取func需要用到的数据长度 get the len for func_code
- Random
- 生成闭区间 [min(start_val,end_val), max(…)] 内的随机 u16
- build_
exception_ resp - 组装异常响应:Function=03|0x80 + ExceptionCode(1) + CRC(2)
- build_
resp_ bit_ reads - 组装 FC01 / FC02 响应:
- crc16_
modbus - Modbus RTU CRC16,用于生成CRC16验证码