Communication consistency error

Forum Home Forums Runtime Bugs Communicator Bugs Communication consistency error

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1926
    MohanadOdema
    Participant

    Hello,

    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 [1] [2] when communicating with the server that ultimately nulls the current device data [3] 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.

    [1] https://www.dropbox.com/s/rwuusx2abt4vczp/1.jpg?dl=0
    [2] https://www.dropbox.com/s/f3btf1u13db9vox/2.jpg?dl=0
    [3] https://www.dropbox.com/s/oyzu62a9ocihnpj/3.jpg?dl=0

    #1927
    Mikhail
    Moderator

    Hello,

    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?

    #1928
    MohanadOdema
    Participant

    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

    def main()
    global pi

    # main loop
    try:
    while True:
    store = ModbusSlaveContext(
    di = ModbusSequentialDataBlock(0, [0]*100),
    co = ModbusSequentialDataBlock(0, [0]*100),
    hr = ModbusSequentialDataBlock(0, [0]*100),
    ir = ModbusSequentialDataBlock(0, [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()
    pi.start()
    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
    writer.start(12)

    StartTcpServer(context, identity=identity, address=(“192.168.1.64”, 5022))

    except KeyboardInterrupt:
    p.stop()
    loop.stop()
    writer.stop()
    GPIO.cleanup()

    if __name__ == ‘__main__’:
    main()

    #1929
    Mikhail
    Moderator

    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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.