def setup_keyplus_label(self): try: self.device.open() settingsInfo = protocol.get_device_info(self.device) firmwareInfo = protocol.get_firmware_info(self.device) self.device.close() except TimeoutError as err: # Incase opening the device fails raise Exception ("Error Opening Device: {} | {}:{}" .format( self.device.path, self.device.vendor_id, self.device.product_id ), file=sys.stderr ) if settingsInfo.crc == settingsInfo.computed_crc: build_time_str = protocol.timestamp_to_str(settingsInfo.timestamp) self.label = QLabel('{} | {} | Firmware v{}.{}.{}\n' 'Device id: {}\n' 'Serial number: {}\n' 'Last time updated: {}' .format( self.device.manufacturer_string, self.device.product_string, 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 = QLabel('??? | ??? | 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 = QLabel('??? | ??? | 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 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 setup_keyplus_label(self): try: self.device.open() settingsInfo = protocol.get_device_info(self.device) firmwareInfo = protocol.get_firmware_info(self.device) self.device.close() except TimeoutError as err: # Incase opening the device fails raise Exception("Error Opening Device: {} | {}:{}".format( self.device.path, self.device.vendor_id, self.device.product_id), file=sys.stderr) self.valid = True build_time_str = protocol.timestamp_to_str(settingsInfo.timestamp) self.label = QLabel('{} | {} | Firmware v{}.{}.{}\n' 'Device id: {}\n' 'Serial number: {}\n' 'Last time updated: {}'.format( self.device.manufacturer_string, self.device.product_string, firmwareInfo.version_major, firmwareInfo.version_minor, firmwareInfo.version_patch, settingsInfo.id, self.device.serial_number, build_time_str))
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) device.close() header = ["Attribute", "Value"] device_settings = [ ("Device ID", settingsInfo.id), ("Device name", settingsInfo.name.decode('utf-8')), ("Device serial number", device.serial_number), ("Last layout update", protocol.timestamp_to_str(settingsInfo.timestamp)), ("Default report mode", protocol.report_mode_to_str(settingsInfo.default_report_mode)), ("Matrix scan mode", protocol.scan_mode_to_str(settingsInfo.scan_mode)), ("Matrix columns", settingsInfo.col_count), ("Matrix rows", settingsInfo.row_count), ("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", protocol.has_fw_support_scanning(firmwareInfo)), ("Support scanning col to row", protocol.has_fw_support_scanning_col_row(firmwareInfo)), ("Support scanning row to col", protocol.has_fw_support_scanning_row_col(firmwareInfo)), ("Media keys", protocol.has_fw_support_key_media(firmwareInfo)), ("Mouse keys", protocol.has_fw_support_key_mouse(firmwareInfo)), ("Layer keys", protocol.has_fw_support_key_layers(firmwareInfo)), ("Sticky keys", protocol.has_fw_support_key_sticky(firmwareInfo)), ("Tap keys", protocol.has_fw_support_key_tap(firmwareInfo)), ("Hold keys", protocol.has_fw_support_key_hold(firmwareInfo)), ("Support 6KRO", protocol.has_fw_support_6kro(firmwareInfo)), ("Support NKRO", protocol.has_fw_support_key_hold(firmwareInfo)), ("Support indicator LEDs", protocol.has_fw_support_led_indicators(firmwareInfo)), ("Support LED backlighting", protocol.has_fw_support_led_backlighting(firmwareInfo)), ("Support ws2812 LEDs", protocol.has_fw_support_led_ws2812(firmwareInfo)), ("Support USB", protocol.has_fw_support_usb(firmwareInfo)), ("Support nRF24 wireless", protocol.has_fw_support_wireless(firmwareInfo)), ("Support Unifying", protocol.has_fw_support_unifying(firmwareInfo)), ("Support I2C", protocol.has_fw_support_i2c(firmwareInfo)), ("Support Bluetooth", protocol.has_fw_support_bluetooth(firmwareInfo)), ] self.info_window = DeviceInformationWindow(self, header, device_settings, firmware_settings) self.info_window.setModal(True) self.info_window.exec_() self.deviceListWidget.updateList()