2

Hope you are doing great! I recently started using python for modbus communication. I want to clear my few doubts.

  1. What module is better for modbus implementation using Python - minimalmodbus, pymodbus, pymodbus3 or else.
  2. I am using python3.4 but unable to install pymodbus module using pip or any means. So I installed pymodbus3.
  3. While using pymodbus3 module, I was able to write coils using following code:

    import pymodbus3
    import serial
    from pymodbus3.pdu import ModbusRequest
    from pymodbus3.client.sync import ModbusSerialClient as ModbusClient 
    from pymodbus3.transaction import ModbusRtuFramer
    from serial.tools.list_ports import comports
    
    client = ModbusClient(method = "rtu", port = 'COM4',stopbits = 1, bytesize = 8, parity = 'N', baudrate= 19200)
    connection = client.connect()
    client.write_coil(1000, 1, unit = 0x01)
    

For reading coil status (function 0x01):

result = client.read_coils(1000,1)
print(result)
client.close()

Its returning None.

Or writing to register and reading is also not working:

client.write_register(0, 1000, unit=0x01)
resu= client.read_holding_registers(0, 1, unit=0x01)
print(resu)
client.close()

Positive response is welcomed!

Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150
Ravi C
  • 64
  • 2
  • 10
  • I believe that `pymodbus3` is a Python 3 version of `pymodbus`. I also commend your style of asking questions, detailed and specific with no doubt about what's being asked. Really good job on that. – Koga Sep 01 '16 at 11:22
  • Thanks for appreciation Koga! So can we refer the documentation for [pymodbus](http://pythonhosted.org/pymodbus/) for pymodbus3. – Ravi C Sep 01 '16 at 11:44
  • umodbus module is also not working for me, I tried the example in [docs](http://umodbus.readthedocs.io/en/latest/client/rtu.html#example) – Ravi C Sep 02 '16 at 10:14
  • umm..I am using minimalmodbus which is supportingall the functions and i Implemented my features with it. But it was not able to use Force write multiple coils function. Any suggestion? – Ravi C Oct 01 '16 at 08:48

1 Answers1

13

This is a rather old question, but I want to put this information out there so there is less confusion.

pymodbus3 was a fork of pymodbus created to support python3 before pymodbus did so. pymodbus now fully supports python3 and pymodbus3 is no longer maintained and does not have all the latest that the original does.

See https://github.com/uzumaxy/pymodbus3/issues/7 for details.

Alex
  • 1,172
  • 11
  • 31