I am sending one byte ("\x2b") to a device and will be receiving 1 echo byte plus 3 bytes of data("\x2b\x??\x??\x??").I am using .replace("2b","",4) to get rid of the echo byte.I need to change the 3 bytes of hex received to int(16) and name them 3 different variables that I can call separately one at a time in a calculation. Here is what I have so far.
import serial
import os
ser = serial.Serial(port="COM17", baudrate=9600)
ser.open()
ser.write("\x2b")
print int(ser.readline(4).encode("hex").replace("2b", "", 4), 16)
ser.close()
os.system("pause")
strandbytesare sequences. Just unpack asa, b, c, d = 'abcd'