Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions quick2wire/i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
from ctypes import create_string_buffer, sizeof, c_int, byref, pointer, addressof, string_at
from quick2wire.board_revision import revision

assert sys.version_info.major >= 3, __name__ + " is only supported on Python 3"
#assert sys.version_info.major >= 3, __name__ + " is only supported on Python 3"

def toBytes(seq):
v = ""
if sys.version_info.major >= 3:
v = bytes(seq)
else:
v = ''.join([chr(d) for d in seq])
return v


default_bus = 1 if revision() > 1 else 0
Expand Down Expand Up @@ -101,7 +109,8 @@ def writing(addr, byte_seq):

The bytes are passed to this function as a sequence.
"""
buf = bytes(byte_seq)
#buf = bytes(byte_seq)
buf = toBytes(byte_seq)
return _new_i2c_msg(addr, 0, create_string_buffer(buf, len(buf)))


Expand Down