def setup_keyplus_label(self): self.device.open() settingsInfo = protocol.get_device_info(self.device) firmwareInfo = protocol.get_firmware_info(self.device) errorInfo = protocol.get_error_info(self.device) self.has_critical_error = errorInfo.has_critical_error() self.device.close() if settingsInfo.crc == settingsInfo.computed_crc: build_time_str = protocol.timestamp_to_str(settingsInfo.timestamp) device_name = settingsInfo.device_name_str() device_name = device_name.strip('\x00').strip('\xff').strip() self.label.setText('{} | {} | Firmware v{}.{}.{}\n' 'Device id: {}\n' 'Serial number: {}\n' 'Last time updated: {}'.format( self.device.manufacturer_string, device_name, firmwareInfo.version_major, firmwareInfo.version_minor, firmwareInfo.version_patch, settingsInfo.id, self.device.serial_number, build_time_str)) else: # CRC doesn't match if settingsInfo.is_empty: self.label.setText('??? | ??? | Firmware v{}.{}.{}\n' 'Warning: Empty settings!\n' 'Serial number: {}\n'.format( firmwareInfo.version_major, firmwareInfo.version_minor, firmwareInfo.version_patch, self.device.serial_number, )) else: # corrupt settings in the flash build_time_str = protocol.timestamp_to_str( settingsInfo.timestamp) self.label.setText('??? | ??? | Firmware v{}.{}.{}\n' 'WARNING: Settings are uninitialized\n' 'Serial number: {}\n'.format( firmwareInfo.version_major, firmwareInfo.version_minor, firmwareInfo.version_patch, self.device.serial_number, ))
def infoDeviceHandler(self, device_path): device = self.tryOpenDevicePath(device_path) if device == None: return settingsInfo = protocol.get_device_info(device) firmwareInfo = protocol.get_firmware_info(device) rfInfo = protocol.get_rf_info(device) if firmwareInfo.has_at_least_version('0.2.2'): errorInfo = protocol.get_error_info(device) else: errorInfo = None device.close() header = ["Attribute", "Value"] device_settings = [ ("Device ID", settingsInfo.id), ("Device name", settingsInfo.device_name_str()), ("Device serial number", device.serial_number), ("Last layout update", settingsInfo.timestamp_str()), ("Default report mode", settingsInfo.default_report_mode_str()), ("Matrix scan mode", settingsInfo.scan_mode_str()), ("Matrix columns", settingsInfo.col_count), ("Matrix rows", settingsInfo.row_count), ("Settings stored CRC", hex(settingsInfo.crc)), ("Settings computed CRC", hex(settingsInfo.computed_crc)), ("USB", not (settingsInfo.has_usb_disabled() or not firmwareInfo.has_fw_support_usb())), ("I2C", not (settingsInfo.has_i2c_disabled() or not firmwareInfo.has_fw_support_i2c())), ("nRF24 wireless", not (settingsInfo.has_nrf24_disabled() or not firmwareInfo.has_fw_support_nrf24())), ("Unifying mouse", not (settingsInfo.has_unifying_mouse_disabled() or not firmwareInfo.has_fw_support_unifying())), ("Bluetooth", not (settingsInfo.has_bluetooth_disabled() or not firmwareInfo.has_fw_support_bluetooth())), ("RF pipe0", binascii.hexlify(rfInfo.pipe0).decode('ascii')), ("RF pipe1", binascii.hexlify(rfInfo.pipe1).decode('ascii')), ("RF pipe2", "{:02x}".format(rfInfo.pipe2)), ("RF pipe3", "{:02x}".format(rfInfo.pipe3)), ("RF pipe4", "{:02x}".format(rfInfo.pipe4)), ("RF pipe5", "{:02x}".format(rfInfo.pipe5)), ("RF channel", str(rfInfo.channel)), ("RF auto retransmit count", str(rfInfo.arc)), ("RF data rate", protocol.data_rate_to_str(rfInfo.data_rate)), ] firmware_settings = [ ("Firmware version", "{}.{}.{}".format(firmwareInfo.version_major, firmwareInfo.version_minor, firmwareInfo.version_patch)), ("Firmware build date", str(datetime.datetime.fromtimestamp(firmwareInfo.timestamp))), ("Firmware git hash", "{:08x}".format(firmwareInfo.git_hash)), ("Layout storage size", firmwareInfo.layout_flash_size), ("Bootloader VID", "{:04x}".format(firmwareInfo.bootloader_vid)), ("Bootloader PID", "{:04x}".format(firmwareInfo.bootloader_pid)), ("Support scanning", firmwareInfo.has_fw_support_scanning()), ("Support scanning col to row", firmwareInfo.has_fw_support_scanning_col_row()), ("Support scanning row to col", firmwareInfo.has_fw_support_scanning_row_col()), ("Media keys", firmwareInfo.has_fw_support_key_media()), ("Mouse keys", firmwareInfo.has_fw_support_key_mouse()), ("Layer keys", firmwareInfo.has_fw_support_key_layers()), ("Sticky keys", firmwareInfo.has_fw_support_key_sticky()), ("Tap keys", firmwareInfo.has_fw_support_key_tap()), ("Hold keys", firmwareInfo.has_fw_support_key_hold()), ("Support 6KRO", firmwareInfo.has_fw_support_6kro()), ("Support NKRO", firmwareInfo.has_fw_support_key_hold()), ("Support indicator LEDs", firmwareInfo.has_fw_support_led_indicators()), ("Support LED backlighting", firmwareInfo.has_fw_support_led_backlighting()), ("Support ws2812 LEDs", firmwareInfo.has_fw_support_led_ws2812()), ("Support USB", firmwareInfo.has_fw_support_usb()), ("Support nRF24 wireless", firmwareInfo.has_fw_support_nrf24()), ("Support Unifying", firmwareInfo.has_fw_support_unifying()), ("Support I2C", firmwareInfo.has_fw_support_i2c()), ("Support Bluetooth", firmwareInfo.has_fw_support_bluetooth()), ] if errorInfo: error_codes = [] for code in errorInfo.get_error_codes(): error_codes.append((errorInfo.error_code_to_name(code), code)) else: error_codes = [ ('Error codes require firmware version 0.2.2 or greater', ) ] self.info_window = DeviceInformationWindow( self, header, device_settings, firmware_settings, error_codes, ) self.info_window.setModal(True) self.info_window.exec_() self.deviceListWidget.updateList()