def __init__(self, controller: Controller, controller_details: ControllerDetails, full_scan): """ List the nodes of the controller """ logging.info("") self.nodes = list() nodes_ids = controller_details.nodes for node_id in range(1, 234): if full_scan or bits.is_id_set(nodes_ids, node_id): node = get_node(controller, node_id) if node != None: self.nodes.append(node)
def log(self): logging.info("--- controller --") logging.info("type %s" % self.type) logging.info("version %s" % self.version) logging.info("serial API version %s" % self.serial_api_version) logging.info("home id %s" % self.home_id) logging.info("node id %d" % self.node_id) logging.info("primary %s" % self.is_primary) logging.info("SIS %s" % self.is_SIS) logging.info("chip %s" % self.chip) logging.info("manufacturer %s" % self.manufacturer) logging.info("manufacturer id %s" % self.manufacturer_id) logging.info("product type %s" % self.product_type) logging.info("product id %s" % self.product_id) logging.info( "read NVM supported %s" % bits.is_id_set(self.funcid_supported, message.FUNC_ID_NVM_EXT_READ_LONG_BUFFER[0])) logging.info( "write NVM supported %s" % bits.is_id_set(self.funcid_supported, message.FUNC_ID_NVM_EXT_WRITE_LONG_BUFFER[0]))
def test_each_bit_one_byte(self): bit_id = 1 for i in range(0, 8): bit_field = bytes([1 << i]) self.assertTrue(bits.is_id_set(bit_field, bit_id)) bit_id += 1
def test_bit_id_overflow(self): bit_field = bytes([0xFF, 0xFF]) self.assertTrue(bits.is_id_set(bit_field, 9)) self.assertTrue(bits.is_id_set(bit_field, 16)) self.assertFalse(bits.is_id_set(bit_field, 17)) self.assertFalse(bits.is_id_set(bit_field, 18))
def test_bit_not_set_last_byte(self): self.assertFalse(bits.is_id_set(bytes([0xFF, 0xEF]), 13))
def test_bit_not_set(self): self.assertFalse(bits.is_id_set(bytes([0xF7, 0xFF]), 4)) self.assertFalse(bits.is_id_set(bytes([0xFE, 0xFF]), 1))
def test_each_bit_last_byte(self): bit_id = 17 for i in range(0, 8): bit_field = bytes([0x00, 0x00, 1 << i]) self.assertTrue(bits.is_id_set(bit_field, bit_id)) bit_id += 1
def test_each_bit_middle_byte(self): bit_id = 9 for i in range(0, 8): bit_field = bytes([0x00, 1 << i, 0x00]) self.assertTrue(bits.is_id_set(bit_field, bit_id)) bit_id += 1