Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_vout(self, rail):
mode = self._exec_page_plus_read(rail, CMD.VOUT_MODE, 1)[0]
assert mode >> 5 == 0 # assume vout_mode is always ulinear16
vout = self._exec_page_plus_read(rail, CMD.READ_VOUT, 2)
return linear_to_float(vout, mode & 0x1f)
LOGGER.warning('possibly uninitialized device')
status = [
('Current uptime', self._get_timedelta(_CORSAIR_READ_UPTIME), ''),
('Total uptime', self._get_timedelta(_CORSAIR_READ_TOTAL_UPTIME), ''),
('Temperature 1', self._get_float(CMD.READ_TEMPERATURE_1), '°C'),
('Temperature 2', self._get_float(CMD.READ_TEMPERATURE_2), '°C'),
('Fan control mode', self._get_fan_control_mode(), ''),
('Fan speed', self._get_float(CMD.READ_FAN_SPEED_1), 'rpm'),
('Input voltage', self._get_float(CMD.READ_VIN), 'V'),
('Total power', self._get_float(_CORSAIR_READ_INPUT_POWER), 'W'),
('+12V OCP mode', self._get_12v_ocp_mode(), ''),
]
for rail in [_RAIL_12V, _RAIL_5V, _RAIL_3P3V]:
name = _RAIL_NAMES[rail]
self._exec(WriteBit.WRITE, CMD.PAGE, [rail])
status.append((f'{name} output voltage', self._get_float(CMD.READ_VOUT), 'V'))
status.append((f'{name} output current', self._get_float(CMD.READ_IOUT), 'A'))
status.append((f'{name} output power', self._get_float(CMD.READ_POUT), 'W'))
self._exec(WriteBit.WRITE, CMD.PAGE, [0])
self.device.release()
LOGGER.warning('reading the +12V OCP mode is an experimental feature')
return status