def __init__(self):
self._os_close = os.close
# Initialize i2c interface and register it for closing on exit.
self._dev = os.open("/dev/i2c-1", os.O_SYNC | os.O_RDWR)
if self._dev < 0:
raise ImportError("i2c device not found")
else:
if fcntl.ioctl(self._dev, I2C_SLAVE, ADS111x_ADDRESS) < 0:
self._close()
raise ImportError("Failed to set up i2c address")
else:
atexit.register(self._close)
评论列表
文章目录