Hi,
I've looked around for various modbus libraries that can simulate a serial device and this appears to be the best! I don't have a serial device to test on so
I'm looking to simulate this device being connected, in order to simply add a register and a coil to a slave server with master server to read and write to them. Using the example simulator that comes in the examples on Github (
https://github.com/ljean/modbus-tk/blob/master/examples/mysimu.py), I'm executing this using the port '/dev/ptyp5' as in the example and receiving a server error 'Error 13: permission denied' response. When trying to simulate a device, can I use any name in the '/dev/' folder? I've tried changing to another that is present in that folder such as '/dev/ttyS0' and set the permissions the read/write over all users with the same response. I've also changed the permissions of the simulating python script to the maximum (777) with no luck. I am working on an Ubuntu 1604 machine.
Execution:
tom@tom-OptiPlex-9020:~/scripts$ python simulator.py
'quit' for closing the server
server error: [Errno 13] Permission denied
modbus_tk.simulator is running...
ps aux
tom 6288 0.2 0.1 190024 11724 pts/3 Sl+ 15:43 0:00 python simulator.py
As shown above I can see the process when it is running. When trying to add a slave to the '/dev/ptyp5' device as expected:
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ptyp5: [Errno 2] No such file or directory: '/dev/ptyp5'
Is it possible to simulate a RTU device that I can add coils and registers to, as if there were an actual serial device attached?
I'm aware some of this might seem a little basic and am just trying to get these examples running in this way as a start.
Thanks in advance,
Tom