AWTK-MODBUS 客户端工具是一个用于测试 MODBUS 服务器的工具。它可以通过配置文件来执行一系列的操作,包括连接、读写寄存器、读写位等。
启动方法:
./bin/modbus_client ./data/tcp.ini
- url: 连接地址
- slave: 从机 ID(RTU 模式有效)
[connect]
url = tcp://localhost:502
[connect]
url = serial:///dev/ttys005
slave=1
- addr: 地址
- data: 数据
[write_bit]
addr = 0x130
count = 1
data = 1
- addr: 地址
- count: 数量
- data: 数据,逗号分隔
[write_bits]
addr = 0x130
count = 10
data = 1,0,1,1,0,0,1,1,1,1
- addr: 地址
- count: 数量
- data: 期望数据(可选), 逗号分隔
[read_bits]
addr = 0x130
count = 10
data = 1,0,1,1,0,0,1,1,1,1
- addr: 地址
- data: 数据
参考 write_registers
[write_register]
addr = 0x160
data = 1
- addr: 地址
- count: 数量
- data: 数据,逗号分隔
- year: 年
- month: 月
- day: 日
- hour: 时
- minute: 分
- second: 秒
- rand: 随机数
- count: 计数器
[write_registers]
addr = 0x160
count = 10
data = 1,0,1,1,0,0,1,1,1,1
[write_registers]
addr = 40000
count = 8
data = year,month,day,hour,minute,second,rand,count
- addr: 地址
- count: 数量
- data: 数据,逗号分隔
[read_registers]
addr = 0x160
count = 10
data = 1,0,1,1,0,0,1,1,1,1
- addr: 地址
- count: 数量
- data: 期望数据(可选), 逗号分隔
[read_input_registers]
addr = 0x300
count = 12
data = 0,1,2,3,4,5,6,7,8,9,10,11
- addr: 地址
- count: 数量
- data: 期望数据(可选), 逗号分隔
[read_input_bits]
addr = 0x200
count = 50
data = 0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1, 0,1,0,1,0,1,0,1,0,1,
- time: 时间(毫秒)
[sleep]
time = 1000
[rewind]
- target : 目标
[goto]
target = write_register
[close]