def _read_data(self, mode, data_type): self._send_command(_CMD_RESET) self._send_command(_CMD_SET_MODE, mode) raw_data = self._send_command(_CMD_READ) if tuple(raw_data[3:5]) != data_type: raise ExpectationNotMet('device returned incorrect data type') return raw_data[5:]
def _compute_rgb_address(self): if self._rgb_address: return # the dimm's rgb controller is typically at 0x58–0x5f candidate = self._RGB_DTIC | (self._address[2] & self._SA_MASK) # reading from any register should return 0xba if we have the right device if self._smbus.read_byte_data(candidate, self._REG_RGB_MODE) != 0xba: raise ExpectationNotMet(f'{self.bus}:{candidate:#04x} is not the RGB controller') self._rgb_address = candidate