def _write_device_state(state):
"""INTERNAL. Send the state bits across the I2C bus"""
try:
PTLogger.debug("Connecting to bus...")
i2c_bus = SMBus(_bus_id)
state_to_send = 0x0F & state
PTLogger.debug("Writing new state: " + _get_bit_string(state_to_send))
i2c_bus.write_byte_data(_device_addr, 0, state_to_send)
result = _verify_device_state(state_to_send)
if result is True:
PTLogger.debug("OK")
else:
PTLogger.warning("Error: New state could not be verified")
return result
except:
PTLogger.warning("Error: There was a problem writing to the device")
return False
评论列表
文章目录