Reading registers with pymodbus

前端 未结 2 1441
忘掉有多难
忘掉有多难 2021-01-02 18:35

I am very new to Modbus and PyModBus however I have spent a good amount of time trying to read up and experiment with it. If anyone could point me in the right direction I

2条回答
  •  萌比男神i
    2021-01-02 18:46

    Try to:

     response = client.read_holding_registers(0x00,4,unit=1)
    

    where the unit value is device id of the slave.

    To print all:

    print response.registers
    

    Also is possible to directly get one value (for example third register):

    print response.getRegister(2)
    

    or

    print response.registers[2]  
    

提交回复
热议问题