Example #1
0
    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,
                    )
                )
Example #2
0
    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,
                                   ))
Example #3
0
 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))
Example #4
0
    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()
Example #5
0
def print_firmware_info(device, indent="  "):
    fw_info = protocol.get_firmware_info(device)
    print(indent, "build time: ", timestamp_to_string(fw_info.timestamp))
    print(indent, "git_hash: {:08x}".format(fw_info.git_hash))
Example #6
0
    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()