Search code examples
pythonhex

How to join two Hex values c1 and 32 to get decimal of 49458?


im back and have made some progress :)

im trying to join two hex values

for example: c1 and 32. In decimal it should be 49458 this is my python code thus far.

ComPort = serial.Serial("COM3", baudrate=9600,bytesize=8,parity='N',stopbits=1, timeout=1,)

Temphex = b'\x01\x03\x00\x00\x00\x02\xC4\x0B'

ComPort.write(Temphex)

temp = ComPort.read(7)
t=" ".join(["{:02x}".format(x) for x in temp])

print(t)

#parse

t1=(t[12:14])
t2=(t[18:20])
print (t1,t2)

ComPort.close()

this is what im getting back

t1 = 01 03 04 0a c1 14 32

t2 = c1 32

Solution

  • >>> print( int( (t[12:14]+t[18:20]),16) )
    49458