We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I read a word from i2c, it is treated as big endian. However I want to read a temperature that is stored as little endian. I have solved this so:
BUS = SMBus(1) value = BUS.read_word_data(address, register) hstr = str(hex(value))[2:].rjust(4, '0') value = int('0x%s%s' % (hstr[2:], hstr[:2]), 16)
Not very elegant. Is there a native way to handle this?
The text was updated successfully, but these errors were encountered:
Slow response, sorry. but you don't need to go via strings.
little_endian_value = ((value & 0xFF) << 8) | ((value >> 8) & 0xFF)
Sorry, something went wrong.
Thanks!
No branches or pull requests
When I read a word from i2c, it is treated as big endian. However I want to read a temperature that is stored as little endian. I have solved this so:
Not very elegant.
Is there a native way to handle this?
The text was updated successfully, but these errors were encountered: