kplindegaard / smbus2

A drop-in replacement for smbus-cffi/smbus-python in pure Python
MIT License
243 stars 68 forks source link

Invalid i2c_msg created from a string in Python 3.x character value >= 128 #32

Closed kplindegaard closed 5 years ago

kplindegaard commented 5 years ago

This does not work properly in Python 3.x in version 0.2.2 and earlier

from smbus2 import i2c_msg

address = 80
msg1 = i2c_msg.write(address,  'ABC\xff')  # Notice value 0xFF (255) as last value
msg2 = i2c_msg.write(address, [65, 66, 67, 255])  # Same same, just using list instead
msg1.len == msg2.len  # False in Python 3.x !!