February 3, 2017 at 11:27 am #1926
I have a Modbus server running on a Raspberry Pi that communicates with a Modbus client on a desktop computer. Everything is working fine but I have a consistency problem. There is a repeated communication error   when communicating with the server that ultimately nulls the current device data  in the device data section in the communicator.
I need to optimize my system so I would really appreciate it if you advise me on how to deal with this bug. I’m posting some screenshots as well to give you insight of what I mean.February 3, 2017 at 3:15 pm #1927
The communication log “says” that RPi drops the connection. Do you develop the Modbus server by yourself or use 3rd party software? Is there any logs of the Modbus server?February 4, 2017 at 11:35 pm #1928
No I developed it by myself using the pymodbus library on the RPi. Unfortunately there are no logs for the Modbus server as I only run a Python code prompting it to act as a server. I can post to you the main loop though where I suspect the problem of communication lies since the values are never actually nullified in the server’s registers.
from pymodbus.server.async import StartTcpServer
from pymodbus.device import ModbusDeviceIdentification
from pymodbus.datastore import ModbusSequentialDataBlock
from pymodbus.datastore import ModbusSlaveContext, ModbusServerContext
from pymodbus.transaction import ModbusRtuFramer, ModbusAsciiFramer
from twisted.internet.task import LoopingCall
# main loop
store = ModbusSlaveContext(
di = ModbusSequentialDataBlock(0, *100),
co = ModbusSequentialDataBlock(0, *100),
hr = ModbusSequentialDataBlock(0, *100),
ir = ModbusSequentialDataBlock(0, *100))
context = ModbusServerContext(slaves=store, single=True)
identity = ModbusDeviceIdentification()
identity.VendorName = ‘pymodbus’
identity.ProductCode = ‘PM’
identity.VendorUrl = ‘http://github.com/bashwork/pymodbus/’
identity.ProductName = ‘pymodbus Server’
identity.ModelName = ‘pymodbus Server’
identity.MajorMinorRevision = ‘1.0’
delaytime = AtlasI2C.long_timeout
pi = Temp()
time = 5 # 5 seconds delaytime = 5 # 5 seconds delay
writer = LoopingCall(read_context,a=(context,))
loop = LoopingCall(f=updating_writer, a=(context,))
loop.start(8) # initially delay by time
StartTcpServer(context, identity=identity, address=(“192.168.1.64”, 5022))
if __name__ == ‘__main__’:
main()February 5, 2017 at 1:34 pm #1929
To find a cause, debug and log needed. The source code is not enough.
There is a new possibility recently developed: you can install Rapid SCADA on your RPi and pass data from RPi to PC using Rapid SCADA internal protocol. This functionality is implemented by Rapid Gate module. You can download it by this link. In case of follow up questions, be free to ask.
Send me a letter to receive a trial key for Rapid Gate.
You must be logged in to reply to this topic.