# ChatGPT wrote this import usb.core import usb.util import argparse class CyberJack: def __init__(self): self.dev = usb.core.find(idVendor=0x0c4b, idProduct=0x0501) if self.dev is None: raise ValueError("REINER SCT cyberJack comfort not found") cfg = self.dev.get_active_configuration() intf = usb.util.find_descriptor(cfg, bInterfaceNumber=0) if self.dev.is_kernel_driver_active(intf.bInterfaceNumber): raise RuntimeError("Device is bound to a Kernel driver.") usb.util.claim_interface(self.dev, intf.bInterfaceNumber) self.ep_out = usb.util.find_descriptor(intf, bEndpointAddress=0x02) self.ep_in = usb.util.find_descriptor(intf, bEndpointAddress=0x81) def set_brightness(self, value: int): if not 0 <= value <= 255: raise ValueError("value must be in 0..255") prefix = "6b07" # no idea what this is about unknown1 = "00000000" sequence_counter = "11" # the device's reply will contain this, but I do not check or care; is one byte and rolls over unknown2 = "00000001000001" # the lowest byte could be the upper byte of the key key = "3300" # the lower byte could actually be the upper byte of the value value_hex = f"{value:02x}" data = prefix + unknown1 + sequence_counter + unknown2 + key + value_hex bytes_sent = self.dev.write(self.ep_out.bEndpointAddress, bytes.fromhex(data), timeout=100) resp = self.dev.read(self.ep_in.bEndpointAddress, 20, timeout=2000) return resp if __name__ == "__main__": parser = argparse.ArgumentParser(description="Set CyberJack brightness") parser.add_argument("--brightness", type=int, required=True, help="brightness 0-255") args = parser.parse_args() cyberjack = CyberJack() resp = cyberjack.set_brightness(args.brightness)