Skip to content
Snippets Groups Projects
Commit c31e336b authored by Paulus Kruger's avatar Paulus Kruger
Browse files

Check if os=linux do not work

parent bf9879a3
No related branches found
No related tags found
No related merge requests found
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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment