def __init__(self, newinstance=1, ftID=None, verbose=1, vv=0): if vv: verbose = 1 if ftID == None: print("") print( "\t\t\t- ft232h : Listing connected ftd2xx device (by Serial#):" ) print("\t\t\t\t", ftd2xx.listDevices(ft.OPEN_BY_SERIAL_NUMBER)) print( "\t\t\t- ft232h : Listing connected ftd2xx device (by description):" ) print("\t\t\t\t", ftd2xx.listDevices(ft.OPEN_BY_DESCRIPTION)) self.ftID = int( input( "\n>> Choose your device and input the list index (0 ~ ): " )) else: self.ftID = ftID if verbose: print("\t\t\t- ft232h : Opening device by given ftID:", self.ftID) self.dev = ftd2xx.open(self.ftID) if newinstance: self._bringup_configmode(verbose, vv) self._bringup_syncmpsse(verbose, vv) self._bringup_configmpsse(verbose, vv) return
def connect_ftdi(self): import ftd2xx import ftd2xx.defines as fd devices = ftd2xx.listDevices() if not self.serial_number in devices: print("No device found. Exiting...") return None else: ii = devices.index(self.serial_number) print("Initializing device...") device = ftd2xx.open(ii) device.setBaudRate(self.baud_rate) # time.sleep(50/1000) time.sleep(1) device.setDataCharacteristics(fd.BITS_8, fd.STOP_BITS_1, fd.PARITY_NONE) # device.setFlowControl() device.purge(fd.PURGE_RX | fd.PURGE_TX) # time.sleep(50/1000) time.sleep(1) device.resetDevice() time.sleep(1) device.setFlowControl(fd.FLOW_RTS_CTS, 0, 0) device.setRts() print(device.getDeviceInfo()) self.device = device
def refreshSerial(self, _=None): serialnames = ft.listDevices() if serialnames == None: serialnames = [" No Connected Devices "] self.findParam('serno').setLimits(serialnames) self.findParam('serno').setValue(serialnames[0])
def refreshSerial(self): serialnames = ft.listDevices() if serialnames == None: serialnames = [" No Connected Devices "] self.findParam('serno').setLimits(serialnames) self.findParam('serno').setValue(serialnames[0])
def con(self, sn=None): if self.ser is None: if sn is None: pdevs = ft.listDevices() if len(pdevs) > 1: new_pdevs = [] for d in pdevs: if d[-1] == ord('A'): new_pdevs.append(d) pdevs = new_pdevs if len(pdevs) > 1: raise OSError( "Multiple SAKURA-G devices found, please specify serial number" ) if len(pdevs) == 0: raise OSError("Unable to find Sakura-G") self._sn = pdevs[0] try: if isinstance(self._sn, str): self._sn = self._sn.encode('utf-8') self.dev = ft.openEx(self._sn, ft.ftd2xx.OPEN_BY_SERIAL_NUMBER) self.dev.setBitMode(0x00, 0x40) self.dev.setTimeouts(500, 500) self.dev.setLatencyTimer(2) self.ser = self except ft.ftd2xx.DeviceError as e: self.ser = None raise IOError("Unable to connect to Sakura-G {}: {}".format( self._sn, e)) try: self._scope.con(self.ser) except IOError as e: raise IOError("Openadc error")
def __init__(self): # list devices by description, returns tuple of attached devices description strings d = ftd2xx.listDevices() print d try: self.device = ftd2xx.open(0) print self.device self.set_up_device() self.configure_command(self.device, "t11001") # configure trigger time self.configure_command(self.device, "t_020") # configure trigger timeout self.configure_command(self.device, "is_07") # i2c speed 400kHz self.configure_command( self.device, "ip_0") # control pin off (device turned off) # read version time.sleep(0.005) self.device.write("v\r\n") time.sleep(0.005) if self.device.getQueueStatus() > 0: i = self.device.read(self.device.getQueueStatus()) print "version = " + i[1:] except ftd2xx.ftd2xx.DeviceError: print "Unable to open 'EM2130 device'." self.device = ftd2xx.ftd2xx.DEVICE_NOT_FOUND
def initResource(self): # 初始化资源 usbDeviceList = ftd2xx.listDevices() print usbDeviceList if len(usbDeviceList) == 0: #未找到监听 raise TestResourceInitException(u"未找到监听设备") self.monitor = ftd2xx.openEx("TJKCHTBA") self.monitor.setTimeouts(10, 10) self.start()
def __init__(self): self.device_id = ftd2xx.listDevices().index(b'A6O5BD7') self.open(self.device_id) self.device.setChars(0x00,0,0x00,1) self.device.setTimeouts(2000,20000) self.device.setLatencyTimer(0x10) self.device.setBitMode(0xbb, 0x4) self.device.setBaudRate(115200*16) self.lmk_spi_config()
def _init(self): """ :param sakura: :type SASEBOGII :return: """ import ftd2xx as ft print("[*] Sakura SETUP") # List FTDI devices if ft.listDevices() is None: print("[*] Unable to find any FTDI devices") return -1 self._print_ftdi_devices() # Select the control FPGA ("A", the control FPGA) control_fpga = self._determine_control_fpga(ft.listDevices()) result = self._connect_to_control_fpga(control_fpga) if not result: return -1
def ftdi_open(board_id, channel): """opens FTDI device function depending of the current OS""" if OS == 'Linux': return pylibftdi.Device(device_index=board_id, interface_select=channel + 1) elif OS == 'Windows': dev_list = ftdi.listDevices() if channel: i2c_channel = next(ind for ind, dev in enumerate(dev_list) if chr(dev[-1]) == 'B') return ftdi.open(i2c_channel) else: gpio_channel = next(ind for ind, dev in enumerate(dev_list) if chr(dev[-1]) == 'A') return ftdi.open(gpio_channel)
def _print_ftdi_devices(self): """ :return: """ import ftd2xx as ft ftdi_devices = ft.listDevices() print("[*] Found the following FTDI device(s)") devnum = 0 for ftdi_device in ftdi_devices: print("FTDI device:\t {} \t {}".format( ftdi_device, ft.getDeviceInfoDetail(devnum=devnum))) devnum += 1
def connect(self): if self.deviceIndex >= 0 : print('Connecting to device with index %d'% self.deviceIndex) self.dev = ftd2xx.open(self.deviceIndex) #FT4HNA7Z self.status = 1 time.sleep(0.1) self.dev.setBitMode(0x00, 0x40) print('Device connected') elif ftd2xx.listDevices(0): print("no FTDI devices to be connected") self.messagebox.showinfo(title=None, message="Logic Analyzer was not found")
def refreshSerial(self, _=None): serialnames = ft.listDevices() if serialnames == None: serialnames = [" No Connected Devices "] for i,s in enumerate(serialnames): if isinstance(s, unicode): serialnames[i] = unicodedata.normalize('NFC', s) self.findParam('serno').setLimits(serialnames) if len(serialnames) > 1: i = 1 else: i = 0 self.findParam('serno').setValue(serialnames[i])
def refreshSerial(self, _=None): serialnames = ft.listDevices() if serialnames == None: serialnames = [" No Connected Devices "] for i, s in enumerate(serialnames): if isinstance(s, unicode): serialnames[i] = unicodedata.normalize("NFC", s) self.findParam("serno").setLimits(serialnames) if len(serialnames) > 1: i = 1 else: i = 0 self.findParam("serno").setValue(serialnames[i])
def __init__(self, device=None, initbaud=38400, progbaud=1000000): vid, pid, iserial = usbutils.query_usb_id(device) devserials= ftd2xx.listDevices(); dev = None for i, sn in enumerate(devserials): if sn == iserial.encode(): dev = ftd2xx.getDeviceInfoDetail(i) break if dev == None: raise Exception(device + " not found") self.INITBAUD, self.PROGBAUD = int(initbaud), int(progbaud) self.SERIAL = iserial JennicProtocol.__init__(self)
def ftdi_open(board_id, channel, desc=None): """opens FTDI device function depending of the current OS""" if OS == 'Linux': return pylibftdi.Device(device_index=board_id, interface_select=channel + 1) elif OS == 'Windows': add = desc.get('location') dev_list = ftdi.listDevices() dev_channel = None for i, d in enumerate(dev_list): if d != b'': if chr(d[-1]) == chr(ord('A') + channel): tmp_dev = ftdi.getDeviceInfoDetail(i) if tmp_dev.get('location') == add + channel: dev_channel = tmp_dev.get('index') else: pass return ftdi.open(dev_channel)
def ft_init(self): #Get the device list and save the index of logic analyzer into deviceIndex self.deviceList = ftd2xx.listDevices(0) # returns the list of ftdi devices S/Ns self.deviceIndex = -1; self.status = -1; if self.deviceList : print(len(self.deviceList), 'ftdi devices found') for x in range(0,len(self.deviceList)): if ( "LogicAnalyzer" in str(ftd2xx.getDeviceInfoDetail(x)['description'])) : print("Device %d details: "%x) print('-------------------------------------------------') print("Serial : " + str(ftd2xx.getDeviceInfoDetail(x)['serial'])) print("Type : " + str(ftd2xx.getDeviceInfoDetail(x)['type'])) print("ID : " + str(ftd2xx.getDeviceInfoDetail(x)['id'])) print("Description : " + str(ftd2xx.getDeviceInfoDetail(x)['description'])) print('-------------------------------------------------') if self.deviceIndex < 0: self.deviceIndex = x break else: print("no ftdi devices connected")
def detect_xid_devices(self): """ For all of the com ports connected to the computer, send an XID command '_c1'. If the device response with '_xid', it is an xid device. """ self.__xid_cons = [] devs = ftd2xx.listDevices() if devs is None: return for d in devs: device_found = False for b in [115200, 19200, 9600, 57600, 38400]: con = XidConnection(d, b) try: con.open() except ftd2xx.DeviceError: continue con.flush() returnval = con.send_xid_command("_c1", 5).decode('ASCII') if returnval.startswith('_xid'): device_found = True self.__xid_cons.append(con) if (returnval != '_xid0'): # set the device into XID mode con.send_xid_command('c10') con.flush() con.close() if device_found: break
def open_device(name): devices = ftd2xx.listDevices() ix = devices.index(name) return ftd2xx.open(dev=ix)
def serialRefresh(self, _=None): serialnames = ft.listDevices() if serialnames == None: serialnames = [""] self.setSerialNumberLimits(serialnames) self.findParam('snum').setValue(serialnames[0])
# -*- coding: utf-8 -*- """ Created on Wed Jun 6 14:50:19 2018 @author: daukes """ import ftd2xx import time import ftd2xx.defines as fd sn = b'73876440' devices = ftd2xx.listDevices() if not sn in devices: print("No device found. Exiting...") else: ii = devices.index(sn) print("Initializing device...") device = ftd2xx.open(ii) device.setBaudRate(115200) # time.sleep(50/1000) time.sleep(1) device.setDataCharacteristics(fd.BITS_8, fd.STOP_BITS_1, fd.PARITY_NONE) # device.setFlowControl() device.purge(fd.PURGE_RX | fd.PURGE_TX) # time.sleep(50/1000) time.sleep(1) device.resetDevice() time.sleep(1) device.setFlowControl(fd.FLOW_RTS_CTS, 0, 0)
# coding: utf-8 import ftd2xx import time import codecs ############# DEVICE CONFIGURATION ############# d = ftd2xx.listDevices() # list devices by serial, returns tuple of attached devices serial strings h = ftd2xx.openEx(d[0]) h.setBitMode(0xFF, 0x00) # reset mode time.sleep(0.01) h.setBitMode(0xFF, 0x40) # 245 fifo mode h.setLatencyTimer(2) # h.setUSBParameters(0x10000,0x10000) h.setFlowControl(0x0100, 0x0, 0x0) # Avoid packet losses h.setTimeouts(200,200) # set RX/TX timeouts h.purge(1) #Purge RX Buffer h.purge(2) #Purge TX Buffer time.sleep(2) ############# HEADER DEFINITION ################ header_1 = "00" # Header MSB Key header_2 = "01" # Header LSB Key header_3 = "02" # Header MSB Mask header_4 = "03" # Header LSB Mask header_5 = "04" # Header plaintext ############# AES 256 CBC INPUTS ############### key_hex_1 = "000102030405060708090a0b0c0d0e0f" key_hex_2 = "101112131415161718191a1b1c1d1e1f" mask_hex_1 ="102030405060708090A0B0C0D0E0F101"
def testlistDevices(self): self.assert_(isinstance(ftd2xx.listDevices(), list))
def testopenEx(self): self.assert_(isinstance(ftd2xx.openEx(ftd2xx.listDevices()[0]), ftd2xx.FTD2XX))
def __init__(self, name, address=0, ver=0, use_internal_trigger=True, mode='master'): from qsweepy.config import get_config import numbers #qtlab stuff Instrument.__init__(self, name, tags=['measure']) # Opening ftd2xx connection (USB-COM dongle) if not isinstance(address, numbers.Integral): address = ftd2xx.listDevices().index(address) print ('opening device') self.h = ftd2xx.open(address) print ('device open') # QTLab stuff self.add_parameter('repetition_period', type=float, flags=Instrument.FLAG_SET | Instrument.FLAG_SOFTGET, minval=2e-9) self.add_function('LoadRAM') self.add_function('Send2CPU') self.add_function('ProgLimit') self.add_function('RamAddrCtrl') self.add_function('SetDAC8') self.add_function('InitDAC8') self.add_function('ProgAutoTrigger') self.add_function('ProgTimer') self.add_function('ProgRepeater') self.add_function('LoadPWL') self.add_function('intToBytes') #self.add_function('SetDAC16Gain') self.add_function('SetDAC16zero') self.add_function('SetDAC16') self.add_function('ProgPulse') self.add_function('SetPulseAmplitude') self.add_function('SendControlWord') self.add_function('InitPulseDacs') self.add_function('SendPacket') self.add_function('set_trigger_repeats') self.add_function('get_trigger_repeats') self.add_function('set_trigger_period') self.add_function('get_trigger_period') self.add_function('set_repetition_period') self.add_function('get_repetition_period') self.add_function('set_trigger_amplitude') self.add_function('get_trigger_amplitude') self.add_function('set_trigger_pulse') self.add_function('get_trigger_pulse') self.add_function('set_waveform') self.add_function('get_waveform') self.add_function('create_delayed_trigger_pulse') self.add_function('get_max_value') self.add_function('get_min_value') self.add_function('get_sample_period') self.add_function('get_sample_dtype') self.add_function('get_max_sample_size') # default driver settings channel_settings = {channel_id:{'on':True, # turn on channel power 'mode': 'ram', # AWG mode: 'ram' - predefined point, 'PWL' - piecewise linear 'filter':False, # turno/off 10 MHz filter (only available for channel 0) 'offset':0, # slow hardware offset (only available for channel 0) 'sw_offset':0, #software offset 'signed':True, # 0 for -8192 to 8191, 1 for 0 to 16383 'continuous_run':False, # enables repetition inside a single AWG pulse sequence for this channel 'reset_enable':False, # enables repetition rate inside a single AWG pulse sequence # for this channel different from 32768 pulse points 'clock_phase':0, # clock phase inverter (1 ns shift) 'delta_ram':0, # points per clock period 'slow':0, # 2e-9 s clock period per data point 'ram_pulse_length':32768, # repetition rate inside a single AWG pulse sequence if 'continuous run' and 'reset enable' is on 'delay':0 # some strange delay } for channel_id in range(7)} self.pulses = {channel_id: [] for channel_id in range(7)} self.channel_settings = channel_settings self.use_internal_trigger = use_internal_trigger # turning on AWG channels (control word) self.ver = ver if ver == 2: self.h.setBitMode(0xff, 0x40) self.h.setUSBParameters(0x10000, 0x10000) self.h.setLatencyTimer(2) self.h.setFlowControl(FT_FLOW_RTS_CTS, 0, 0) is_programmed = self.IsVirtexProgrammed() print ('Virtex is programmed? ', is_programmed) if not is_programmed: if mode=='master': self.ProgVirtex6(filename=get_config()['AWG500_default_firmware']) else: self.ProgVirtex6(filename=get_config()['AWG500_slave_firmware']) self.send_control_word() # setting a single trigger per AWG repeat self.set_trigger_repeats(1) self.set_trigger_period(0) self.set_repetition_period(self.get_max_sample_size()*2e-9) # setting trigger amplitudes for PLS channels #self.trigger_amplitudes = {'PLS5':0xfff0, 'PLS2':0xfff0, 'PLS1':0xfff0} self.trigger_amplitudes = {'PLS5':0x0000, 'PLS2':0x0000, 'PLS1':0x0000} for channel_name, amplitude in zip(self.trigger_amplitudes.keys(), self.trigger_amplitudes.values()): self.set_trigger_amplitude(channel_name, amplitude) # setting trigger pulse form. This is sick shit and it doesn't work as expected. # see documentation for explanation how it should work in principle. #default_trigger_pulse = [0, 4] default_trigger_pulse = self.create_delayed_trigger_pulse(0) self.trigger_pulses = {channel_name:default_trigger_pulse for channel_name in ['SYNC0']}#, 'PLS1', 'PLS2', 'SYNC3', 'SYNC4', 'PLS5']} for channel_name, pulse in zip(self.trigger_pulses.keys(), self.trigger_pulses.values()): self.set_trigger_pulse(channel_name, pulse) # setting default AWG channel settings for channel_id, settings in zip(self.channel_settings.keys(), self.channel_settings.values()): self.set_channel_settings(channel_id, settings)
from pymeasure.display import widgets as pw from pymeasure.display.inputs import * import ftd2xx # Thorlabs MFF101 import ftd2xx.defines as constants from ftd2xx import listDevices, getDeviceInfoDetail import pymeasure.experiment.parameters as pars from time import sleep from pymeasure.experiment import Procedure from pymeasure.experiment import IntegerParameter import sys FTDIresources = listDevices() FTDIresources serial = FTDIresources[0] def mirror(switch): """Switch 'on' or 'off'""" serial = FTDIresources[0] # Raw byte commands for "MGMSG_MOT_MOVE_JOG". # on = b"\x6A\x04\x00\x01\x21\x01" # x01 up # off = b"\x6A\x04\x00\x02\x21\x01" # x02 down if switch == 'on': motor = ftd2xx.openEx(serial) print(motor.getDeviceInfo()) motor.setBaudRate(115200)
def testopenEx(self): self.assert_( isinstance(ftd2xx.openEx(ftd2xx.listDevices()[0]), ftd2xx.FTD2XX))