I need to take an integer (for example, -200) and change it into a hexadecimal (FF 38), then into an integer 0-255 to send via serial. The example I was given was:
-200 = hex FF38 = [hex FF] [hex 38] = [255] [56]
I've tried using struct.pack('>h', -200) but that returned the incorrect value. I also tried hex() but that returned a negative hex value that was incorrect as well.
I don't know what else I should be trying.
b'255'(three bytes) or just a as a byte:b'\xff'(single byte)?