I'm using modbus_tk library to use as a Modbus RTU slave. I have an off the shelf Modbus RTU master simulator running on another PC through a usb to 485 converter. I cannot see my holding register in the Master.
I have verified that the serial link is good because I can send strings to the slave using a serial program. I have tried setting up the Master for 16 and 32 bit ints the response is always 83 04. I have tried using a few different masters with staring address of 0, this one happens to default to first register 40001. Baud rates and serial port setting match.
import modbus_tk
import modbus_tk.defines as cst
from modbus_tk import modbus_rtu
import serial
import time
modbusServ = modbus_rtu.RtuServer(serial.Serial('/dev/ttyS0'),baudrate= 9600,
bytesize=8, parity='N', stopbits=1, xonxoff=0)
print("start")
modbusServ.start()
slave_1 = modbus_tk.modbus.Slave(1)
slave_1.add_block("BlockName", modbus_tk.defines.HOLDING_REGISTERS, 40001, 10)
aa= (1,2,3,4,5,6,7,8,9,10) # data in the register
while True:
slave_1.set_values ("BlockName", 40001, aa)
time.sleep(0.5)