I try to follow exactly this video https://www.youtube.com/watch?v=ZlHqEOmvW6M
You can have a look what I do : https://drive.google.com/file/d/1LenDiJVxT8wQUOlMbdDZ_VkIzqLvHmLJ/view?usp=sharing
I will describe what I do :
I use modbus slave simulator in desktop as modbus slave, I use raspberry pi 3 as a master. We communicate between it .I use rasberry pi 3 to show register in modbus slave simulator ( modbus slave register that we will let it a number)
enter image description here I use 2 usb to rs 485, 1 dongle in my laptop, 1 dongle in rasberry pi3. I use eclipse ide for code.
I also try the another usb to rs 485 is usb to rs 485 v2. I also try another modbus slave simulator. All two methods, slave still no response@@.
My code :
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
from pymodbus.register_read_message import ReadInputRegistersResponse
client = ModbusClient(method='rtu', port='/dev/ttyUSB0',stopbits=1, bytesize=8, parity='N',baurdrate='9600', timeout=0.3)
connection = client.connect()
print(connection)
value = client.read_input_registers(300, 4, unit=0x00)
print(value.registers)
Result in :
Traceback (most recent call last):
File "main.py", line 19, in <module>
print(value.registers)
Attribute: 'ModbusIOException' object has no attribute 'registers'
My laptop and rasberry show that 2 usb are received.
I think there is no problem with code, with simulator, rasberry pi. I think the problem is link between 2 usb, and I try to link it by wire but it cant help.
Do anybody have a solution (like use another kind of adapter)?