I am retrieving bytes of data from an IC2 device using the read_i2c_block_data function. Within this block of data are signed 16-bit values that I want to display. I am able to print out the value correctly using the following:
print ("PC12 : %d mW" % int.from_bytes((return_data[5],return_data[6]), byteorder='little', signed=True))
Though, I have been trying print out the value using the following, which doesn't work and I don't know why. I am curious to why I can't get it to work.
print ("PC12 : %d mW" % int.from_bytes(return_data[5:6], byteorder='little', signed=True))
Does anyone know what I am doing wrong? I thought I could specify the range in the from_bytes function.
Thanks, Mark
return_data?