Hi,
I use socat on linux to create a virtual serial port, then run modpoll to test serial devices.
Using a USR–TCP232-302 device.
socat notes for serial line sniffer
Create a PTY with socat - note, cd to /tmp as the log files will be wriien in the current directory.
$ socat /dev/ttyUSB1,raw,echo=0 SYSTEM:‘tee input.txt | socat - “PTY,link=/tmp/ttyV0,raw,echo=0,waitslave” | tee output.txt’
Run the serial command, using the PTY
$ modpoll -m rtu -b 9600 -p none -a 2 -r 1 -c 1 -t4:float -1 -f /tmp/ttyV0
modpoll 3.4 - FieldTalk™ Modbus® Master Simulator
Copyright © 2002-2013 proconX Pty Ltd
Visit http://www.modbusdriver.com for Modbus libraries and tools.
Protocol configuration: Modbus RTU
Slave configuration…: address = 2, start reference = 1, count = 1
Communication…: /tmp/ttyV0, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type…: 32-bit float, output (holding) register table
Word swapping…: Slave configured as big-endian float machine
– Polling slave…
[1]: 0.000000
$ od -h input.txt
0000000 0302 0004 0000 c900 0033
0000011
$ od -h output.txt
0000000 0302 0000 0200 38c4
0000010
$ modpoll -m rtu -b 9600 -p none -a 2 -r 513 -c 2 -t4:hex -1 -f /tmp/ttyV0
modpoll 3.4 - FieldTalk™ Modbus® Master Simulator
Copyright © 2002-2013 proconX Pty Ltd
Visit http://www.modbusdriver.com for Modbus libraries and tools.
Protocol configuration: Modbus RTU
Slave configuration…: address = 2, start reference = 513, count = 2
Communication…: /tmp/ttyV0, 9600, 8, 1, none, t/o 1.00 s, poll rate 1000 ms
Data type…: 16-bit register (hex), output (holding) register table
Word swapping…: Slave configured as big-endian float machine
– Polling slave…
[513]: 0x0000
[514]: 0x0000
=======================================