Пример #1
0
def get_ftdi_device_list():
    dev_list = []
    for device in Driver().list_devices():
        dev_info = device
        vendor, product, serial = dev_info  # device must always be this triple
        dev_list.append(serial)
    return dev_list
Пример #2
0
def list_devices():
    print "Vendor\t\tProduct\t\t\tSerial"
    dev_list = []
    for device in Driver().list_devices():
        device = map(lambda x: x.decode('latin1'), device)
        vendor, product, serial = device
        print "%s\t\t%s\t\t%s" % (vendor, product, serial)
Пример #3
0
 def run(self):
     while self.parent.run:
         time.sleep(.5)
         new_devices = {}
         try:
             for device in Driver().list_devices():
                 # vendor, product, serial = map(lambda x: x.decode('latin1'), device)
                 vendor, product, serial = map(lambda x: x, device)
                 new_devices[serial] = (vendor, product)
                 if not serial in self.ftdi_devices:
                     wx.CallAfter(dispatcher.send,
                                  signal="USBMonitor",
                                  sender=self,
                                  action="add",
                                  vendor=vendor,
                                  product=product,
                                  serial=serial)
             for serial in self.ftdi_devices:
                 if not serial in new_devices:
                     wx.CallAfter(dispatcher.send,
                                  signal="USBMonitor",
                                  sender=self,
                                  action="remove",
                                  vendor=self.ftdi_devices[serial][0],
                                  product=self.ftdi_devices[serial][1],
                                  serial=serial)
         except FtdiError as e:
             if sys.exc_info()[0] == LibraryMissingError:
                 wx.LogError(str(e))
                 break
         except LibraryMissingError as e:
             wx.LogError(str(e))
             break
         self.ftdi_devices = new_devices
Пример #4
0
def GetFtdiDevices():
    dev_list = {}
    for device in Driver().list_devices():
        dev_info = map(lambda x: x.decode('latin1'), device)
        vendor, product, serial = dev_info
        dev_list[serial] = (vendor, product)
    return dev_list
Пример #5
0
def GetFtdiDevices():
    dev_list = {}
    for device in Driver().list_devices():
        dev_info = device
        vendor, product, serial = dev_info
        dev_list[serial] = (vendor, product)
    return dev_list
Пример #6
0
 def load_hardware(self):
   self.__device_type = None
   for device in Driver().list_devices():
     vendor, product, self.__device = [x.decode('latin1') for x in device]
     self.__device_type = 'Serial' if product.endswith('UART') else 'BitBang'
     logger.debug('Found switch board {}, {}, {}, of type {}'.format(vendor,product,self.__device,self.__device_type))
     break # For now, we only support 1 switch board!
Пример #7
0
def return_device_serial_number():
    # print "Vendor\t\tProduct\t\t\tSerial"
    serial = None
    for device in Driver().list_devices():
        device = map(lambda x: x.decode("latin1"), device)
        vendor, product, serial = device
        # print "%s\t\t%s\t\t%s" % (vendor, product, serial)
    return serial
Пример #8
0
 def __load_ftdi_device(self):
     for device in Driver().list_devices():
         vendor, product, self.device = map(lambda x: x.decode('latin1'),
                                            device)
         self.device_type = 'Serial' if product.endswith(
             'UART') else 'BitBang'
         logger.debug('Found switch board %s, %s, %s, of type %s' %
                      (vendor, product, self.device, self.device_type))
         break  # For now, we only support 1 switch board!
Пример #9
0
def list_devices():
    print('%-12s' % 'Vendor',
          '%-35s' % 'Product',
          '%-25s' % 'Serial',
          sep='\t')
    print(
        '--------------------------------------------------------------------')
    dev_list = []
    for vendor, product, serial in Driver().list_devices():
        print('%-12s' % vendor, '%-35s' % product, '%-25s' % serial, sep='\t')
Пример #10
0
def get_ftdi_device_list():
    """
    return a list of lines, each a colon-separated
    vendor:product:serial summary of detected devices
    """
    dev_list = []
    for device in Driver().list_devices():
        # device must always be this triple
        vendor, product, serial = device
        dev_list.append("%s:%s:%s" % (vendor, product, serial))
    return dev_list
Пример #11
0
def get_ftdi_device_list():
    """
    return a list of lines, each a colon-separated
    vendor:product:serial summary of detected devices
    """
    dev_list = []
    for device in Driver().list_devices():
        # list_devices returns bytes rather than strings
        dev_info = map(lambda x: x.decode('latin1'), device)
        # device must always be this triple
        vendor, product, serial = dev_info
        dev_list.append("%s:%s:%s" % (vendor, product, serial))
    return dev_list
