예제 #1
0
    def __init__(self, url):
        try:
            self.ftdi = Ftdi.create_from_url(url)
        except UsbToolsError:
            raise Error('no device found for URL %s' % url)

        self.i2c = I2cController()
        self.i2c.set_retry_count(1)
        self.i2c.configure(url)

        self.gpio = Device.GpioController(self.ftdi)
        port = self.i2c.get_port(0x74)

        self.buttons = []
        self.rails = []

        self.power = Device.I2cButton(port, "power", 0x7, 0x3, 4)
        self.buttons.append(self.power)

        self.reset = Device.I2cButton(port, "reset", 0x6, 0x2, 3)
        self.buttons.append(self.reset)

        self.recovery = Device.I2cButton(port, "recovery", 0x7, 0x3, 3)
        self.buttons.append(self.recovery)

        self.force = Device.GpioButton(self.gpio, 6, "force-off")
        self.buttons.append(self.force)

        self.eeprom = Device.Eeprom(self.ftdi)

        self.core = Device.PowerRail(port, "core", 0x7, 0x1, 6)
        self.rails.append(self.core)

        self.cpu = Device.PowerRail(port, "cpu", 0x7, 0x1, 7)
        self.rails.append(self.cpu)
예제 #2
0
 def createdevpinout(self,ftdidevicename,devtype="",devorder=-1):
  global PINOUT
  startpoint = len(Settings.Pinout)
  try:
   fi = Ftdi()
   fi = fi.create_from_url(ftdidevicename)
   gpionum = fi.port_width
   lismpsse = fi.has_mpsse
   lportindex = fi.port_index
   fi.close()
  except Exception as e:
   gpionum = 0
  if gpionum>0:
   for g in range(0,gpionum):
    pname = get_ftdi_pinnames(g,lportindex,lismpsse)
    if devorder>-1:
     try:
      pname[2] = pname[2].replace("SPI-","SPI"+str(devorder)+"-")
      pname[3] = pname[3].replace("I2C-","I2C"+str(devorder)+"-")
     except:
      pass
    pindet = {"ID": int(startpoint+g),
"BCM":int(startpoint+g),
"realpin":int(g),
"name":pname,
"canchange":1,
"altfunc": 0,
"startupstate":-1,
"actualstate":-1,
"ftdevice":ftdidevicename,
"ftdevtype":devtype
}
    Settings.Pinout.append(pindet)
    pindet = None
예제 #3
0
 def open(self):
     """Open the initialized serial port"""
     if self.port is None:
         raise SerialException("Port must be configured before use.")
     try:
         device = Ftdi.create_from_url(self.port)
     except (UsbToolsError, IOError) as ex:
         raise SerialException('Unable to open USB port %s: %s' %
                               (self.portstr, str(ex)))
     self.udev = device
     self._set_open_state(True)
     self._reconfigure_port()
예제 #4
0
 def open(self):
     """Open the initialized serial port"""
     if self.port is None:
         raise SerialException("Port must be configured before use.")
     try:
         device = Ftdi.create_from_url(self.port)
     except (UsbToolsError, IOError) as ex:
         raise SerialException('Unable to open USB port %s: %s' %
                               (self.portstr, str(ex)))
     self.udev = device
     self._set_open_state(True)
     self._reconfigure_port()
예제 #5
0
                # print("Sending byte " + str(j))
                f1.write_data(bytes([byte1]))
                dout = f1.read_data_bytes(1, attempt=10000)
                # print("data sent = " + str(int(byte1)) + ". Recieved back " + str(dout))
                # print()
                j += 1
            i += 1


strVariable = StringVar(top)

L1 = Label(top, text="Serial Terminal")
L1.grid(row=0, column=0)
E1 = Entry(top, textvariable=strVariable, bd=5)
E1.grid(row=0, column=1)

MyButton1 = Button(top, text="Submit", width=10, command=callback)
MyButton1.grid(row=1, column=1)
fileButton = Button(top,
                    text="Select program",
                    width=10,
                    command=fileButtonCallback)
fileButton.grid(row=2, column=1)
clearButton = Button(top, text="Clear", width=10, command=clearCallback)
clearButton.grid(row=3, column=1)
f1 = Ftdi.create_from_url('ftdi:///1')
f1.set_baudrate(115200)
data1 = f1.modem_status()
print(data1)
top.mainloop()
예제 #6
0
    start_time = time.time()
    while (not bool(bb) and (time.time() - start_time) < timeout_sec):
        bb = motor_stageXY.read(90) 
    
    You also have to use "write_data" and "read_data" instead of 'write' and 'read'
    
    It's better also to use time.sleep(0.1) between commands
    '''

    timeout_sec = 2
    from pyftdi.ftdi import Ftdi

    # PID seems to be FAF0 in device manager
    Ftdi.add_custom_product(0x403, 0xfaf0)
    try:
        motor_stageXY = Ftdi.create_from_url('ftdi://0x403:0xfaf0/1')
        motor_stageXY.open_from_url(url='ftdi://0x403:0xfaf0/1')

        motor_stageXY.set_baudrate(115200)
        motor_stageXY.set_line_property(8, 1, 'N',
                                        break_=0)  # 'N' = parity_none
        time.sleep(50e-3)  # pre-purge
        motor_stageXY.purge_buffers()  # purge RX and TX buffers
        time.sleep(50e-3)  # post-purge
        motor_stageXY._reset_device(
        )  # private module, unlock it to public if no access
        motor_stageXY.set_flowctrl('hw')  # 'hw' means RTS/CTS UART lines

        # f1.set_rts(state) # not sure for this one, the doc does not specify the 'state'

    except Exception as e: