Пример #1
0
    def __init__(self):
        """RTC_INTERFACE Interface to the real-time control device. As far as
        possible this object is designed to be state-less. (The exception
        being the parameter list.)"""

        # Set the end points and interface of interest
        self.intf = 0
        self.ep_out = 1
        self.ep_in = 129

        # Get the device
        self.context = usb1.LibUSBContext()
        self.dev = self.context.openByVendorIDAndProductID(0x0123, 0x4567)
        if self.dev is None:
            raise rtc_exception("RTC device not found")
        self.dev.claimInterface(self.intf)

        # The timeout for any USB communications
        self.timeout = 5000

        # Get the parameter names
        self.get_par_list()

        # A helper class for getting/setting parameters
        self.par = rtc_parameters(self)
Пример #2
0
def main(bus=None, device_address=None):
    context = usb1.LibUSBContext()
    for md in libnetmd.iterdevices(context,
                                   bus=bus,
                                   device_address=device_address):
        md_iface = libnetmd.NetMDInterface(md)
        md_iface.eraseDisc()
Пример #3
0
def main(bus=None, device_address=None, track_range=None):
    context = usb1.LibUSBContext()
    for md in libnetmd.iterdevices(context,
                                   bus=bus,
                                   device_address=device_address):
        md_iface = libnetmd.NetMDInterface(md)
        MDDump(md_iface, track_range)
Пример #4
0
def main() -> None:
    ctx = usb1.LibUSBContext()
    usb_dev = ctx.openByVendorIDAndProductID(0x0547, 0x4d33)

    if not usb_dev:
        _error('Device not found (0x0547, 0x4d33)')

    dev = ScopetekDevice(usb_dev)

    dev.start()
Пример #5
0
def download(filename,title,wireformat=libnetmd.WIREFORMAT_PCM,bus=None,device_address=None):


    print "Download request received for file %s and title %s" % (filename,title)
    context = usb1.LibUSBContext()
    for md in libnetmd.iterdevices(context, bus=bus,
                                   device_address=device_address):
        md_iface = libnetmd.NetMDInterface(md)

        mdtrack = MDTrack(filename,title,wireformat)
        DownloadHack(md_iface,mdtrack)
Пример #6
0
def main(bus=None,
         device_address=None,
         ext='ogg',
         track_range=None,
         title=None):
    context = usb1.LibUSBContext()
    for md in libnetmd.iterdevices(context,
                                   bus=bus,
                                   device_address=device_address):
        md_iface = libnetmd.NetMDInterface(md)
        try:
            MDDump(md_iface, ext, track_range, title)
        finally:
            md_iface.stop()
Пример #7
0
    def __init__(self, i2caddress=0x33, refreshRate=3):
        """
        Initialize and open connection to USB2FIR.
        """
        ctx = usb1.LibUSBContext()
        self.usbdev = ctx.getByVendorIDAndProductID(USB2FIR_VID, USB2FIR_PID)
        self.usbhandle = self.usbdev.open()
        self.usbhandle.claimInterface(0)
        self.i2caddress = i2caddress

        data = self.read_memory(0x2400, 832 * 2)
        eepromdata = np.frombuffer(data, '>u2')
        self.commonParameters = MLXCommonParameters(eepromdata)

        self.start_bfmode(refreshRate)
Пример #8
0
    def get_usb_device(self, serialnumber=None):
        """
        Get USB device matching VID and PID and if given also check the USB serial number.
        :rtype: USBDeviceHandle
        :param serialnumber: USB serial number
        :type serialnumber: string       
        """
        ctx = usb1.LibUSBContext()

        for device in ctx.getDeviceIterator():
            if device.getVendorID() == I2C_MP_USB_VID and device.getProductID(
            ) == I2C_MP_USB_PID:
                if serialnumber is None:
                    return device
                elif device.getSerialNumber() == serialnumber:
                    return device
Пример #9
0
    def __init__(self, vid=0x221A, pid=0x0100, in_ep=0x82, out_ep=0x06):
        self.vid, self.pid = vid, pid
        self.in_ep, self.out_ep = in_ep, out_ep

        self.context = usb1.LibUSBContext()
        self.dev = self.context.openByVendorIDAndProductID(self.vid, self.pid)

        if self.dev is None:
            raise RuntimeError("device not found")

        self.write_buffer = b""
        self.read_buffer = b""

        for i in range(self.POLLRATE):
            transfer = self.dev.getTransfer()
            transfer.setBulk(self.in_ep, self.BLOCKSIZE, self._read_callback,
                             None, 0)
            transfer.submit()

        # clear leftover data
        time.sleep(0.1)
        self.read_buffer = b""
Пример #10
0
    def __init__(self, driver):
        # Keep a reference to the driver:
        self._driver = driver

        # Open and set the USB configuration of the controller:
        self._context = usb1.LibUSBContext()
        self._device_handle = self._find_and_open_device()
        self._device = self._device_handle.getDevice()

        self._configuration = self._device[0]
        self._interface = self._configuration[0]
        self._setting = self._interface[0]

        self._device_handle.setConfiguration( \
          self._configuration.getConfigurationValue())

        self._device_handle.claimInterface(0)

        # Initialise state:
        self._last_transmitted_frame = 0xffffffffL
        self._last_enqueued_frame = 0xffffffffL
        self._last_dequeued_frame = 0xffffffffL

        self._enqueue_in_progress = False

        self._last_inputs = 0L
        self._last_outputs = 0L
        self._last_state = None
        self._last_state_details = None
        self._last_state_callback = None

        self._running = True
        self._run_failure = None

        self._timers_heap = []

        self._driver_initialised = False
Пример #11
0
def main(bus=None,
         device_address=None,
         ext='wav',
         track_range=None,
         title=None):
    context = usb1.LibUSBContext()
    try:
        for md in libnetmd.iterdevices(context,
                                       bus=bus,
                                       device_address=device_address):
            md_iface = libnetmd.NetMDInterface(md)

            try:
                MDDump(md_iface, ext, track_range, title)
            finally:

                md_iface.stop()

    except IOError:
        print 'no MD-- connect a NetMD Device'
        return

    finally:
        return
Пример #12
0
def main(bus=None, device_address=None, show_uuids=False):
    context = usb1.LibUSBContext()
    for md in libnetmd.iterdevices(context,
                                   bus=bus,
                                   device_address=device_address):
        listMD(md, show_uuids)
Пример #13
0
def main(bus=None, device_address=None):
    context = usb1.LibUSBContext()
    for md in libnetmd.iterdevices(context,
                                   bus=bus,
                                   device_address=device_address):
        MDctl(md)
Пример #14
0
#!/usr/bin/env python
# Source: http://paste.jvnv.net/raw/XdBz7
# zyp, March 2013
# Used for dumping tracewswo output via BMP

import usb1, libusb1
import time, struct

ctx = usb1.LibUSBContext()

dev = ctx.getByVendorIDAndProductID(0x1d50, 0x6018)

if not dev:
    print 'Device not found.'
    exit(1)

handle = dev.open()
handle.claimInterface(5)


def transfer_cb(t):
    print t.getBuffer()[:t.getActualLength()].encode('hex')

    return True


th = usb1.USBTransferHelper()
th.setEventCallback(libusb1.LIBUSB_TRANSFER_COMPLETED, transfer_cb)

t = handle.getTransfer()
t.setBulk(0x85, 64, th)