0

I have created a modbusrtu server using pymodbus library on Pi4.I am writing values on the context using the function

def write_data(context,address, value, slave_id_reader,reg_type):
        context = context
        print(" Adddress =",address,", value =",value,", slave_id :",slave_id_reader," ,reg_type ",reg_type)
        # while True:
        context[slave_id_reader].setValues(reg_type, address, value)

when i read from the Qmodmaster software on Windows, I am receieving correct values(see attached picture). But as soon as i use another pi or controller(TEMCO) . It fails to receive correct values .Using another pi which is connected through modbusrtu protocol , i have used client code, But some times it reads the value and sometime it fails and timeout occurs.When reading through the TEMCO thrugh rs485 or any controller. the values appear sometimes which are mostly wrong and most of the time there are no values.I have checked the server settings on all of them

                        timeout=1, 
                        baudrate=9600, 
                        parity='N',
                        bytesize=8,
                        stopbits=1)

These settings are same in the controller and pi

I have tried increaasing and decreasing delay in reading the register but nothing worked.

I have created a modbus rtu server using pymodbus library on python. I am writing register from the server. Secondly, on another pi I have made a client using pymodbus library which is reading from the server.Both pi are connected serially.

These are logs printed on the Client's end. There is a frequent disconnection between the Client and the server. Sometimes it reads and sometimes it doesn't

ReadRegisterResponse (65)
ReadRegisterResponse (65)
Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)
ReadRegisterResponse (65)
ReadRegisterResponse (65)
ReadRegisterResponse (65)
Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)
ReadRegisterResponse (65)
ReadRegisterResponse (65)
  • Hello Umer. This issue you are reporting here is oftentimes related to wiring and/or hardware and not anything related to software. Make sure you are connecting all cables properly, including a good ground common to both devices (sometimes that can be quite tricky). – Marcos G. Feb 10 '23 at 12:01
  • I am reading the register using the software T3000, which gets data from the TEMCO, when I read only when 1 register then I get the correct value on the correct address 70 % of the time. For multiple registers the value is shown on a random register address. In short on both sides, we have software that reads and writes the registers. but the one reading from TEMCO(controller) is reading the wrong values. Secondly, In place of T3000, When I use Qmodbus software on Windows I receive the correct value on the correct address. – Umer Farooq Feb 10 '23 at 13:14
  • it still sounds to me like a hardware issue. If you are sure it is not maybe you should post reproducible code and full error logs. Then I might be able to help. – Marcos G. Feb 10 '23 at 13:19
  • I have created a modbus rtu server using pymodbus library on python. I am writing register from the server. Secondly, on another pi I have made a client using pymodbus library which is reading from the server.Both pi are connected serially. I have added logs in the post above. As you can see there is a frequent disconnection between the Client and the server. Sometimes it reads and sometimes it doesn't When I use the software in place of the second Client pi. I have received frequent Server timeouts about 50% of the times there is a timeout and software failed to receive the packet – Umer Farooq Feb 13 '23 at 09:37
  • And can it be that you are reading registers too fast? do you have any delay between reads? Maybe you can show your client code... – Marcos G. Feb 13 '23 at 09:54
  • I have tried various delays, 0.4 , 0.6 , 1.5 , 1 , 2 seconds. But the problem persist – Umer Farooq Feb 13 '23 at 10:28

0 Answers0