From 125b33954b5a46c96b1f614ded8a8bbb0ca444db Mon Sep 17 00:00:00 2001 From: Thomas Juerges <203795-tjuerges@users.noreply.gitlab.com> Date: Tue, 9 Feb 2021 17:48:00 +0100 Subject: [PATCH] Add platform dependency when importing libi2c --- i2c/I2C.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/i2c/I2C.py b/i2c/I2C.py index 1abf950..10c89b0 100644 --- a/i2c/I2C.py +++ b/i2c/I2C.py @@ -1,4 +1,5 @@ -import pylibi2c; +if os.sys.platform is 'linux': + import pylibi2c; import time import logging #bus = pylibi2c.I2CDevice('/dev/i2c-1' @@ -25,7 +26,7 @@ def I2C1server(addr,data,reg=None,read=0): bus.ioctl_write(0,str(bytearray([reg]))) data[:]=[int(x) for x in bus.ioctl_read(0,length)] else: - if reg is None: + if reg is None: bus.iaddr_bytes=0 reg=0; bus.ioctl_write(reg,str(bytearray(data))) -- GitLab