Пример #12
0
 def _scan_relays(callback = None, **kwargs):
   device_nr = 0
   for (_, _, serial) in Driver().list_devices():
     device_nr += 1
     # We have by default 4 switches..... not sure...
     amount_sockets = 4
     for x in range(amount_sockets):
       # Explicit None value for ID. This will force to generate a new ID based on the address
       yield terrariumRelay(None,
                            terrariumRelayFTDI.HARDWARE,
                            f'{x+1},{serial}',
                            f'{terrariumRelayFTDI.NAME} device nr: {device_nr}({serial}) socket: {x+1}',
                            callback=callback)
Пример #13
0
  def load_hardware(self):
    address = self.__get_address()

    self.__device_type = None
    counter = 1
    for device in Driver().list_devices():
      if counter != address[1]:
        counter += 1
        continue

      vendor, product, self.__device = [x for x in device]
      self.__device_type = 'Serial' if product.endswith('UART') else 'BitBang'
      logger.debug('Found switch board {}, {}, {}, of type {}'.format(vendor,product,self.__device,self.__device_type))
      break # For now, we only support 1 switch board!
Пример #14
0
def reset_device():
    print "locating device..."
    found = False
    while not found:
        for device in Driver().list_devices():
            device = map(lambda x: x.decode('latin1'), device)
            vendor, product, serial = device
            print product
            if product == PRODUCT:
                found = True
                break
        else:
            retry()
    print "...done"
Пример #15
0
def getFTDIDevicesFromSystem():
    global vendor
    global product
    global serial

    dev_list = []
    for device in Driver().list_devices():
        # list_devices returns bytes rather than strings
        dev_info = map(lambda x: x.decode('latin1'), device)
        # device must always be this triple
        vendor, product, serial = dev_info

        if vendor == "FTDI":
            dev_list.append("%s:%s:%s" % (vendor, product, serial))
        return dev_list
Пример #16
0
  def _load_hardware(self):
    # Address value = Switch_number,board_serial (optional). When board_serial is missing, use the first found device and update the address....
    address = self._address

    number_mode = terrariumUtils.is_float(address[1])
    counter = 1
    for (_, device_type, serial) in Driver().list_devices():
      # Loop until we reatch the number (amount) or serial that is entered
      if (number_mode and counter != address[1]) or (not number_mode and address[1] != serial):
        counter += 1
        continue

      device = serial
      device_type = terrariumRelayFTDI.SERIAL if device_type.lower().endswith('uart') else terrariumRelayFTDI.BITBANG

      self.address = f'{address[0]},{device}'

      return (serial,device_type)
Пример #17
0
def GetFtdiDevices():
    # devices = ftd.listDevices()
    # dev_list = {}
    # i = 0
    # ftd.createDeviceInfoList()
    # for device in devices:
    # 	dev_info_detail = ftd.getDeviceInfoDetail(i, False)
    # 	i = i + 1
    # 	serial = dev_info_detail.get("serial")
    # 	vendor = dev_info_detail.get("id")
    # 	product = dev_info_detail.get("description")
    # 	dev_list[serial] = (vendor, product)
    # return dev_list

    dev_list = {}
    for device in Driver().list_devices():
        dev_info = map(lambda x: x.decode('latin1'), device)
        # dev_info = map(lambda x: x, device)
        vendor, product, serial = dev_info
        dev_list[serial] = (vendor, product)
    return dev_list
Пример #18
0
def list_serial_only():
    # print("Vendor\t\tProduct\t\t\tSerial")
    for device in Driver().list_devices():
        device = map(lambda x: x, device)
        vendor, product, serial = device
        print("%s" % serial)
Пример #19
0
 def devlist(
     self
 ):  # should really be done outside of this script; but I'll just put it here too. SUDO PRIVILEGES NEEDED TO WORK, OTHERWISE LIST COMES BACK EMPTY.
     return Driver().list_devices()
Пример #20
0
 def __init__(self):
     self.driver = Driver()
     self.bb = None
     self.comport = None
from pylibftdi import Driver

for dev in Driver().list_devices():
    print(dev)

Пример #22
0
#! /usr/bin/python

import sys, os

#import pylibftdi
from pylibftdi import Driver, Device

try:
  dev_list  = Driver().list_devices()
  if len(dev_list) != 0:
    print "\n\nFollowing devices found: \n"
    for device_ in dev_list:
      print device_
    
    dev = Device(device_id="FTZ17IRO", mode='b', interface_select=2)
    
    dev.open()
    
    tx_data = bytearray(range(0, 256))
    dev.write(tx_data)
    
    rx_data = bytearray(dev.read(257))#, timeout = 0))
    
    if len(rx_data) == 256 :
      print "\n\n[Test] Test 1 Passed: Sent 256 bytes of data, received 256 bytes of data"
    
    failed = False
    for i in range(256):
      if ((tx_data[i]+1)%256) != rx_data[i]:
        print "[Test] Test 2: Data verification failed! , tx_data : ", tx_data[i], " =/= rx_data : ", rx_data[i]
        failed = True