From d11b3854670343e9b9e397a95ca4e1b049ef58ec Mon Sep 17 00:00:00 2001 From: ladyada Date: Sat, 30 Jun 2018 18:12:20 -0400 Subject: [PATCH] politely cope with strings of bytes --- src/busio.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/busio.py b/src/busio.py index 3523acd..0d23b33 100755 --- a/src/busio.py +++ b/src/busio.py @@ -53,6 +53,8 @@ class I2C(Lockable): return self._i2c.readfrom_into(address, buffer, stop) def writeto(self, address, buffer, start=0, end=None, stop=True): + if isinstance(buffer, str): + buffer = bytes([ord(x) for x in buffer]) if start is not 0 or end is not None: if end is None: return self._i2c.writeto(address, memoryview(buffer)[start:], stop) -- 2.49.0