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 connect(self): # connect to port try: self.sasebo = ft.openEx("FTSZ1IONB") except ft.ftd2xx.DeviceError, e: self.sasebo = None return False
def con(self): try: self.sasebo = ft.openEx(self.serNo) except ft.ftd2xx.DeviceError, e: self.sasebo = None print "Failed to find device: %s" % str(e) return False
def con(self): try: self.sasebo = ft.openEx("FTSZ1IONB") # self.sasebo = ft.openEx("FTWQ8BMIA") except ft.ftd2xx.DeviceError, e: self.sasebo = None return False
def _con(self, scope=None): self._sn = self.findParam('serno').getValue() try: self.sasebo = ft.openEx(self._sn) except ft.ftd2xx.DeviceError, e: self.sasebo = None raise Warning("Failed to connect to FTDI device. Specificed serial number is '%s'. Check 'Target' tab to ensure correct serial-number selected."%self._sn)
def con(self, scope=None): try: self.sasebo = ft.openEx(self.serNo) except ft.ftd2xx.DeviceError, e: self.sasebo = None logging.error('Failed to find device: %s' % str(e)) return False
def con(self, scope = None): try: self.sasebo = ft.openEx(self.serNo) except ft.ftd2xx.DeviceError, e: self.sasebo = None print "Failed to find device: %s" % str(e) return False
def __init__(self, countchannel, triggerchannel, binwidth, roistart, roistop, filename=None, parent = None, FPGASerial="A6VTOYBO"): QThread.__init__(self, parent) self.channel = countchannel self.triggerchannel = triggerchannel self.binwidth = binwidth self.roistart = roistart self.roistop = roistop self.numberOfBins = (roistop-roistart)/binwidth+1 self.histogram = numpy.zeros(self.numberOfBins) self.exiting = False self.crc8 = crcmod.mkCrcFun(poly=0x107, initCrc=0xff, xorOut=0x00, rev=False) self.Connection = ftd2xx.openEx(FPGASerial); self.Connection.setBaudRate(3000000) self.Connection.setDataCharacteristics(8, 0, 0) self.Connection.setFlowControl(0, 0, 0) self.Connection.setTimeouts(500, 500) self.Connection.resetDevice() self.Connection.purge() self.integration_time = 100.0; command = struct.pack('>BBBI', 0x10, 0, 0x11, int(500*50000 ) ) self.Connection.write(command) command = struct.pack('>BB', 0x12, 0x0 ) self.Connection.write(command) self.Mutex = QMutex() self.filename = filename self.binfile = None if self.filename is not None: self.binfile = open(self.filename, 'wb') self.clearStatus() self.maxPretriggerPhotons = 1000000
def open( self ): # This method must return a string showing whether the open succeeded or failed. enum = d2xx.createDeviceInfoList() # quantity of FTDI devices if (enum == 0): return 'Device was not found' for i in range(enum): # Searching and openinq needed device a = d2xx.getDeviceInfoDetail(i) if (a['description'] == 'SDR-Micron'): try: self.usb = d2xx.openEx(a['serial']) except: return 'Device was not found' Mode = 64 # Configure FT2232H into 0x40 Sync FIFO Mode self.usb.setBitMode(255, 0) # reset time.sleep(0.1) self.usb.setBitMode( 255, Mode) #configure FT2232H into Sync FIFO mode self.usb.setTimeouts(100, 100) # read, write self.usb.setLatencyTimer(2) self.usb.setUSBParameters(64, 64) # in_tx_size, out_tx_size=0 time.sleep(1.5) # waiting for initialisation device data = self.usb.read( self.usb.getQueueStatus()) # clean the usb data buffer self.device = 'Opened' self.frame_msg = a['description'] + ' S/N - ' + a['serial'] return self.frame_msg return 'Device was not found'
def open(self): if self._comport is None: raise ValueError self._ftdi = ftd2xx.openEx(self._comport) self._ftdi.setBaudRate(57600) self._is_opened = True self._shouldstop.clear() threading.Thread(target=self._getting_log_output).start()
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 open(self): self.ftd2xx_con = ftd2xx.openEx(self.ftd2xx_intermediate) self.ftd2xx_con.setBaudRate(self.baudrate) self.ftd2xx_con.setDataCharacteristics(8, 0, 0) self.ftd2xx_con.setTimeouts(50, 50) self.ftd2xx_con.setUSBParameters(64,64) self.ftd2xx_con.setLatencyTimer(10) self.flush()
def con(self, scope=None): try: self.sasebo = ft.openEx(self.serNo) except ft.ftd2xx.DeviceError as e: self.sasebo = None logging.error('Failed to find device: %s' % str(e)) return False self.sasebo.setTimeouts(1000, 1000) return True
def con(self): if self.ser is None: try: self.dev = ft.openEx(str(self.serialNumber), 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, e: self.ser = None raise IOError("Could not open %s: %s" % (self.serialNumber, e))
def _con(self, scope=None): self._sn = self.findParam('serno').getValue() try: self.sasebo = ft.openEx(self._sn) except ft.ftd2xx.DeviceError: self.sasebo = None raise Warning("Failed to connect to FTDI device (serial number: '%s'). Check 'Target' tab to ensure correct serial-number selected." % self._sn) self.sasebo.setTimeouts(1000, 1000) #Init self.init() return True
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) motor.setDataCharacteristics(constants.BITS_8, constants.STOP_BITS_1, constants.PARITY_NONE) sleep(.05) motor.purge() sleep(.05) motor.resetDevice() motor.setFlowControl(constants.FLOW_RTS_CTS, 0, 0) motor.setRts() # Send raw bytes to USB driver. motor.write(b"\x6A\x04\x00\x01\x21\x01") # up or motor.close() else: motor = ftd2xx.openEx(serial) print(motor.getDeviceInfo()) motor.setBaudRate(115200) motor.setDataCharacteristics(constants.BITS_8, constants.STOP_BITS_1, constants.PARITY_NONE) sleep(.05) motor.purge() sleep(.05) motor.resetDevice() motor.setFlowControl(constants.FLOW_RTS_CTS, 0, 0) motor.setRts() # Send raw bytes to USB driver. motor.write(b"\x6A\x04\x00\x02\x21\x01") # up or motor.close()
def _connect(self, serial_no: object): """ :param serial_no: :return: """ import ftd2xx as ft # connect to port try: self.sasebo = ft.openEx(serial_no) # type: ft.FTD2XX except ft.ftd2xx.DeviceError: self.sasebo = None return False self.sasebo.setTimeouts(20000, 20000) return True
def _con(self, scope=None): self._sn = self.findParam("serno").getValue() try: self.sasebo = ft.openEx(self._sn) except ft.ftd2xx.DeviceError: self.sasebo = None raise Warning( "Failed to connect to FTDI device (serial number: '%s'). Check 'Target' tab to ensure correct serial-number selected." % self._sn ) self.sasebo.setTimeouts(1000, 1000) # Init self.init() return True
def con(self): if self.ser is None: try: self.dev = ft.openEx(str(self.serialNumber), 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("Could not open %s: %s" % (self.serialNumber, e)) try: self.scope.con(self.ser) logging.info('OpenADC Found, Connecting') except IOError as e: exctype, value = sys.exc_info()[:2] raise IOError("OpenADC Error: %s" % (str(exctype) + str(value)) + " - " + e.message)
def start(self): self.f = ftd2xx.openEx(self.SERIAL.encode()) self.f.setTimeouts(100, 100) self.enterprogrammingmode() self.doreset = 1 self.f.setBaudRate(self.INITBAUD) self.f.setDataCharacteristics(8, 0, 0)#ftd2xx.BITS_8, ftd2xx.STOP_BITS_1, ftd2xx.PARITY_NONE) self.f.setRts() self.f.setFlowControl(0x0100)#ftd2xx.SIO_RTS_CTS_HS) self.f.clrRts() self.f.purge() self.talk(CHANGE_BAUD_RATE, data=[super().baud_to_div(self.PROGBAUD)]) self.f.setBaudRate(self.PROGBAUD) super().start()
def connect(self): try: import ftd2xx import ftd2xx.defines as constants motor = ftd2xx.openEx(self._port) motor.setBaudRate(115200) motor.setDataCharacteristics(constants.BITS_8, constants.STOP_BITS_1, constants.PARITY_NONE) time.sleep(.05) motor.purge() time.sleep(.05) motor.resetDevice() motor.setFlowControl(constants.FLOW_RTS_CTS, 0, 0) motor.setRts() self.motor = motor except: pass
def __init__(self): #serial number for this motor flipper #if have more than one modify to take as argument) serial = b"37000036" #recommended d2xx setup instructions from Thorlabs motor = ftd2xx.openEx(serial) motor.setBaudRate(115200) motor.setDataCharacteristics(constants.BITS_8, constants.STOP_BITS_1, constants.PARITY_NONE) time.sleep(.05) motor.purge() time.sleep(.05) motor.resetDevice() motor.setFlowControl(constants.FLOW_RTS_CTS, 0, 0) motor.setRts() #set its motor as the motor self.motor = motor
def __init__(self, countchannel, triggerchannel, binwidth, roistart, roistop, filename=None, parent=None, FPGASerial="A6VTOYBO"): QThread.__init__(self, parent) self.channel = countchannel self.triggerchannel = triggerchannel self.binwidth = binwidth self.roistart = roistart self.roistop = roistop self.numberOfBins = (roistop - roistart) / binwidth + 1 self.histogram = numpy.zeros(self.numberOfBins) self.exiting = False self.crc8 = crcmod.mkCrcFun(poly=0x107, initCrc=0xff, xorOut=0x00, rev=False) self.Connection = ftd2xx.openEx(FPGASerial) self.Connection.setBaudRate(3000000) self.Connection.setDataCharacteristics(8, 0, 0) self.Connection.setFlowControl(0, 0, 0) self.Connection.setTimeouts(500, 500) self.Connection.resetDevice() self.Connection.purge() self.integration_time = 100.0 command = struct.pack('>BBBI', 0x10, 0, 0x11, int(500 * 50000)) self.Connection.write(command) command = struct.pack('>BB', 0x12, 0x0) self.Connection.write(command) self.Mutex = QMutex() self.filename = filename self.binfile = None if self.filename is not None: self.binfile = open(self.filename, 'wb') self.clearStatus() self.maxPretriggerPhotons = 1000000
# 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"
#!/usr/bin/python from sys import exit from time import sleep try: import ftd2xx except OSError: print "Check libftd2xx.so presence." exit(2) try: com = ftd2xx.openEx('Dual RS232-HS B', ftd2xx.ftd2xx.OPEN_BY_DESCRIPTION) except ftd2xx.ftd2xx.DeviceError: print "Unable to open 'Dual RS232-HS B'." exit(1) except: print "Unknown error while openning 'Dual RS232-HS B'." exit(3) open('lock-ftdi-B.lck', 'w').close() while True: cnt = com.getQueueStatus() com.read(cnt) sleep(1) com.close()
def open(self, device_id): if type(device_id) is int: self.device = ftd2xx.open(device_id) else: self.device = ftd2xx.openEx(device_id)
def testopenEx(self): self.assert_(isinstance(ftd2xx.openEx(ftd2xx.listDevices()[0]), ftd2xx.FTD2XX))
#!/usr/bin/python import sys import tty import termios import select from time import sleep try: import ftd2xx except OSError: print "Check libftd2xx.so presence." sys.exit(2) try: com = ftd2xx.openEx('Dual RS232-HS A', ftd2xx.ftd2xx.OPEN_BY_DESCRIPTION) except ftd2xx.ftd2xx.DeviceError: print "Unable to open 'Dual RS232-HS A'." sys.exit(1) except: print "Unknown error while openning 'Dual RS232-HS A'." sys.exit(3) com.setBaudRate(ftd2xx.ftd2xx.BAUD_38400) com.setDataCharacteristics(ftd2xx.ftd2xx.BITS_8, ftd2xx.ftd2xx.STOP_BITS_1, ftd2xx.ftd2xx.PARITY_NONE) com.setFlowControl(ftd2xx.ftd2xx.FLOW_NONE) old_settings = termios.tcgetattr(sys.stdin) try: tty.setcbreak(sys.stdin.fileno())
def testopenEx(self): self.assert_( isinstance(ftd2xx.openEx(ftd2xx.listDevices()[0]), ftd2xx.FTD2XX))
def __init__(self, serial=None): if serial is not None: self.dev = ftd2xx.openEx(serial) else: self.dev = ftd2xx.open() self.dev.setTimeouts(read=5000, write=5000)