From c31e336b8067b89d2d27cd21fd85b8af6566c4d5 Mon Sep 17 00:00:00 2001 From: Paulus <kruger@astron.nl> Date: Wed, 31 Mar 2021 07:58:44 +0100 Subject: [PATCH] Check if os=linux do not work --- i2c/I2C.py | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/i2c/I2C.py b/i2c/I2C.py index d3a60c9..10eddc5 100644 --- a/i2c/I2C.py +++ b/i2c/I2C.py @@ -1,5 +1,6 @@ -if os.sys.platform is 'linux': - import pylibi2c; +#import os +#if os.sys.platform is 'linux': +import pylibi2c; import time import logging #bus = pylibi2c.I2CDevice('/dev/i2c-1' @@ -68,33 +69,3 @@ def I2C4server(addr,data,reg=None,read=0): # data[0]=0 return False; - -def I2C2server(addr,data,reg=None,read=0): - try: - if read==3: - time.sleep(data[0]/1000.) - return True - logging.debug(str(("I2C2",addr,reg,data,read))) - -# print("I2C",addr,reg,data,read) -# return True; - bus=pylibi2c.I2CDevice('/dev/i2c-2',addr) - if read==1: - length=len(data) - bus.iaddr_bytes=0 - if not(reg is None): - bus.ioctl_write(0,str(bytearray([reg]))) - data[:]=[int(x) for x in bus.ioctl_read(0,length)] - else: - if reg is None: - bus.iaddr_bytes=0 - reg=0; - bus.ioctl_write(reg,str(bytearray(data))) - bus.close() - return True; - except: - if bus: bus.close() - print("I2C4 error") -# data[0]=0xff - return False; - -- GitLab