At the first page of this forum, there is a python example of calculating the checksum.
I try to get a response from my Powermax Plus by sending the init message (PM has PowerLink enrolled), but I don't get any response from the PowerMax.
(In this example I added the prefix / checksum and postfix to the message.)
(Tried the Interface of Bart, which works fine, so hardware is ok.)
I'm not sure how to format the Hex bytes correctly (hex string, or hex byte?)
Is anyone familiar to this? My code;
Code: Select all
import time
import serial
ser = serial.Serial(
port='/dev/ttyUSB0',
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
ser.close()
ser.open()
ser.isOpen()
MSG="\x0D\xAB\x06\x00\x01\x00\x00\x00\x00\x00\x00\x00\x43\x0A\x0A"
MSG2=bytearray([0x0D,0xAB,0x06,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x0A,0x0A])
# Try HexString ---------------------------------------
ser.write(MSG)
time.sleep(2)
# Try Hex array ---------------------------------------
l = len(MSG2)
x=0
while x < l:
#print format(MSG2[x],'02X')
ser.write(format(MSG2[x],'02X'))
x+=1
ser.close()