コード例 #1
0
ファイル: scpi.py プロジェクト: sixGodChan/scpi_tools
    def __init__(self, port, baud=115200):
        """
        Initializes SCPI slave device from a given port.

        Port can either be an already initialized pyserial port
        or may be a string, specifiying the port to be used.
        Special name: hamegusb, this uses the HM2008 USB interface
        """
        if ( type(port) is str):
            if (port == "hamegusb"):
                USB_PID_LIST.append(0xED72);
                self.__ser = Device(mode='b')
            else:
        # configure the serial connections (the parameters differs from device
        # to device you are connecting to)
                self.__ser = serial.Serial(
                   port=port,
                   baudrate=baud,
                   parity=serial.PARITY_NONE,
                   stopbits=serial.STOPBITS_ONE,
                   bytesize=serial.EIGHTBITS
                )
        else:
            self.__ser = port
        # Try at least an *IDN? command, if this fails
        # most likely nothing will work on the device at all.
        self.__device_id = self.query_string("*IDN?", 1);
        print "Found >>"+self.__device_id
コード例 #2
0
ファイル: scpi.py プロジェクト: ptwz/scpi_tools
    def __init__(self, port, baud=115200):
        """
        Initializes SCPI slave device from a given port.

        Port can either be an already initialized pyserial port
        or may be a string, specifiying the port to be used.
        Special name: hamegusb, this uses the HM2008 USB interface
        """
        if type(port) is str:
            if port == "hamegusb":
                USB_PID_LIST.append(0xED72)
                self.__ser = Device(mode="b")
            else:
                # configure the serial connections (the parameters differs from device
                # to device you are connecting to)
                self.__ser = serial.Serial(
                    port=port,
                    baudrate=baud,
                    parity=serial.PARITY_NONE,
                    stopbits=serial.STOPBITS_ONE,
                    bytesize=serial.EIGHTBITS,
                )
        else:
            self.__ser = port
        # Try at least an *IDN? command, if this fails
        # most likely nothing will work on the device at all.
        self.__device_id = self.query_string("*IDN?", 1)
        print "Found >>" + self.__device_id
コード例 #3
0
    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)
コード例 #4
0
import paho.mqtt.client as mqtt
import json
from pylibftdi import Device, USB_PID_LIST, USB_VID_LIST

from config import MQTT_HOST

USB_VID_LIST.append(0x1321)
USB_PID_LIST.append(0x1001)

dev = Device(mode='t')
dev.baudrate = 57600
dev.open()


def run_command(cmd):
    if cmd != '':
        dev.flush()
        print('TX: ' + cmd)
        dev.writelines(cmd + '\r')
        out = ''
        while out == '':
            out = dev.readline()
        print('RX: ' + out)


def to_command(obj):
    cmds = []
    for input in obj:
        cmd = 'xpgn(' + input + ',*)='
        # print('Input: ' + input)
        # print(obj[input])
コード例 #5
0
#!/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}")
コード例 #6
0
ファイル: pyl08.py プロジェクト: Noah1989/pyl08
from pylibftdi import USB_PID_LIST, SerialDevice
from ctypes import byref

USB_PID_LIST.append(0x6015)
BITMODE_CBUS = 0x20


dev = SerialDevice()

dev.baudrate = 46875

# programming voltage
dev.rts = 1

# reset
dev.ftdi_fn.ftdi_set_bitmode(0x40, BITMODE_CBUS)

dev.close()
コード例 #7
0
from pylibftdi.examples import list_devices as ld
from pylibftdi import USB_VID_LIST, USB_PID_LIST


class TST001:
    def __init__(self):
        print('hi')


if __name__ == '__main__':
    USB_PID_LIST.append(0xfaf0)
    print(ld.get_ftdi_device_list())
    print(map(hex, USB_VID_LIST))
    print(map(hex, USB_PID_LIST))