def __init__(self, i2c, device_address, *, debug=False):
while not i2c.try_lock():<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>i2c.writeto(device_address, b'<STR_LIT>')<EOL><DEDENT>except OSError:<EOL><INDENT>try:<EOL><INDENT>result = bytearray(<NUM_LIT:1>)<EOL>i2c.readfrom_into(device_address, result)<EOL><DEDENT>except OSError:<EOL><INDENT>raise ValueError("<STR_LIT>" % device_address)<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>i2c.unlock()<EOL><DEDENT>self.i2c = i2c<EOL>self.device_address = device_address<EOL>self._debug = debug<EOL>
Try to read a byte from an address,
if you get an OSError it means the device is not there