def _read_device_state():
"""INTERNAL. Read from the I2C bus to get the current state of the pulse. Caller should handle exceptions"""
try:
PTLogger.debug("Connecting to bus...")
i2c_bus = SMBus(_bus_id)
current_state = i2c_bus.read_byte(_device_addr) & 0x0F
return int(current_state)
except:
PTLogger.warning("Error: There was a problem reading from the device")
# Best to re-raise as we can't recover from this
raise
评论列表
文章目录