Open coyool opened 5 years ago
Thanks for reporting this issue. Could you add a stacktrace?
sorry , I am very new to python, I don't know how to get stacktrace. you can get this error simply by putting a value of 33333 into the address 33333 which belong to station 233
I problely found the bug is that: when you use struct.pack, you must make sure all the values in the list are between 0~65535(for H pack) stand modbus NEVER predefine the type of values( negative or not), so please remove the signed config, and make it more compatble \umodbus\functions.py line 728
val = []
for d in data:
tmp = d
if tmp<0 :
tmp = 65536+d
val.append(tmp)
return struct.pack(fmt, self.function_code, len(data) * 2, *val)
run as rtu serve when writing to 233 station, 33000 write a data(<0,eg:-100) to addr 33000 (larger than 2^15), will surely cause "salve failure error" all code as below: