I have a Furnace that I am trying to communicate with using Modbus protocol. Here is the command:
mell_addr = 0x01
ser = None
def start():
global ser
ser = serial.Serial('/dev/ttyUSB0', # RS485 comm port on Iono Pi Max
baudrate=9600,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_TWO,
timeout=0.05)
def write(query):
global ser
# CRC-16 default function, matches default CRC for TM4 and Love 16B:
crc16func = crcmod.mkCrcFun(0x18005)
byte_query = bytearray(query)
crc_send = crc16func(byte_query)
crc_send = crc_send.to_bytes(2,'little')
byte_query += crc_send
ser.write(byte_query)
start()
write([mell_addr, 0x05, 0x08, 0x14, 0xff,0x00])
a = ser.readline()
print(a)
b = [i for i in a]
print(b)
a = [hex(i) for i in a]
print(a)
ser.close()
This command is meant to turn the output of furnace on. It runs on mac and windows but not on linux. The errors I get on linux are not consistent for example:
b’x01x05x08x14xffx00′ – [1, 5, 8, 20, 255, 0]
b’x01xffx00xce^’ – [1, 255, 0, 206, 94]
b’x05x08x14xffx00xce^’ – [5, 8, 20, 255, 0, 206, 94]
b’x01x05x08x14xffx00′ – [1, 5, 8, 20, 255, 0]
b’x01x05x08x14xffx00xce^’ – [1, 5, 8, 20, 255, 0, 206, 94]
b’x08x14xffx00xce^’ – [8, 20, 255, 0, 206, 94]
As you can see the error is not consistent and sometimes the address of the slave is incorrect (3rd error).
On Linux this is what I get after using lsb_release -a
:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
Any suggestions?