I have following code which try to convert an integer value to two individual bytes in a bytearray.
value = 13183
print("Initial value: ", value)
val_msb = (value >> 8) & 0xFF
val_lsb = value & 0xFF
print("Value MSB:", val_msb, "Value LSB:", val_lsb)
val_arr = bytearray(2);
val_arr[0] = val_msb
val_arr[1] = val_lsb
print("Byte array:", val_arr)
Getting following output which is not matching with the expectation.
Initial value: 13183
Value MSB: 51 Value LSB: 127
Byte array: bytearray(b'3\x7f')
I expect it to produce final bytearray as Byte array: bytearray(b'x33\x7f')