def __init__(self): QObject.__init__(self) # Clear the FTDI VID and PID lists and replace them with the Styx # PID and VID, so we will only match Styx boards USB_VID_LIST.clear() USB_VID_LIST.append(STYX_VID) USB_PID_LIST.clear() USB_PID_LIST.append(STYX_PID) self._dev = None self._poll_msgs = [] self._tx_queue = queue.Queue() self._rx_bytes = b'' self._poll_ctr = 0 self._timer = QTimer(None) self._timer.timeout.connect(self._service) self._timer.start(POLL_PERIOD_MS)
#!/usr/bin/env python import random import time from pylibftdi import Device, USB_PID_LIST, USB_VID_LIST RANDOM = False INPUT = False STYX_VID = 0x2a19 STYX_PID = 0x1007 USB_VID_LIST.clear() USB_VID_LIST.append(STYX_VID) USB_PID_LIST.clear() USB_PID_LIST.append(STYX_PID) SLIP_END = b'\xC0' SLIP_ESC = b'\xDB' SLIP_ESC_END = b'\xDC' SLIP_ESC_ESC = b'\xDD' def translate(msg): write = (msg[0] >> 7) == 1 address_group = (msg[0] & 127) address = int.from_bytes(msg[1:3], byteorder='big') data = int.from_bytes(msg[3:5], byteorder='big') print(f"Write: {write}") print(f"Address group: {address_group}") print(f"Address: {address}") print(f"Data: {data}")