Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def atcab_selftest(self, mode, param2=0):
if self._device != "ATECC608A":
raise ATCA_EXCEPTIONS.UnsupportedDeviceError("atcab_selftest")
packet = ATCAPacket(
opcode=ATCA_CONSTANTS.ATCA_SELFTEST,
param1=mode,
param2=param2
)
self.execute(packet)
RSP_DATA_IDX = ATCA_CONSTANTS.ATCA_RSP_DATA_IDX
return packet[RSP_DATA_IDX] & int(not mode) == ATCA_STATUS.ATCA_SUCCESS
def __init__(
self,
bus=machine.I2C(1, freq=133000),
address=I2C_ADDRESS, retries=RX_RETRIES):
if address not in bus.scan():
raise ATCA_EXCEPTIONS.NoDevicesFoundError()
self._bus = bus
self._address = address
self._retries = retries
try:
self._device = SUPPORTED_DEVICES[self.atcab_info()[1+2]]
except KeyError:
raise ATCA_EXCEPTIONS.UnsupportedDeviceError()