OpenCores
URL https://opencores.org/ocsvn/usb_fpga_1_2/usb_fpga_1_2/trunk

Subversion Repositories usb_fpga_1_2

[/] [usb_fpga_1_2/] [trunk/] [java/] [ztex/] [Ztex1.java] - Diff between revs 3 and 4

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 3 Rev 4
Line 1... Line 1...
/*!
/*!
   Java Driver API for the ZTEX Firmware Kit
   Java Driver API for the ZTEX Firmware Kit
   Copyright (C) 2008-2009 ZTEX e.K.
   Copyright (C) 2009-2010 ZTEX e.K.
   http://www.ztex.de
   http://www.ztex.de
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 3 as
   it under the terms of the GNU General Public License version 3 as
   published by the Free Software Foundation.
   published by the Free Software Foundation.
Line 42... Line 42...
public class Ztex1 {
public class Ztex1 {
    private int handle;
    private int handle;
    private ZtexDevice1 dev = null;
    private ZtexDevice1 dev = null;
    private boolean oldDevices[] = new boolean[128];
    private boolean oldDevices[] = new boolean[128];
    private String usbBusName = null;
    private String usbBusName = null;
/** * Setting to true will enable certain workarounds, e.g. to deal with bad driver/OS implementations. */
/** * Setting to true enables certain workarounds, e.g. to deal with bad driver/OS implementations. */
    public boolean certainWorkarounds = false;
    public boolean certainWorkarounds = false;
/** * The timeout for  control messages in ms. */
/** * The timeout for  control messages in ms. */
    public int controlMsgTimeout = 1000;        // in ms
    public int controlMsgTimeout = 1000;        // in ms
    private long lastVendorCommandT = 0;
    private long lastVendorCommandT = 0;
 
 
Line 58... Line 58...
  */
  */
    public Ztex1 ( ZtexDevice1 pDev ) throws UsbException {
    public Ztex1 ( ZtexDevice1 pDev ) throws UsbException {
        dev = pDev;
        dev = pDev;
 
 
        handle = LibusbJava.usb_open(dev.dev());
        handle = LibusbJava.usb_open(dev.dev());
        if ( handle<=0 )
//      if ( handle<=0 ) 
            throw new UsbException(dev.dev(), "Error opening device");
//          throw new UsbException(dev.dev(), "Error opening device");
    }
    }
 
 
// ******* finalize ************************************************************
// ******* finalize ************************************************************
/** * The destructor closes the USB file handle. */
/** * The destructor closes the USB file handle. */
    protected void finalize () {
    protected void finalize () {
Line 296... Line 296...
  */
  */
    public void vendorRequest2 (int cmd, String func, byte[] buf, int maxlen) throws UsbException {
    public void vendorRequest2 (int cmd, String func, byte[] buf, int maxlen) throws UsbException {
        vendorRequest2(cmd, func, 0, 0, buf, maxlen);
        vendorRequest2(cmd, func, 0, 0, buf, maxlen);
    }
    }
 
 
 
 
 
 
 
// ******* setConfiguration ****************************************************
 
/**
 
  * Sets the configuration.
 
  * @param config The configuration number (usually 1)
 
  * @throws UsbException if an error occurs while attempting to set the configuration.
 
  */
 
    public void setConfiguration ( int config) throws UsbException{
 
        if ( LibusbJava.usb_set_configuration(handle(), config) < 0 )
 
            throw new UsbException("Setting configuration to " + config + " failed: " + LibusbJava.usb_strerror());
 
    }
 
 
 
 
 
// ******* trySetConfiguration ****************************************************
 
/**
 
  * Tries to set the configuration.
 
  * If an error occurs while attempting to set the configuration, a warning messaage is printed to stderr.
 
  * @param config The configuration number (usually 1)
 
  */
 
    public void trySetConfiguration ( int config) {
 
        if ( LibusbJava.usb_set_configuration(handle(), config) < 0 )
 
            System.err.println("Setting configuration to " + config + " failed: " + LibusbJava.usb_strerror());
 
    }
 
 
 
 
 
// ******* claimInterface ******************************************************
 
/**
 
  * Claims an interface.
 
  * @param iface The interface number (usually 0)
 
  * @throws UsbException if an error occurs while attempting to claim the interface.
 
  */
 
    public void claimInterface ( int iface) throws UsbException{
 
        if ( LibusbJava.usb_claim_interface(handle(), iface) < 0 )
 
            throw new UsbException("Claiming interface " + iface + " failed: " + LibusbJava.usb_strerror());
 
    }
 
 
 
 
 
// ******* releaseInterface ****************************************************
 
/**
 
  * Releases an interface.
 
  * @param iface The interface number (usually 0)
 
  */
 
    public void releaseInterface ( int iface ) {
 
        LibusbJava.usb_release_interface(handle(), iface);
 
    }
 
 
 
 
// ******* findOldDevices ******************************************************
// ******* findOldDevices ******************************************************
    private synchronized void findOldDevices () {
    private synchronized void findOldDevices () {
        Usb_Bus bus = dev.dev().getBus();
        Usb_Bus bus = dev.dev().getBus();
        usbBusName = bus.getDirname();
        usbBusName = bus.getDirname();
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.