I am doing a project to implement Modbus client in the Python.
I found the package pymodbus. I installed in Windows it works fine , When I installed the package in raspberry Debian Linux, it was successful. I installed by using the following commands:
sudo easy_install pip
sudo pip install pymodbus
Pathbrowser is updated, show the path of the package in the dist-package.
But when I run the code, it gives me the error, My code is mentioned below.
from pymodbus.client.sync import ModbusTcpClient
# Accessing the ModBus Client with the IP address
client = ModbusTcpClient('127.0.0.1')
# Function Code 05 (x05) Write single Output coil (Coil_number,Data(True/False),Slave_ID(hex))
client.write_coil(5, True,unit=0x02)
# Function Code 01 (x01) Read output coils and store in vector (Start_coil_no,count_coil,Slave_ID)
result = client.read_coils(1,10,unit=0x02)
print (result.bits[4])