Decimal to hexadecimal conversion problem

I want to exchange data with a serial port (usb). To do this, I need to send a hexadecimal value to the board, for example, my code:

elements = [133,128,128,128] registerValue = bytearray(elements) ser.write(registerValue[0:4]) print (registerValue[0:5] , "here") 

and he will print:

 bytearray(b'\x85\x80\x80\x80') here 

which is correct in my case, but I also need to have [130, 50] when I do the same, instead of

 bytearray(b'\x82\x32') here 

he will print

 bytearray(b'\x822') here 

I tried to understand the code and it seems like it will return ascii value can anyone help me with this problem?

+5
source share

Source: https://habr.com/ru/post/1276127/


All Articles