- *
- * http://libusbjava.sourceforge.net
- * This library is covered by the LGPL, read LGPL.txt for details.
- */
-package ch.ntb.usb;
-
-/**
- * Represents the descriptor of an USB endpoint.
- * Endpoint descriptors are used to describe endpoints other than endpoint zero.
- * Endpoint zero is always assumed to be a control endpoint and is configured
- * before any descriptors are even requested. The host will use the information
- * returned from these descriptors to determine the bandwidth requirements of
- * the bus.
- *
- * The length of the configuration descriptor is
- * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_ENDPOINT_SIZE} and the type is
- * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_ENDPOINT}.
- *
- */
-public class Usb_Endpoint_Descriptor extends Usb_Descriptor {
-
- /**
- * Maximum number of endpoints
- */
- public static final int USB_MAXENDPOINTS = 32;
-
- /**
- * Endpoint address mask (in bEndpointAddress).
- */
- public static final int USB_ENDPOINT_ADDRESS_MASK = 0x0f,
- USB_ENDPOINT_DIR_MASK = 0x80;
-
- /**
- * Endpoint type mask (in bmAttributes).
- */
- public static final int USB_ENDPOINT_TYPE_MASK = 0x03;
-
- /**
- * Possible endpoint types (in bmAttributes).
- */
- public static final int USB_ENDPOINT_TYPE_CONTROL = 0,
- USB_ENDPOINT_TYPE_ISOCHRONOUS = 1, USB_ENDPOINT_TYPE_BULK = 2,
- USB_ENDPOINT_TYPE_INTERRUPT = 3;
-
- private byte bEndpointAddress;
-
- private byte bmAttributes;
-
- private short wMaxPacketSize;
-
- private byte bInterval;
-
- private byte bRefresh;
-
- private byte bSynchAddress;
-
- private byte[] extra; /* Extra descriptors */
-
- private int extralen;
-
- /**
- * Returns the endpoint address.
- *
- * Bits 3..0: Endpoint number
- * Bits 6..4: Reserved. Set to zero
- * Bit 7: Direction (host to device). 0 = OUT (send data from host to
- * device), 1 = IN (host receives data from device). Note: these values are
- * ignored for control endpoints.
- *
- * @return the endpoint address
- */
- public byte getBEndpointAddress() {
- return bEndpointAddress;
- }
-
- /**
- * Returns the intervall for polling endpoint data transfers.
- * Value in frame counts. Ignored for Bulk & Control eEndpoints. Isochronous
- * endpoints must equal 1 and field may range from 1 to 255 for interrupt
- * endpoints.
- *
- * @return the intervall for polling endpoint data transfers
- */
- public byte getBInterval() {
- return bInterval;
- }
-
- /**
- * Returns the attributes of this endpoint.
- *
- * Bits 1..0: Transfer Type (see USB_ENDPOINT_TYPE_XXX).
- * Bits 7..2: Reserved.
- *
- *
- * If isochronous endpoint:
- * Bits 3..2: Synchronisation type
- * 00 = No synchronisation
- * 01 = Asynchronous
- * 10 = Adaptive
- * 11 = Synchronous
- * Bits 5..4: Usage Type
- * 00 = Data endpoint
- * 01 = Feedback endpoint
- * 10 = Explicit feedback data endpoint
- * 11 = Reserved
- *
- *
- * @return the attributes of this endpoint
- */
- public byte getBmAttributes() {
- return bmAttributes;
- }
-
- public byte getBRefresh() {
- return bRefresh;
- }
-
- public byte getBSynchAddress() {
- return bSynchAddress;
- }
-
- /**
- * Returns the data of extra descriptor(s) if available.
- *
- * @return null or a byte array with the extra descriptor data
- */
- public byte[] getExtra() {
- return extra;
- }
-
- /**
- * Returns the number of bytes of the extra descriptor.
- *
- * @return the number of bytes of the extra descriptor
- */
- public int getExtralen() {
- return extralen;
- }
-
- /**
- * Returns the maximum packet size of this endpoint is capable of sending or
- * receiving.
- *
- * @return the maximum packet size
- */
- public short getWMaxPacketSize() {
- return wMaxPacketSize;
- }
-
- @Override
- public String toString() {
- return "Usb_Endpoint_Descriptor bEndpointAddress: 0x"
- + Integer.toHexString(bEndpointAddress & 0xFF);
- }
-}
+/*
+ * Java libusb wrapper
+ * Copyright (c) 2005-2006 Andreas Schläpfer
+ *
+ * http://libusbjava.sourceforge.net
+ * This library is covered by the LGPL, read LGPL.txt for details.
+ */
+package ch.ntb.usb;
+
+/**
+ * Represents the descriptor of an USB endpoint.
+ * Endpoint descriptors are used to describe endpoints other than endpoint zero.
+ * Endpoint zero is always assumed to be a control endpoint and is configured
+ * before any descriptors are even requested. The host will use the information
+ * returned from these descriptors to determine the bandwidth requirements of
+ * the bus.
+ *
+ * The length of the configuration descriptor is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_ENDPOINT_SIZE} and the type is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_ENDPOINT}.
+ *
+ */
+public class Usb_Endpoint_Descriptor extends Usb_Descriptor {
+
+ /**
+ * Maximum number of endpoints
+ */
+ public static final int USB_MAXENDPOINTS = 32;
+
+ /**
+ * Endpoint address mask (in bEndpointAddress).
+ */
+ public static final int USB_ENDPOINT_ADDRESS_MASK = 0x0f,
+ USB_ENDPOINT_DIR_MASK = 0x80;
+
+ /**
+ * Endpoint type mask (in bmAttributes).
+ */
+ public static final int USB_ENDPOINT_TYPE_MASK = 0x03;
+
+ /**
+ * Possible endpoint types (in bmAttributes).
+ */
+ public static final int USB_ENDPOINT_TYPE_CONTROL = 0,
+ USB_ENDPOINT_TYPE_ISOCHRONOUS = 1, USB_ENDPOINT_TYPE_BULK = 2,
+ USB_ENDPOINT_TYPE_INTERRUPT = 3;
+
+ private byte bEndpointAddress;
+
+ private byte bmAttributes;
+
+ private short wMaxPacketSize;
+
+ private byte bInterval;
+
+ private byte bRefresh;
+
+ private byte bSynchAddress;
+
+ private byte[] extra; /* Extra descriptors */
+
+ private int extralen;
+
+ /**
+ * Returns the endpoint address.
+ *
+ * Bits 3..0: Endpoint number
+ * Bits 6..4: Reserved. Set to zero
+ * Bit 7: Direction (host to device). 0 = OUT (send data from host to
+ * device), 1 = IN (host receives data from device). Note: these values are
+ * ignored for control endpoints.
+ *
+ * @return the endpoint address
+ */
+ public byte getBEndpointAddress() {
+ return bEndpointAddress;
+ }
+
+ /**
+ * Returns the intervall for polling endpoint data transfers.
+ * Value in frame counts. Ignored for Bulk & Control eEndpoints. Isochronous
+ * endpoints must equal 1 and field may range from 1 to 255 for interrupt
+ * endpoints.
+ *
+ * @return the intervall for polling endpoint data transfers
+ */
+ public byte getBInterval() {
+ return bInterval;
+ }
+
+ /**
+ * Returns the attributes of this endpoint.
+ *
+ * Bits 1..0: Transfer Type (see USB_ENDPOINT_TYPE_XXX).
+ * Bits 7..2: Reserved.
+ *
+ *
+ * If isochronous endpoint:
+ * Bits 3..2: Synchronisation type
+ * 00 = No synchronisation
+ * 01 = Asynchronous
+ * 10 = Adaptive
+ * 11 = Synchronous
+ * Bits 5..4: Usage Type
+ * 00 = Data endpoint
+ * 01 = Feedback endpoint
+ * 10 = Explicit feedback data endpoint
+ * 11 = Reserved
+ *
+ *
+ * @return the attributes of this endpoint
+ */
+ public byte getBmAttributes() {
+ return bmAttributes;
+ }
+
+ public byte getBRefresh() {
+ return bRefresh;
+ }
+
+ public byte getBSynchAddress() {
+ return bSynchAddress;
+ }
+
+ /**
+ * Returns the data of extra descriptor(s) if available.
+ *
+ * @return null or a byte array with the extra descriptor data
+ */
+ public byte[] getExtra() {
+ return extra;
+ }
+
+ /**
+ * Returns the number of bytes of the extra descriptor.
+ *
+ * @return the number of bytes of the extra descriptor
+ */
+ public int getExtralen() {
+ return extralen;
+ }
+
+ /**
+ * Returns the maximum packet size of this endpoint is capable of sending or
+ * receiving.
+ *
+ * @return the maximum packet size
+ */
+ public short getWMaxPacketSize() {
+ return wMaxPacketSize;
+ }
+
+ @Override
+ public String toString() {
+ return "Usb_Endpoint_Descriptor bEndpointAddress: 0x"
+ + Integer.toHexString(bEndpointAddress & 0xFF);
+ }
+}
diff --git a/java/src/ch/ntb/usb/Usb_Interface.java b/src/main/java/ch/ntb/usb.r273/Usb_Interface.java
similarity index 95%
rename from java/src/ch/ntb/usb/Usb_Interface.java
rename to src/main/java/ch/ntb/usb.r273/Usb_Interface.java
index 4ea724a..a8bb6bc 100644
--- a/java/src/ch/ntb/usb/Usb_Interface.java
+++ b/src/main/java/ch/ntb/usb.r273/Usb_Interface.java
@@ -1,50 +1,50 @@
-/*
- * Java libusb wrapper
- * Copyright (c) 2005-2006 Andreas Schläpfer
- *
- * http://libusbjava.sourceforge.net
- * This library is covered by the LGPL, read LGPL.txt for details.
- */
-package ch.ntb.usb;
-
-/**
- * Represents an USB interface.
- * An interface is a group of alternate settings of a configuration.
- *
- */
-public class Usb_Interface {
-
- /**
- * Maximal number of alternate settings
- */
- public static final int USB_MAXALTSETTING = 128; /* Hard limit */
-
- private Usb_Interface_Descriptor[] altsetting;
-
- private int num_altsetting;
-
- @Override
- public String toString() {
- return "Usb_Interface num_altsetting: 0x"
- + Integer.toHexString(num_altsetting);
- }
-
- /**
- * Retuns an array of interface descriptors.
- *
- * @return an array of interface descriptors
- */
- public Usb_Interface_Descriptor[] getAltsetting() {
- return altsetting;
- }
-
- /**
- * Returns the number of alternate settings.
- *
- * @return the number of alternate settings
- */
- public int getNumAltsetting() {
- return num_altsetting;
- }
-
-}
+/*
+ * Java libusb wrapper
+ * Copyright (c) 2005-2006 Andreas Schläpfer
+ *
+ * http://libusbjava.sourceforge.net
+ * This library is covered by the LGPL, read LGPL.txt for details.
+ */
+package ch.ntb.usb;
+
+/**
+ * Represents an USB interface.
+ * An interface is a group of alternate settings of a configuration.
+ *
+ */
+public class Usb_Interface {
+
+ /**
+ * Maximal number of alternate settings
+ */
+ public static final int USB_MAXALTSETTING = 128; /* Hard limit */
+
+ private Usb_Interface_Descriptor[] altsetting;
+
+ private int num_altsetting;
+
+ @Override
+ public String toString() {
+ return "Usb_Interface num_altsetting: 0x"
+ + Integer.toHexString(num_altsetting);
+ }
+
+ /**
+ * Retuns an array of interface descriptors.
+ *
+ * @return an array of interface descriptors
+ */
+ public Usb_Interface_Descriptor[] getAltsetting() {
+ return altsetting;
+ }
+
+ /**
+ * Returns the number of alternate settings.
+ *
+ * @return the number of alternate settings
+ */
+ public int getNumAltsetting() {
+ return num_altsetting;
+ }
+
+}
diff --git a/java/src/ch/ntb/usb/Usb_Interface_Descriptor.java b/src/main/java/ch/ntb/usb.r273/Usb_Interface_Descriptor.java
similarity index 95%
rename from java/src/ch/ntb/usb/Usb_Interface_Descriptor.java
rename to src/main/java/ch/ntb/usb.r273/Usb_Interface_Descriptor.java
index 683f143..a36d3ed 100644
--- a/java/src/ch/ntb/usb/Usb_Interface_Descriptor.java
+++ b/src/main/java/ch/ntb/usb.r273/Usb_Interface_Descriptor.java
@@ -1,145 +1,145 @@
-/*
- * Java libusb wrapper
- * Copyright (c) 2005-2006 Andreas Schläpfer
- *
- * http://libusbjava.sourceforge.net
- * This library is covered by the LGPL, read LGPL.txt for details.
- */
-package ch.ntb.usb;
-
-/**
- * Represents the descriptor of a USB interface.
- * The interface descriptor could be seen as a header or grouping of the
- * endpoints into a functional group performing a single feature of the device.
- *
- * The length of the interface descriptor is
- * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE_SIZE} and the type is
- * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE}.
- *
- */
-public class Usb_Interface_Descriptor extends Usb_Descriptor {
-
- /**
- * Maximum number of interfaces
- */
- public static final int USB_MAXINTERFACES = 32;
-
- private byte bInterfaceNumber;
-
- private byte bAlternateSetting;
-
- private byte bNumEndpoints;
-
- private byte bInterfaceClass;
-
- private byte bInterfaceSubClass;
-
- private byte bInterfaceProtocol;
-
- private byte iInterface;
-
- private Usb_Endpoint_Descriptor[] endpoint;
-
- private byte[] extra; /* Extra descriptors */
-
- private int extralen;
-
- @Override
- public String toString() {
- return "Usb_Interface_Descriptor bNumEndpoints: 0x"
- + Integer.toHexString(bNumEndpoints);
- }
-
- /**
- * Returns the value used to select the alternate setting ({@link LibusbJava#usb_set_altinterface(long, int)}).
- *
- * @return the alternate setting
- */
- public byte getBAlternateSetting() {
- return bAlternateSetting;
- }
-
- /**
- * Returns the class code (Assigned by www.usb.org).
- *
- * @return the class code
- */
- public byte getBInterfaceClass() {
- return bInterfaceClass;
- }
-
- /**
- * Returns the number (identifier) of this interface.
- *
- * @return the number (identifier) of this interface
- */
- public byte getBInterfaceNumber() {
- return bInterfaceNumber;
- }
-
- /**
- * Returns the protocol code (Assigned by www.usb.org).
- *
- * @return the protocol code
- */
- public byte getBInterfaceProtocol() {
- return bInterfaceProtocol;
- }
-
- /**
- * Returns the subclass code (Assigned by www.usb.org).
- *
- * @return the subclass code
- */
- public byte getBInterfaceSubClass() {
- return bInterfaceSubClass;
- }
-
- /**
- * Returns the number of endpoints used for this interface.
- *
- * @return the number of endpoints used for this interface
- */
- public byte getBNumEndpoints() {
- return bNumEndpoints;
- }
-
- /**
- * Returns an array of endpoint descriptors.
- *
- * @return an array of endpoint descriptors
- */
- public Usb_Endpoint_Descriptor[] getEndpoint() {
- return endpoint;
- }
-
- /**
- * Returns the data of extra descriptor(s) if available.
- *
- * @return null or a byte array with the extra descriptor data
- */
- public byte[] getExtra() {
- return extra;
- }
-
- /**
- * Returns the number of bytes of the extra descriptor.
- *
- * @return the number of bytes of the extra descriptor
- */
- public int getExtralen() {
- return extralen;
- }
-
- /**
- * Returns the index of the String descriptor describing this interface.
- *
- * @return the index of the String descriptor
- */
- public byte getIInterface() {
- return iInterface;
- }
-}
+/*
+ * Java libusb wrapper
+ * Copyright (c) 2005-2006 Andreas Schläpfer
+ *
+ * http://libusbjava.sourceforge.net
+ * This library is covered by the LGPL, read LGPL.txt for details.
+ */
+package ch.ntb.usb;
+
+/**
+ * Represents the descriptor of a USB interface.
+ * The interface descriptor could be seen as a header or grouping of the
+ * endpoints into a functional group performing a single feature of the device.
+ *
+ * The length of the interface descriptor is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE_SIZE} and the type is
+ * {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE}.
+ *
+ */
+public class Usb_Interface_Descriptor extends Usb_Descriptor {
+
+ /**
+ * Maximum number of interfaces
+ */
+ public static final int USB_MAXINTERFACES = 32;
+
+ private byte bInterfaceNumber;
+
+ private byte bAlternateSetting;
+
+ private byte bNumEndpoints;
+
+ private byte bInterfaceClass;
+
+ private byte bInterfaceSubClass;
+
+ private byte bInterfaceProtocol;
+
+ private byte iInterface;
+
+ private Usb_Endpoint_Descriptor[] endpoint;
+
+ private byte[] extra; /* Extra descriptors */
+
+ private int extralen;
+
+ @Override
+ public String toString() {
+ return "Usb_Interface_Descriptor bNumEndpoints: 0x"
+ + Integer.toHexString(bNumEndpoints);
+ }
+
+ /**
+ * Returns the value used to select the alternate setting ({@link LibusbJava#usb_set_altinterface(long, int)}).
+ *
+ * @return the alternate setting
+ */
+ public byte getBAlternateSetting() {
+ return bAlternateSetting;
+ }
+
+ /**
+ * Returns the class code (Assigned by www.usb.org).
+ *
+ * @return the class code
+ */
+ public byte getBInterfaceClass() {
+ return bInterfaceClass;
+ }
+
+ /**
+ * Returns the number (identifier) of this interface.
+ *
+ * @return the number (identifier) of this interface
+ */
+ public byte getBInterfaceNumber() {
+ return bInterfaceNumber;
+ }
+
+ /**
+ * Returns the protocol code (Assigned by www.usb.org).
+ *
+ * @return the protocol code
+ */
+ public byte getBInterfaceProtocol() {
+ return bInterfaceProtocol;
+ }
+
+ /**
+ * Returns the subclass code (Assigned by www.usb.org).
+ *
+ * @return the subclass code
+ */
+ public byte getBInterfaceSubClass() {
+ return bInterfaceSubClass;
+ }
+
+ /**
+ * Returns the number of endpoints used for this interface.
+ *
+ * @return the number of endpoints used for this interface
+ */
+ public byte getBNumEndpoints() {
+ return bNumEndpoints;
+ }
+
+ /**
+ * Returns an array of endpoint descriptors.
+ *
+ * @return an array of endpoint descriptors
+ */
+ public Usb_Endpoint_Descriptor[] getEndpoint() {
+ return endpoint;
+ }
+
+ /**
+ * Returns the data of extra descriptor(s) if available.
+ *
+ * @return null or a byte array with the extra descriptor data
+ */
+ public byte[] getExtra() {
+ return extra;
+ }
+
+ /**
+ * Returns the number of bytes of the extra descriptor.
+ *
+ * @return the number of bytes of the extra descriptor
+ */
+ public int getExtralen() {
+ return extralen;
+ }
+
+ /**
+ * Returns the index of the String descriptor describing this interface.
+ *
+ * @return the index of the String descriptor
+ */
+ public byte getIInterface() {
+ return iInterface;
+ }
+}
diff --git a/java/src/ch/ntb/usb/Utils.java b/src/main/java/ch/ntb/usb.r273/Utils.java
similarity index 96%
rename from java/src/ch/ntb/usb/Utils.java
rename to src/main/java/ch/ntb/usb.r273/Utils.java
index e14591d..d13a5ba 100644
--- a/java/src/ch/ntb/usb/Utils.java
+++ b/src/main/java/ch/ntb/usb.r273/Utils.java
@@ -1,60 +1,60 @@
-/*
- * Java libusb wrapper
- * Copyright (c) 2005-2006 Andreas Schläpfer
- *
- * http://libusbjava.sourceforge.net
- * This library is covered by the LGPL, read LGPL.txt for details.
- */
-package ch.ntb.usb;
-
-import java.io.PrintStream;
-
-public class Utils {
-
- public static void logBus(Usb_Bus bus) {
- logBus(bus, System.out);
- }
-
- public static void logBus(Usb_Bus bus, PrintStream out) {
- Usb_Bus usb_Bus = bus;
- while (usb_Bus != null) {
- out.println(usb_Bus.toString());
- Usb_Device dev = usb_Bus.getDevices();
- while (dev != null) {
- out.println("\t" + dev.toString());
- // Usb_Device_Descriptor
- Usb_Device_Descriptor defDesc = dev.getDescriptor();
- out.println("\t\t" + defDesc.toString());
- // Usb_Config_Descriptor
- Usb_Config_Descriptor[] confDesc = dev.getConfig();
- for (int i = 0; i < confDesc.length; i++) {
- out.println("\t\t" + confDesc[i].toString());
- Usb_Interface[] int_ = confDesc[i].getInterface();
- if (int_ != null) {
- for (int j = 0; j < int_.length; j++) {
- out.println("\t\t\t" + int_[j].toString());
- Usb_Interface_Descriptor[] intDesc = int_[j]
- .getAltsetting();
- if (intDesc != null) {
- for (int k = 0; k < intDesc.length; k++) {
- out.println("\t\t\t\t"
- + intDesc[k].toString());
- Usb_Endpoint_Descriptor[] epDesc = intDesc[k]
- .getEndpoint();
- if (epDesc != null) {
- for (int e = 0; e < epDesc.length; e++) {
- out.println("\t\t\t\t\t"
- + epDesc[e].toString());
- }
- }
- }
- }
- }
- }
- }
- dev = dev.getNext();
- }
- usb_Bus = usb_Bus.getNext();
- }
- }
-}
+/*
+ * Java libusb wrapper
+ * Copyright (c) 2005-2006 Andreas Schläpfer
+ *
+ * http://libusbjava.sourceforge.net
+ * This library is covered by the LGPL, read LGPL.txt for details.
+ */
+package ch.ntb.usb;
+
+import java.io.PrintStream;
+
+public class Utils {
+
+ public static void logBus(Usb_Bus bus) {
+ logBus(bus, System.out);
+ }
+
+ public static void logBus(Usb_Bus bus, PrintStream out) {
+ Usb_Bus usb_Bus = bus;
+ while (usb_Bus != null) {
+ out.println(usb_Bus.toString());
+ Usb_Device dev = usb_Bus.getDevices();
+ while (dev != null) {
+ out.println("\t" + dev.toString());
+ // Usb_Device_Descriptor
+ Usb_Device_Descriptor defDesc = dev.getDescriptor();
+ out.println("\t\t" + defDesc.toString());
+ // Usb_Config_Descriptor
+ Usb_Config_Descriptor[] confDesc = dev.getConfig();
+ for (int i = 0; i < confDesc.length; i++) {
+ out.println("\t\t" + confDesc[i].toString());
+ Usb_Interface[] int_ = confDesc[i].getInterface();
+ if (int_ != null) {
+ for (int j = 0; j < int_.length; j++) {
+ out.println("\t\t\t" + int_[j].toString());
+ Usb_Interface_Descriptor[] intDesc = int_[j]
+ .getAltsetting();
+ if (intDesc != null) {
+ for (int k = 0; k < intDesc.length; k++) {
+ out.println("\t\t\t\t"
+ + intDesc[k].toString());
+ Usb_Endpoint_Descriptor[] epDesc = intDesc[k]
+ .getEndpoint();
+ if (epDesc != null) {
+ for (int e = 0; e < epDesc.length; e++) {
+ out.println("\t\t\t\t\t"
+ + epDesc[e].toString());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ dev = dev.getNext();
+ }
+ usb_Bus = usb_Bus.getNext();
+ }
+ }
+}
diff --git a/java/src/ch/ntb/usb/logger/LogUtil.java b/src/main/java/ch/ntb/usb.r273/logger/LogUtil.java
similarity index 96%
rename from java/src/ch/ntb/usb/logger/LogUtil.java
rename to src/main/java/ch/ntb/usb.r273/logger/LogUtil.java
index f227a14..998b602 100644
--- a/java/src/ch/ntb/usb/logger/LogUtil.java
+++ b/src/main/java/ch/ntb/usb.r273/logger/LogUtil.java
@@ -1,135 +1,135 @@
-/*
- * Java libusb wrapper
- * Copyright (c) 2005-2006 Andreas Schläpfer
- *
- * http://libusbjava.sourceforge.net
- * This library is covered by the LGPL, read LGPL.txt for details.
- */
-package ch.ntb.usb.logger;
-
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogManager;
-import java.util.logging.Logger;
-
-public class LogUtil {
-
- // debug this class
- private static final boolean debugLogUtil = false;
-
- private static final String PLUGIN_ID = "ch.ntb.usb";
- private static final String PROPERTIES_FILE = ".configure";
- private static final String LOGGER_WARNING = "Warning in class "
- + LogUtil.class.getName()
- + ": could not load the logger properties file " + PROPERTIES_FILE;
-
- private static boolean debugEnabled;
-
- static {
- createLoggersFromProperties();
- }
-
- private static void debugMsg(String method, String message) {
- if (debugLogUtil) {
- System.out.println(method + ": " + message);
- }
- }
-
- public static void setLevel(Logger logger, Level loglevel) {
- Handler[] h = logger.getHandlers();
- for (int i = 0; i < h.length; i++) {
- System.out.println("setLevel " + loglevel.toString());
- h[i].setLevel(loglevel);
- }
- logger.setLevel(loglevel);
- }
-
- public static Logger getLogger(String name) {
- debugMsg("getLogger", name);
- LogManager manager = LogManager.getLogManager();
- // check if logger is already registered
- Logger logger = manager.getLogger(name);
- if (logger == null) {
- logger = Logger.getLogger(name);
- setLevel(logger, Level.OFF);
- manager.addLogger(logger);
- debugMsg("getLogger", "creating new logger");
- }
- if (logger.getLevel() == null) {
- debugMsg("getLogger", "level == null -> setLevel to OFF ");
- setLevel(logger, Level.OFF);
- }
- debugMsg("getLogger", "logLevel " + logger.getLevel().getName());
- return logger;
- }
-
- private static void initLevel(Logger logger, Level loglevel) {
- Handler[] h = logger.getHandlers();
- for (int i = 0; i < h.length; i++) {
- logger.removeHandler(h[i]);
- }
- Handler console = new ConsoleHandler();
- console.setLevel(loglevel);
- logger.addHandler(console);
- logger.setLevel(loglevel);
- logger.setUseParentHandlers(false);
- }
-
- private static void createLoggersFromProperties() {
- try {
- debugMsg(LogUtil.class.getName(), "createLoggersFromProperties");
- InputStream is = LogUtil.class.getClassLoader()
- .getResourceAsStream(PROPERTIES_FILE);
- if (is == null) {
- System.err.println(LOGGER_WARNING);
- } else {
- Properties prop = new Properties();
- prop.load(is);
- debugMsg("createLoggersFromProperties",
- "properties file loaded: " + PROPERTIES_FILE);
- debugMsg("createLoggersFromProperties", "file content:\n"
- + prop.toString());
- // get global debug enable flag
- debugEnabled = Boolean.parseBoolean(prop.getProperty(PLUGIN_ID
- + "/debug"));
- debugMsg("createLoggersFromProperties", "debuging enabled: "
- + debugEnabled);
- // get and configure loggers
- boolean moreLoggers = true;
- int loggerCount = 0;
- while (moreLoggers) {
- String loggerProp = prop.getProperty(PLUGIN_ID
- + "/debug/logger" + loggerCount);
- loggerCount++;
- if (loggerProp != null) {
- // parse string and get logger name and log level
- int slashIndex = loggerProp.indexOf('/');
- String loggerName = loggerProp.substring(0, slashIndex)
- .trim();
- String logLevel = loggerProp.substring(slashIndex + 1,
- loggerProp.length());
- // register logger
- Level level;
- if (debugEnabled) {
- level = Level.parse(logLevel);
- } else {
- level = Level.OFF;
- }
- Logger logger = getLogger(loggerName);
- initLevel(logger, level);
- debugMsg("createLoggersFromProperties",
- "create logger " + loggerName + " with level "
- + level.toString());
- } else {
- moreLoggers = false;
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
+/*
+ * Java libusb wrapper
+ * Copyright (c) 2005-2006 Andreas Schläpfer
+ *
+ * http://libusbjava.sourceforge.net
+ * This library is covered by the LGPL, read LGPL.txt for details.
+ */
+package ch.ntb.usb.logger;
+
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+public class LogUtil {
+
+ // debug this class
+ private static final boolean debugLogUtil = false;
+
+ private static final String PLUGIN_ID = "ch.ntb.usb";
+ private static final String PROPERTIES_FILE = ".configure";
+ private static final String LOGGER_WARNING = "Warning in class "
+ + LogUtil.class.getName()
+ + ": could not load the logger properties file " + PROPERTIES_FILE;
+
+ private static boolean debugEnabled;
+
+ static {
+ createLoggersFromProperties();
+ }
+
+ private static void debugMsg(String method, String message) {
+ if (debugLogUtil) {
+ System.out.println(method + ": " + message);
+ }
+ }
+
+ public static void setLevel(Logger logger, Level loglevel) {
+ Handler[] h = logger.getHandlers();
+ for (int i = 0; i < h.length; i++) {
+ System.out.println("setLevel " + loglevel.toString());
+ h[i].setLevel(loglevel);
+ }
+ logger.setLevel(loglevel);
+ }
+
+ public static Logger getLogger(String name) {
+ debugMsg("getLogger", name);
+ LogManager manager = LogManager.getLogManager();
+ // check if logger is already registered
+ Logger logger = manager.getLogger(name);
+ if (logger == null) {
+ logger = Logger.getLogger(name);
+ setLevel(logger, Level.OFF);
+ manager.addLogger(logger);
+ debugMsg("getLogger", "creating new logger");
+ }
+ if (logger.getLevel() == null) {
+ debugMsg("getLogger", "level == null -> setLevel to OFF ");
+ setLevel(logger, Level.OFF);
+ }
+ debugMsg("getLogger", "logLevel " + logger.getLevel().getName());
+ return logger;
+ }
+
+ private static void initLevel(Logger logger, Level loglevel) {
+ Handler[] h = logger.getHandlers();
+ for (int i = 0; i < h.length; i++) {
+ logger.removeHandler(h[i]);
+ }
+ Handler console = new ConsoleHandler();
+ console.setLevel(loglevel);
+ logger.addHandler(console);
+ logger.setLevel(loglevel);
+ logger.setUseParentHandlers(false);
+ }
+
+ private static void createLoggersFromProperties() {
+ try {
+ debugMsg(LogUtil.class.getName(), "createLoggersFromProperties");
+ InputStream is = LogUtil.class.getClassLoader()
+ .getResourceAsStream(PROPERTIES_FILE);
+ if (is == null) {
+ System.err.println(LOGGER_WARNING);
+ } else {
+ Properties prop = new Properties();
+ prop.load(is);
+ debugMsg("createLoggersFromProperties",
+ "properties file loaded: " + PROPERTIES_FILE);
+ debugMsg("createLoggersFromProperties", "file content:\n"
+ + prop.toString());
+ // get global debug enable flag
+ debugEnabled = Boolean.parseBoolean(prop.getProperty(PLUGIN_ID
+ + "/debug"));
+ debugMsg("createLoggersFromProperties", "debuging enabled: "
+ + debugEnabled);
+ // get and configure loggers
+ boolean moreLoggers = true;
+ int loggerCount = 0;
+ while (moreLoggers) {
+ String loggerProp = prop.getProperty(PLUGIN_ID
+ + "/debug/logger" + loggerCount);
+ loggerCount++;
+ if (loggerProp != null) {
+ // parse string and get logger name and log level
+ int slashIndex = loggerProp.indexOf('/');
+ String loggerName = loggerProp.substring(0, slashIndex)
+ .trim();
+ String logLevel = loggerProp.substring(slashIndex + 1,
+ loggerProp.length());
+ // register logger
+ Level level;
+ if (debugEnabled) {
+ level = Level.parse(logLevel);
+ } else {
+ level = Level.OFF;
+ }
+ Logger logger = getLogger(loggerName);
+ initLevel(logger, level);
+ debugMsg("createLoggersFromProperties",
+ "create logger " + loggerName + " with level "
+ + level.toString());
+ } else {
+ moreLoggers = false;
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/java/src/ch/ntb/usb/logger/package.html b/src/main/java/ch/ntb/usb.r273/logger/package.html
similarity index 94%
rename from java/src/ch/ntb/usb/logger/package.html
rename to src/main/java/ch/ntb/usb.r273/logger/package.html
index 0fbe441..fe57a92 100644
--- a/java/src/ch/ntb/usb/logger/package.html
+++ b/src/main/java/ch/ntb/usb.r273/logger/package.html
@@ -1,16 +1,16 @@
-
-
-
-
-
-Logging related classes.
-
-Related Resources
-
-For more information about this project visit
-http://libusbjava.sourceforge.net
-.
-
-
-
+
+
+
+
+
+Logging related classes.
+
+Related Resources
+
+For more information about this project visit
+http://libusbjava.sourceforge.net
+.
+
+
+
diff --git a/java/src/ch/ntb/usb/package.html b/src/main/java/ch/ntb/usb.r273/package.html
similarity index 95%
rename from java/src/ch/ntb/usb/package.html
rename to src/main/java/ch/ntb/usb.r273/package.html
index e698310..147866d 100644
--- a/java/src/ch/ntb/usb/package.html
+++ b/src/main/java/ch/ntb/usb.r273/package.html
@@ -1,26 +1,26 @@
-
-
-
-
-
-Includes the main classes for the Java libusb wrapper.
-
-LibusbJava.java
-is the JNI class to the
-LibusbJava.dll
-. Every class starting with
-Usb_
-represents a descriptor of the bus structure which is retrieved by
-calling
-LibusbJava.usb_get_busses()
-.
-
-Related Resources
-
-For more information about this project visit
-http://libusbjava.sourceforge.net
-.
-
-
-
+
+
+
+
+
+Includes the main classes for the Java libusb wrapper.
+
+LibusbJava.java
+is the JNI class to the
+LibusbJava.dll
+. Every class starting with
+Usb_
+represents a descriptor of the bus structure which is retrieved by
+calling
+LibusbJava.usb_get_busses()
+.
+
+Related Resources
+
+For more information about this project visit
+http://libusbjava.sourceforge.net
+.
+
+
+
diff --git a/java/src/ch/ntb/usb/usbView/UsbTreeModel.java b/src/main/java/ch/ntb/usb.r273/usbView/UsbTreeModel.java
similarity index 97%
rename from java/src/ch/ntb/usb/usbView/UsbTreeModel.java
rename to src/main/java/ch/ntb/usb.r273/usbView/UsbTreeModel.java
index 26ddb43..8e4b1ca 100644
--- a/java/src/ch/ntb/usb/usbView/UsbTreeModel.java
+++ b/src/main/java/ch/ntb/usb.r273/usbView/UsbTreeModel.java
@@ -1,495 +1,495 @@
-/*
- * Java libusb wrapper
- * Copyright (c) 2005-2006 Andreas Schläpfer
- *
- * http://libusbjava.sourceforge.net
- * This library is covered by the LGPL, read LGPL.txt for details.
- */
-package ch.ntb.usb.usbView;
-
-import java.util.Vector;
-
-import javax.swing.JTextArea;
-import javax.swing.JTree;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-
-import ch.ntb.usb.LibusbJava;
-import ch.ntb.usb.Usb_Bus;
-import ch.ntb.usb.Usb_Config_Descriptor;
-import ch.ntb.usb.Usb_Device;
-import ch.ntb.usb.Usb_Device_Descriptor;
-import ch.ntb.usb.Usb_Endpoint_Descriptor;
-import ch.ntb.usb.Usb_Interface;
-import ch.ntb.usb.Usb_Interface_Descriptor;
-
-public class UsbTreeModel implements TreeModel, TreeSelectionListener {
-
- private Usb_Bus rootBus;
-
- private static final String USB_ROOT = "USB";
-
- private JTextArea textArea;
-
- private Vector treeModelListeners = new Vector();
-
- /**
- * Default constructor.
- *
- * @param rootBus
- * the root bus from which the data is read
- * @param textArea
- * the text area to which the data is written
- */
- public UsbTreeModel(Usb_Bus rootBus, JTextArea textArea) {
- this.rootBus = rootBus;
- this.textArea = textArea;
- }
-
- /**
- * Returns the root of the tree.
- */
- public Object getRoot() {
- return USB_ROOT;
- }
-
- /**
- * Returns the child of parent at index index in the parent's child array.
- */
- public Object getChild(Object parent, int index) {
-
- if (parent instanceof String && ((String) parent).compareTo(USB_ROOT) == 0)
- {
- Usb_Bus curBus = rootBus;
-
- for (int i = 0; curBus != null; curBus = curBus.getNext(), i++)
- {
- if (i == index)
- return curBus;
- }
- }
-
- else if (parent instanceof Usb_Bus) {
- Usb_Device device = ((Usb_Bus) parent).getDevices();
- int count = 0;
- while (device != null) {
- if (count == index)
- return device;
- count++;
- device = device.getNext();
- }
- return null;
- } else if (parent instanceof Usb_Device) {
- Usb_Device dev = (Usb_Device) parent;
- // return the Usb_Device_Descriptor at index 0
- if (index == 0) {
- return dev.getDescriptor();
- }
- Usb_Config_Descriptor[] confDescs = dev.getConfig();
- if (index >= confDescs.length + 1)
- return null;
- return confDescs[index - 1];
- } else if (parent instanceof Usb_Config_Descriptor) {
- Usb_Interface[] intDescs = ((Usb_Config_Descriptor) parent)
- .getInterface();
- if (index >= intDescs.length)
- return null;
- return intDescs[index];
- } else if (parent instanceof Usb_Interface) {
- Usb_Interface_Descriptor[] altSettings = ((Usb_Interface) parent)
- .getAltsetting();
- if (index >= altSettings.length)
- return null;
- return altSettings[index];
- } else if (parent instanceof Usb_Interface_Descriptor) {
- Usb_Endpoint_Descriptor[] endpoints = ((Usb_Interface_Descriptor) parent)
- .getEndpoint();
- if (index >= endpoints.length)
- return null;
- return endpoints[index];
- }
- return null;
- }
-
- /**
- * Returns the number of children of parent.
- */
- public int getChildCount(Object parent)
- {
- if (parent instanceof String && ((String) parent).compareTo(USB_ROOT) == 0)
- {
- int count = 0;
-
- Usb_Bus curBus = rootBus;
-
- for (; curBus != null; curBus = curBus.getNext())
- {
- count++;
- }
-
- return count;
-
- }
- else if (parent instanceof Usb_Bus) {
- Usb_Device device = ((Usb_Bus) parent).getDevices();
- int count = 0;
- while (device != null) {
- count++;
- device = device.getNext();
- }
- return count;
- } else if (parent instanceof Usb_Device) {
- // add the Usb_Device_Descriptor
- return ((Usb_Device) parent).getConfig().length + 1;
- } else if (parent instanceof Usb_Config_Descriptor) {
- return ((Usb_Config_Descriptor) parent).getInterface().length;
- } else if (parent instanceof Usb_Interface) {
- return ((Usb_Interface) parent).getAltsetting().length;
- } else if (parent instanceof Usb_Interface_Descriptor) {
- return ((Usb_Interface_Descriptor) parent).getEndpoint().length;
- }
- return 0;
- }
-
- /**
- * Returns true if node is a leaf.
- */
- public boolean isLeaf(Object node) {
- return false;
- }
-
- /**
- * Messaged when the user has altered the value for the item identified by
- * path to newValue. Not used by this model.
- */
- public void valueForPathChanged(TreePath path, Object newValue) {
- System.out.println("*** valueForPathChanged : " + path + " --> "
- + newValue);
- }
-
- /**
- * Returns the index of child in parent.
- */
- public int getIndexOfChild(Object parent, Object child) {
- return 0;
- }
-
- public void addTreeModelListener(TreeModelListener l) {
- treeModelListeners.addElement(l);
- }
-
- public void removeTreeModelListener(TreeModelListener l) {
- treeModelListeners.removeElement(l);
- }
-
- /**
- * The only event raised by this model is TreeStructureChanged with the root
- * as path, i.e. the whole tree has changed.
- */
- protected void fireTreeStructureChanged(Usb_Bus newRootBus) {
- rootBus = newRootBus;
- int len = treeModelListeners.size();
- TreeModelEvent e = new TreeModelEvent(this, new Object[] { newRootBus });
- for (int i = 0; i < len; i++) {
- treeModelListeners.elementAt(i).treeStructureChanged(e);
- }
- }
-
- public void valueChanged(TreeSelectionEvent e) {
- JTree tree = (JTree) e.getSource();
- Object component = tree.getLastSelectedPathComponent();
- if (component instanceof Usb_Bus) {
- Usb_Bus bus = (Usb_Bus) component;
- StringBuffer sb = new StringBuffer("Usb_Bus\n");
- sb.append("\tdirname: " + bus.getDirname() + "\n");
- sb.append("\tlocation: 0x" + Long.toHexString(bus.getLocation())
- + "\n");
- textArea.setText(sb.toString());
- } else if (component instanceof Usb_Device) {
- Usb_Device device = (Usb_Device) component;
- StringBuffer sb = new StringBuffer("Usb_Device\n");
- sb.append("\tfilename: " + device.getFilename() + "\n");
- sb.append("\tdevnum: " + device.getDevnum() + "\n");
- sb.append("\tnum_children: " + device.getNumChildren() + "\n");
- textArea.setText(sb.toString());
- } else if (component instanceof Usb_Device_Descriptor) {
- Usb_Device_Descriptor devDesc = (Usb_Device_Descriptor) component;
- StringBuffer sb = new StringBuffer("Usb_Device_Descriptor\n");
- sb.append("\tblenght: 0x"
- + Integer.toHexString(devDesc.getBLength() & 0xFF) + "\n");
- sb.append("\tbDescriptorType: 0x"
- + Integer.toHexString(devDesc.getBDescriptorType() & 0xFF)
- + "\n");
- sb.append("\tbcdUSB: 0x"
- + Integer.toHexString(devDesc.getBcdUSB() & 0xFFFF) + "\n");
- sb.append("\tbDeviceClass: 0x"
- + Integer.toHexString(devDesc.getBDeviceClass() & 0xFF)
- + "\n");
- sb.append("\tbDeviceSubClass: 0x"
- + Integer.toHexString(devDesc.getBDeviceSubClass() & 0xFF)
- + "\n");
- sb.append("\tbDeviceProtocol: 0x"
- + Integer.toHexString(devDesc.getBDeviceProtocol() & 0xFF)
- + "\n");
- sb.append("\tbMaxPacketSize0: 0x"
- + Integer.toHexString(devDesc.getBMaxPacketSize0() & 0xFF)
- + " (" + devDesc.getBMaxPacketSize0() + ")\n");
- sb.append("\tidVendor: 0x"
- + Integer.toHexString(devDesc.getIdVendor() & 0xFFFF)
- + "\n");
- sb.append("\tidProduct: 0x"
- + Integer.toHexString(devDesc.getIdProduct() & 0xFFFF)
- + "\n");
- sb
- .append("\tbcdDevice: 0x"
- + Integer
- .toHexString(devDesc.getBcdDevice() & 0xFF)
- + "\n");
- sb.append("\tiManufacturer: 0x"
- + Integer.toHexString(devDesc.getIManufacturer() & 0xFF)
- + "\n");
- sb.append("\tiProduct: 0x"
- + Integer.toHexString(devDesc.getIProduct()) + "\n");
- sb.append("\tiSerialNumber: 0x"
- + Integer.toHexString(devDesc.getISerialNumber() & 0xFF)
- + "\n");
- sb
- .append("\tbNumConfigurations: 0x"
- + Integer.toHexString(devDesc
- .getBNumConfigurations() & 0xFF) + "\n");
- // get device handle to retrieve string descriptors
- Usb_Bus bus = rootBus;
- while (bus != null) {
- Usb_Device dev = bus.getDevices();
- while (dev != null) {
- Usb_Device_Descriptor tmpDevDesc = dev.getDescriptor();
- if ((dev.getDescriptor() != null)
- && ((dev.getDescriptor().getIManufacturer() > 0)
- || (dev.getDescriptor().getIProduct() > 0) || (dev
- .getDescriptor().getISerialNumber() > 0))) {
- if (tmpDevDesc.equals(devDesc)) {
- long handle = LibusbJava.usb_open(dev);
- sb.append("\nString descriptors\n");
- if (handle <= 0) {
- sb.append("\terror opening the device\n");
- break;
- }
- if (dev.getDescriptor().getIManufacturer() > 0) {
- String manufacturer = LibusbJava
- .usb_get_string_simple(handle, devDesc
- .getIManufacturer());
- if (manufacturer == null)
- manufacturer = "unable to fetch manufacturer string";
- sb.append("\tiManufacturer: " + manufacturer
- + "\n");
- }
- if (dev.getDescriptor().getIProduct() > 0) {
- String product = LibusbJava
- .usb_get_string_simple(handle, devDesc
- .getIProduct());
- if (product == null)
- product = "unable to fetch product string";
- sb.append("\tiProduct: " + product + "\n");
- }
- if (dev.getDescriptor().getISerialNumber() > 0) {
- String serialNumber = LibusbJava
- .usb_get_string_simple(handle, devDesc
- .getISerialNumber());
- if (serialNumber == null)
- serialNumber = "unable to fetch serial number string";
- sb.append("\tiSerialNumber: " + serialNumber
- + "\n");
- }
- LibusbJava.usb_close(handle);
- }
- }
- dev = dev.getNext();
- }
- bus = bus.getNext();
- }
- textArea.setText(sb.toString());
- } else if (component instanceof Usb_Config_Descriptor) {
- Usb_Config_Descriptor confDesc = (Usb_Config_Descriptor) component;
- StringBuffer sb = new StringBuffer("Usb_Config_Descriptor\n");
- sb.append("\tblenght: 0x"
- + Integer.toHexString(confDesc.getBLength()) + "\n");
- sb.append("\tbDescriptorType: 0x"
- + Integer.toHexString(confDesc.getBDescriptorType() & 0xFF)
- + "\n");
- sb.append("\tbNumInterfaces: 0x"
- + Integer.toHexString(confDesc.getBNumInterfaces() & 0xFF)
- + "\n");
- sb
- .append("\tbConfigurationValue: 0x"
- + Integer.toHexString(confDesc
- .getBConfigurationValue() & 0xFF) + "\n");
- sb.append("\tiConfiguration: 0x"
- + Integer.toHexString(confDesc.getIConfiguration() & 0xFF)
- + "\n");
- sb.append("\tbmAttributes: 0x"
- + Integer.toHexString(confDesc.getBmAttributes() & 0xFF)
- + "\n");
- sb.append("\tMaxPower [mA]: 0x"
- + Integer.toHexString(confDesc.getMaxPower() & 0xFF) + " ("
- + confDesc.getMaxPower() + ")\n");
- sb.append("\textralen: 0x"
- + Integer.toHexString(confDesc.getExtralen()) + "\n");
- sb.append("\textra: " + extraDescriptorToString(confDesc.getExtra()) + "\n");
- // get device handle to retrieve string descriptors
- Usb_Bus bus = rootBus;
- while (bus != null) {
- Usb_Device dev = bus.getDevices();
- while (dev != null) {
- Usb_Config_Descriptor[] tmpConfDesc = dev.getConfig();
- for (int i = 0; i < tmpConfDesc.length; i++) {
- if ((tmpConfDesc.equals(confDesc))
- && (confDesc.getIConfiguration() > 0)) {
- long handle = LibusbJava.usb_open(dev);
- sb.append("\nString descriptors\n");
- if (handle <= 0) {
- sb.append("\terror opening the device\n");
- break;
- }
- String configuration = LibusbJava
- .usb_get_string_simple(handle, confDesc
- .getIConfiguration());
- if (configuration == null)
- configuration = "unable to fetch configuration string";
- sb.append("\tiConfiguration: " + configuration
- + "\n");
-
- LibusbJava.usb_close(handle);
-
- }
- }
- dev = dev.getNext();
- }
- bus = bus.getNext();
- }
- textArea.setText(sb.toString());
- } else if (component instanceof Usb_Interface) {
- Usb_Interface int_ = (Usb_Interface) component;
- StringBuffer sb = new StringBuffer("Usb_Interface\n");
- sb.append("\tnum_altsetting: 0x"
- + Integer.toHexString(int_.getNumAltsetting()) + "\n");
- sb.append("\taltsetting: " + int_.getAltsetting() + "\n");
- textArea.setText(sb.toString());
- } else if (component instanceof Usb_Interface_Descriptor) {
- Usb_Interface_Descriptor intDesc = (Usb_Interface_Descriptor) component;
- StringBuffer sb = new StringBuffer("Usb_Interface_Descriptor\n");
- sb.append("\tblenght: 0x"
- + Integer.toHexString(intDesc.getBLength() & 0xFF) + "\n");
- sb.append("\tbDescriptorType: 0x"
- + Integer.toHexString(intDesc.getBDescriptorType() & 0xFF)
- + "\n");
- sb.append("\tbInterfaceNumber: 0x"
- + Integer.toHexString(intDesc.getBInterfaceNumber() & 0xFF)
- + "\n");
- sb.append("\tbAlternateSetting: 0x"
- + Integer
- .toHexString(intDesc.getBAlternateSetting() & 0xFF)
- + "\n");
- sb.append("\tbNumEndpoints: 0x"
- + Integer.toHexString(intDesc.getBNumEndpoints() & 0xFF)
- + "\n");
- sb.append("\tbInterfaceClass: 0x"
- + Integer.toHexString(intDesc.getBInterfaceClass() & 0xFF)
- + "\n");
- sb
- .append("\tbInterfaceSubClass: 0x"
- + Integer.toHexString(intDesc
- .getBInterfaceSubClass() & 0xFF) + "\n");
- sb
- .append("\tbInterfaceProtocol: 0x"
- + Integer.toHexString(intDesc
- .getBInterfaceProtocol() & 0xFF) + "\n");
- sb.append("\tiInterface: 0x"
- + Integer.toHexString(intDesc.getIInterface()) + "\n");
- sb.append("\textralen: 0x"
- + Integer.toHexString(intDesc.getExtralen()) + "\n");
- sb.append("\textra: " + extraDescriptorToString(intDesc.getExtra()) + "\n");
- // get device handle to retrieve string descriptors
- Usb_Bus bus = rootBus;
- while (bus != null) {
- Usb_Device dev = bus.getDevices();
- while (dev != null) {
- Usb_Config_Descriptor[] confDescs = dev.getConfig();
- for (int i = 0; i < confDescs.length; i++) {
- Usb_Interface[] ints = confDescs[i].getInterface();
- for (int j = 0; j < ints.length; j++) {
- Usb_Interface_Descriptor[] tmpIntDescs = ints[j]
- .getAltsetting();
- for (int k = 0; k < ints.length; k++) {
- if (i < tmpIntDescs.length && tmpIntDescs[i].equals(intDesc)
- && (intDesc.getIInterface() > 0)) {
- long handle = LibusbJava.usb_open(dev);
- sb.append("\nString descriptors\n");
- if (handle <= 0) {
- sb
- .append("\terror opening the device\n");
- break;
- }
- String interface_ = LibusbJava
- .usb_get_string_simple(handle,
- intDesc.getIInterface());
- if (interface_ == null)
- interface_ = "unable to fetch interface string";
- sb.append("\tiInterface: " + interface_
- + "\n");
- LibusbJava.usb_close(handle);
- }
- }
- }
- }
- dev = dev.getNext();
- }
- bus = bus.getNext();
- }
- textArea.setText(sb.toString());
- } else if (component instanceof Usb_Endpoint_Descriptor) {
- Usb_Endpoint_Descriptor epDesc = (Usb_Endpoint_Descriptor) component;
- StringBuffer sb = new StringBuffer("Usb_Endpoint_Descriptor\n");
- sb.append("\tblenght: 0x"
- + Integer.toHexString(epDesc.getBLength() & 0xFF) + "\n");
- sb.append("\tbDescriptorType: 0x"
- + Integer.toHexString(epDesc.getBDescriptorType() & 0xFF)
- + "\n");
- sb.append("\tbEndpointAddress: 0x"
- + Integer.toHexString(epDesc.getBEndpointAddress() & 0xFF)
- + "\n");
- sb.append("\tbmAttributes: 0x"
- + Integer.toHexString(epDesc.getBmAttributes() & 0xFF)
- + "\n");
- sb.append("\twMaxPacketSize: 0x"
- + Integer.toHexString(epDesc.getWMaxPacketSize() & 0xFFFF)
- + " (" + epDesc.getWMaxPacketSize() + ")\n");
- sb.append("\tbInterval: 0x"
- + Integer.toHexString(epDesc.getBInterval() & 0xFF) + "\n");
- sb.append("\tbRefresh: 0x"
- + Integer.toHexString(epDesc.getBRefresh() & 0xFF) + "\n");
- sb.append("\tbSynchAddress: 0x"
- + Integer.toHexString(epDesc.getBSynchAddress()) + "\n");
- sb.append("\textralen: 0x"
- + Integer.toHexString(epDesc.getExtralen()) + "\n");
- sb.append("\textra: " + extraDescriptorToString(epDesc.getExtra()) + "\n");
- textArea.setText(sb.toString());
- }
- }
-
- private String extraDescriptorToString(byte[] extra) {
- if (extra != null) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < extra.length; i++) {
- sb.append("0x");
- sb.append(Integer.toHexString(extra[i] & 0xff));
- sb.append(' ');
- }
- return sb.toString();
- }
- return null;
- }
-}
+/*
+ * Java libusb wrapper
+ * Copyright (c) 2005-2006 Andreas Schläpfer
+ *
+ * http://libusbjava.sourceforge.net
+ * This library is covered by the LGPL, read LGPL.txt for details.
+ */
+package ch.ntb.usb.usbView;
+
+import java.util.Vector;
+
+import javax.swing.JTextArea;
+import javax.swing.JTree;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+
+import ch.ntb.usb.LibusbJava;
+import ch.ntb.usb.Usb_Bus;
+import ch.ntb.usb.Usb_Config_Descriptor;
+import ch.ntb.usb.Usb_Device;
+import ch.ntb.usb.Usb_Device_Descriptor;
+import ch.ntb.usb.Usb_Endpoint_Descriptor;
+import ch.ntb.usb.Usb_Interface;
+import ch.ntb.usb.Usb_Interface_Descriptor;
+
+public class UsbTreeModel implements TreeModel, TreeSelectionListener {
+
+ private Usb_Bus rootBus;
+
+ private static final String USB_ROOT = "USB";
+
+ private JTextArea textArea;
+
+ private Vector treeModelListeners = new Vector();
+
+ /**
+ * Default constructor.
+ *
+ * @param rootBus
+ * the root bus from which the data is read
+ * @param textArea
+ * the text area to which the data is written
+ */
+ public UsbTreeModel(Usb_Bus rootBus, JTextArea textArea) {
+ this.rootBus = rootBus;
+ this.textArea = textArea;
+ }
+
+ /**
+ * Returns the root of the tree.
+ */
+ public Object getRoot() {
+ return USB_ROOT;
+ }
+
+ /**
+ * Returns the child of parent at index index in the parent's child array.
+ */
+ public Object getChild(Object parent, int index) {
+
+ if (parent instanceof String && ((String) parent).compareTo(USB_ROOT) == 0)
+ {
+ Usb_Bus curBus = rootBus;
+
+ for (int i = 0; curBus != null; curBus = curBus.getNext(), i++)
+ {
+ if (i == index)
+ return curBus;
+ }
+ }
+
+ else if (parent instanceof Usb_Bus) {
+ Usb_Device device = ((Usb_Bus) parent).getDevices();
+ int count = 0;
+ while (device != null) {
+ if (count == index)
+ return device;
+ count++;
+ device = device.getNext();
+ }
+ return null;
+ } else if (parent instanceof Usb_Device) {
+ Usb_Device dev = (Usb_Device) parent;
+ // return the Usb_Device_Descriptor at index 0
+ if (index == 0) {
+ return dev.getDescriptor();
+ }
+ Usb_Config_Descriptor[] confDescs = dev.getConfig();
+ if (index >= confDescs.length + 1)
+ return null;
+ return confDescs[index - 1];
+ } else if (parent instanceof Usb_Config_Descriptor) {
+ Usb_Interface[] intDescs = ((Usb_Config_Descriptor) parent)
+ .getInterface();
+ if (index >= intDescs.length)
+ return null;
+ return intDescs[index];
+ } else if (parent instanceof Usb_Interface) {
+ Usb_Interface_Descriptor[] altSettings = ((Usb_Interface) parent)
+ .getAltsetting();
+ if (index >= altSettings.length)
+ return null;
+ return altSettings[index];
+ } else if (parent instanceof Usb_Interface_Descriptor) {
+ Usb_Endpoint_Descriptor[] endpoints = ((Usb_Interface_Descriptor) parent)
+ .getEndpoint();
+ if (index >= endpoints.length)
+ return null;
+ return endpoints[index];
+ }
+ return null;
+ }
+
+ /**
+ * Returns the number of children of parent.
+ */
+ public int getChildCount(Object parent)
+ {
+ if (parent instanceof String && ((String) parent).compareTo(USB_ROOT) == 0)
+ {
+ int count = 0;
+
+ Usb_Bus curBus = rootBus;
+
+ for (; curBus != null; curBus = curBus.getNext())
+ {
+ count++;
+ }
+
+ return count;
+
+ }
+ else if (parent instanceof Usb_Bus) {
+ Usb_Device device = ((Usb_Bus) parent).getDevices();
+ int count = 0;
+ while (device != null) {
+ count++;
+ device = device.getNext();
+ }
+ return count;
+ } else if (parent instanceof Usb_Device) {
+ // add the Usb_Device_Descriptor
+ return ((Usb_Device) parent).getConfig().length + 1;
+ } else if (parent instanceof Usb_Config_Descriptor) {
+ return ((Usb_Config_Descriptor) parent).getInterface().length;
+ } else if (parent instanceof Usb_Interface) {
+ return ((Usb_Interface) parent).getAltsetting().length;
+ } else if (parent instanceof Usb_Interface_Descriptor) {
+ return ((Usb_Interface_Descriptor) parent).getEndpoint().length;
+ }
+ return 0;
+ }
+
+ /**
+ * Returns true if node is a leaf.
+ */
+ public boolean isLeaf(Object node) {
+ return false;
+ }
+
+ /**
+ * Messaged when the user has altered the value for the item identified by
+ * path to newValue. Not used by this model.
+ */
+ public void valueForPathChanged(TreePath path, Object newValue) {
+ System.out.println("*** valueForPathChanged : " + path + " --> "
+ + newValue);
+ }
+
+ /**
+ * Returns the index of child in parent.
+ */
+ public int getIndexOfChild(Object parent, Object child) {
+ return 0;
+ }
+
+ public void addTreeModelListener(TreeModelListener l) {
+ treeModelListeners.addElement(l);
+ }
+
+ public void removeTreeModelListener(TreeModelListener l) {
+ treeModelListeners.removeElement(l);
+ }
+
+ /**
+ * The only event raised by this model is TreeStructureChanged with the root
+ * as path, i.e. the whole tree has changed.
+ */
+ protected void fireTreeStructureChanged(Usb_Bus newRootBus) {
+ rootBus = newRootBus;
+ int len = treeModelListeners.size();
+ TreeModelEvent e = new TreeModelEvent(this, new Object[] { newRootBus });
+ for (int i = 0; i < len; i++) {
+ treeModelListeners.elementAt(i).treeStructureChanged(e);
+ }
+ }
+
+ public void valueChanged(TreeSelectionEvent e) {
+ JTree tree = (JTree) e.getSource();
+ Object component = tree.getLastSelectedPathComponent();
+ if (component instanceof Usb_Bus) {
+ Usb_Bus bus = (Usb_Bus) component;
+ StringBuffer sb = new StringBuffer("Usb_Bus\n");
+ sb.append("\tdirname: " + bus.getDirname() + "\n");
+ sb.append("\tlocation: 0x" + Long.toHexString(bus.getLocation())
+ + "\n");
+ textArea.setText(sb.toString());
+ } else if (component instanceof Usb_Device) {
+ Usb_Device device = (Usb_Device) component;
+ StringBuffer sb = new StringBuffer("Usb_Device\n");
+ sb.append("\tfilename: " + device.getFilename() + "\n");
+ sb.append("\tdevnum: " + device.getDevnum() + "\n");
+ sb.append("\tnum_children: " + device.getNumChildren() + "\n");
+ textArea.setText(sb.toString());
+ } else if (component instanceof Usb_Device_Descriptor) {
+ Usb_Device_Descriptor devDesc = (Usb_Device_Descriptor) component;
+ StringBuffer sb = new StringBuffer("Usb_Device_Descriptor\n");
+ sb.append("\tblenght: 0x"
+ + Integer.toHexString(devDesc.getBLength() & 0xFF) + "\n");
+ sb.append("\tbDescriptorType: 0x"
+ + Integer.toHexString(devDesc.getBDescriptorType() & 0xFF)
+ + "\n");
+ sb.append("\tbcdUSB: 0x"
+ + Integer.toHexString(devDesc.getBcdUSB() & 0xFFFF) + "\n");
+ sb.append("\tbDeviceClass: 0x"
+ + Integer.toHexString(devDesc.getBDeviceClass() & 0xFF)
+ + "\n");
+ sb.append("\tbDeviceSubClass: 0x"
+ + Integer.toHexString(devDesc.getBDeviceSubClass() & 0xFF)
+ + "\n");
+ sb.append("\tbDeviceProtocol: 0x"
+ + Integer.toHexString(devDesc.getBDeviceProtocol() & 0xFF)
+ + "\n");
+ sb.append("\tbMaxPacketSize0: 0x"
+ + Integer.toHexString(devDesc.getBMaxPacketSize0() & 0xFF)
+ + " (" + devDesc.getBMaxPacketSize0() + ")\n");
+ sb.append("\tidVendor: 0x"
+ + Integer.toHexString(devDesc.getIdVendor() & 0xFFFF)
+ + "\n");
+ sb.append("\tidProduct: 0x"
+ + Integer.toHexString(devDesc.getIdProduct() & 0xFFFF)
+ + "\n");
+ sb
+ .append("\tbcdDevice: 0x"
+ + Integer
+ .toHexString(devDesc.getBcdDevice() & 0xFF)
+ + "\n");
+ sb.append("\tiManufacturer: 0x"
+ + Integer.toHexString(devDesc.getIManufacturer() & 0xFF)
+ + "\n");
+ sb.append("\tiProduct: 0x"
+ + Integer.toHexString(devDesc.getIProduct()) + "\n");
+ sb.append("\tiSerialNumber: 0x"
+ + Integer.toHexString(devDesc.getISerialNumber() & 0xFF)
+ + "\n");
+ sb
+ .append("\tbNumConfigurations: 0x"
+ + Integer.toHexString(devDesc
+ .getBNumConfigurations() & 0xFF) + "\n");
+ // get device handle to retrieve string descriptors
+ Usb_Bus bus = rootBus;
+ while (bus != null) {
+ Usb_Device dev = bus.getDevices();
+ while (dev != null) {
+ Usb_Device_Descriptor tmpDevDesc = dev.getDescriptor();
+ if ((dev.getDescriptor() != null)
+ && ((dev.getDescriptor().getIManufacturer() > 0)
+ || (dev.getDescriptor().getIProduct() > 0) || (dev
+ .getDescriptor().getISerialNumber() > 0))) {
+ if (tmpDevDesc.equals(devDesc)) {
+ long handle = LibusbJava.usb_open(dev);
+ sb.append("\nString descriptors\n");
+ if (handle <= 0) {
+ sb.append("\terror opening the device\n");
+ break;
+ }
+ if (dev.getDescriptor().getIManufacturer() > 0) {
+ String manufacturer = LibusbJava
+ .usb_get_string_simple(handle, devDesc
+ .getIManufacturer());
+ if (manufacturer == null)
+ manufacturer = "unable to fetch manufacturer string";
+ sb.append("\tiManufacturer: " + manufacturer
+ + "\n");
+ }
+ if (dev.getDescriptor().getIProduct() > 0) {
+ String product = LibusbJava
+ .usb_get_string_simple(handle, devDesc
+ .getIProduct());
+ if (product == null)
+ product = "unable to fetch product string";
+ sb.append("\tiProduct: " + product + "\n");
+ }
+ if (dev.getDescriptor().getISerialNumber() > 0) {
+ String serialNumber = LibusbJava
+ .usb_get_string_simple(handle, devDesc
+ .getISerialNumber());
+ if (serialNumber == null)
+ serialNumber = "unable to fetch serial number string";
+ sb.append("\tiSerialNumber: " + serialNumber
+ + "\n");
+ }
+ LibusbJava.usb_close(handle);
+ }
+ }
+ dev = dev.getNext();
+ }
+ bus = bus.getNext();
+ }
+ textArea.setText(sb.toString());
+ } else if (component instanceof Usb_Config_Descriptor) {
+ Usb_Config_Descriptor confDesc = (Usb_Config_Descriptor) component;
+ StringBuffer sb = new StringBuffer("Usb_Config_Descriptor\n");
+ sb.append("\tblenght: 0x"
+ + Integer.toHexString(confDesc.getBLength()) + "\n");
+ sb.append("\tbDescriptorType: 0x"
+ + Integer.toHexString(confDesc.getBDescriptorType() & 0xFF)
+ + "\n");
+ sb.append("\tbNumInterfaces: 0x"
+ + Integer.toHexString(confDesc.getBNumInterfaces() & 0xFF)
+ + "\n");
+ sb
+ .append("\tbConfigurationValue: 0x"
+ + Integer.toHexString(confDesc
+ .getBConfigurationValue() & 0xFF) + "\n");
+ sb.append("\tiConfiguration: 0x"
+ + Integer.toHexString(confDesc.getIConfiguration() & 0xFF)
+ + "\n");
+ sb.append("\tbmAttributes: 0x"
+ + Integer.toHexString(confDesc.getBmAttributes() & 0xFF)
+ + "\n");
+ sb.append("\tMaxPower [mA]: 0x"
+ + Integer.toHexString(confDesc.getMaxPower() & 0xFF) + " ("
+ + confDesc.getMaxPower() + ")\n");
+ sb.append("\textralen: 0x"
+ + Integer.toHexString(confDesc.getExtralen()) + "\n");
+ sb.append("\textra: " + extraDescriptorToString(confDesc.getExtra()) + "\n");
+ // get device handle to retrieve string descriptors
+ Usb_Bus bus = rootBus;
+ while (bus != null) {
+ Usb_Device dev = bus.getDevices();
+ while (dev != null) {
+ Usb_Config_Descriptor[] tmpConfDesc = dev.getConfig();
+ for (int i = 0; i < tmpConfDesc.length; i++) {
+ if ((tmpConfDesc.equals(confDesc))
+ && (confDesc.getIConfiguration() > 0)) {
+ long handle = LibusbJava.usb_open(dev);
+ sb.append("\nString descriptors\n");
+ if (handle <= 0) {
+ sb.append("\terror opening the device\n");
+ break;
+ }
+ String configuration = LibusbJava
+ .usb_get_string_simple(handle, confDesc
+ .getIConfiguration());
+ if (configuration == null)
+ configuration = "unable to fetch configuration string";
+ sb.append("\tiConfiguration: " + configuration
+ + "\n");
+
+ LibusbJava.usb_close(handle);
+
+ }
+ }
+ dev = dev.getNext();
+ }
+ bus = bus.getNext();
+ }
+ textArea.setText(sb.toString());
+ } else if (component instanceof Usb_Interface) {
+ Usb_Interface int_ = (Usb_Interface) component;
+ StringBuffer sb = new StringBuffer("Usb_Interface\n");
+ sb.append("\tnum_altsetting: 0x"
+ + Integer.toHexString(int_.getNumAltsetting()) + "\n");
+ sb.append("\taltsetting: " + int_.getAltsetting() + "\n");
+ textArea.setText(sb.toString());
+ } else if (component instanceof Usb_Interface_Descriptor) {
+ Usb_Interface_Descriptor intDesc = (Usb_Interface_Descriptor) component;
+ StringBuffer sb = new StringBuffer("Usb_Interface_Descriptor\n");
+ sb.append("\tblenght: 0x"
+ + Integer.toHexString(intDesc.getBLength() & 0xFF) + "\n");
+ sb.append("\tbDescriptorType: 0x"
+ + Integer.toHexString(intDesc.getBDescriptorType() & 0xFF)
+ + "\n");
+ sb.append("\tbInterfaceNumber: 0x"
+ + Integer.toHexString(intDesc.getBInterfaceNumber() & 0xFF)
+ + "\n");
+ sb.append("\tbAlternateSetting: 0x"
+ + Integer
+ .toHexString(intDesc.getBAlternateSetting() & 0xFF)
+ + "\n");
+ sb.append("\tbNumEndpoints: 0x"
+ + Integer.toHexString(intDesc.getBNumEndpoints() & 0xFF)
+ + "\n");
+ sb.append("\tbInterfaceClass: 0x"
+ + Integer.toHexString(intDesc.getBInterfaceClass() & 0xFF)
+ + "\n");
+ sb
+ .append("\tbInterfaceSubClass: 0x"
+ + Integer.toHexString(intDesc
+ .getBInterfaceSubClass() & 0xFF) + "\n");
+ sb
+ .append("\tbInterfaceProtocol: 0x"
+ + Integer.toHexString(intDesc
+ .getBInterfaceProtocol() & 0xFF) + "\n");
+ sb.append("\tiInterface: 0x"
+ + Integer.toHexString(intDesc.getIInterface()) + "\n");
+ sb.append("\textralen: 0x"
+ + Integer.toHexString(intDesc.getExtralen()) + "\n");
+ sb.append("\textra: " + extraDescriptorToString(intDesc.getExtra()) + "\n");
+ // get device handle to retrieve string descriptors
+ Usb_Bus bus = rootBus;
+ while (bus != null) {
+ Usb_Device dev = bus.getDevices();
+ while (dev != null) {
+ Usb_Config_Descriptor[] confDescs = dev.getConfig();
+ for (int i = 0; i < confDescs.length; i++) {
+ Usb_Interface[] ints = confDescs[i].getInterface();
+ for (int j = 0; j < ints.length; j++) {
+ Usb_Interface_Descriptor[] tmpIntDescs = ints[j]
+ .getAltsetting();
+ for (int k = 0; k < ints.length; k++) {
+ if (i < tmpIntDescs.length && tmpIntDescs[i].equals(intDesc)
+ && (intDesc.getIInterface() > 0)) {
+ long handle = LibusbJava.usb_open(dev);
+ sb.append("\nString descriptors\n");
+ if (handle <= 0) {
+ sb
+ .append("\terror opening the device\n");
+ break;
+ }
+ String interface_ = LibusbJava
+ .usb_get_string_simple(handle,
+ intDesc.getIInterface());
+ if (interface_ == null)
+ interface_ = "unable to fetch interface string";
+ sb.append("\tiInterface: " + interface_
+ + "\n");
+ LibusbJava.usb_close(handle);
+ }
+ }
+ }
+ }
+ dev = dev.getNext();
+ }
+ bus = bus.getNext();
+ }
+ textArea.setText(sb.toString());
+ } else if (component instanceof Usb_Endpoint_Descriptor) {
+ Usb_Endpoint_Descriptor epDesc = (Usb_Endpoint_Descriptor) component;
+ StringBuffer sb = new StringBuffer("Usb_Endpoint_Descriptor\n");
+ sb.append("\tblenght: 0x"
+ + Integer.toHexString(epDesc.getBLength() & 0xFF) + "\n");
+ sb.append("\tbDescriptorType: 0x"
+ + Integer.toHexString(epDesc.getBDescriptorType() & 0xFF)
+ + "\n");
+ sb.append("\tbEndpointAddress: 0x"
+ + Integer.toHexString(epDesc.getBEndpointAddress() & 0xFF)
+ + "\n");
+ sb.append("\tbmAttributes: 0x"
+ + Integer.toHexString(epDesc.getBmAttributes() & 0xFF)
+ + "\n");
+ sb.append("\twMaxPacketSize: 0x"
+ + Integer.toHexString(epDesc.getWMaxPacketSize() & 0xFFFF)
+ + " (" + epDesc.getWMaxPacketSize() + ")\n");
+ sb.append("\tbInterval: 0x"
+ + Integer.toHexString(epDesc.getBInterval() & 0xFF) + "\n");
+ sb.append("\tbRefresh: 0x"
+ + Integer.toHexString(epDesc.getBRefresh() & 0xFF) + "\n");
+ sb.append("\tbSynchAddress: 0x"
+ + Integer.toHexString(epDesc.getBSynchAddress()) + "\n");
+ sb.append("\textralen: 0x"
+ + Integer.toHexString(epDesc.getExtralen()) + "\n");
+ sb.append("\textra: " + extraDescriptorToString(epDesc.getExtra()) + "\n");
+ textArea.setText(sb.toString());
+ }
+ }
+
+ private String extraDescriptorToString(byte[] extra) {
+ if (extra != null) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < extra.length; i++) {
+ sb.append("0x");
+ sb.append(Integer.toHexString(extra[i] & 0xff));
+ sb.append(' ');
+ }
+ return sb.toString();
+ }
+ return null;
+ }
+}
diff --git a/java/src/ch/ntb/usb/usbView/UsbView.java b/src/main/java/ch/ntb/usb.r273/usbView/UsbView.java
similarity index 96%
rename from java/src/ch/ntb/usb/usbView/UsbView.java
rename to src/main/java/ch/ntb/usb.r273/usbView/UsbView.java
index dfeed49..c531812 100644
--- a/java/src/ch/ntb/usb/usbView/UsbView.java
+++ b/src/main/java/ch/ntb/usb.r273/usbView/UsbView.java
@@ -1,403 +1,403 @@
-/*
- * Java libusb wrapper
- * Copyright (c) 2005-2006 Andreas Schläpfer
- *
- * http://libusbjava.sourceforge.net
- * This library is covered by the LGPL, read LGPL.txt for details.
- */
-package ch.ntb.usb.usbView;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
-import javax.swing.JTextArea;
-import javax.swing.JTree;
-import javax.swing.KeyStroke;
-import javax.swing.tree.TreePath;
-
-import ch.ntb.usb.LibusbJava;
-import ch.ntb.usb.Usb_Bus;
-import ch.ntb.usb.Usb_Config_Descriptor;
-import ch.ntb.usb.Usb_Device;
-import ch.ntb.usb.Usb_Device_Descriptor;
-import ch.ntb.usb.Usb_Endpoint_Descriptor;
-import ch.ntb.usb.Usb_Interface_Descriptor;
-import ch.ntb.usb.testApp.TestApp;
-import ch.ntb.usb.testApp.TestDevice;
-import ch.ntb.usb.testApp.AbstractDeviceInfo.TransferMode;
-
-public class UsbView extends JFrame {
-
- private static final long serialVersionUID = 4693554326612734263L;
-
- private static final int APP_WIDTH = 600, APP_HIGHT = 800;
-
- private JPanel jContentPane = null;
- private JMenuBar jJMenuBar = null;
- private JMenu commandsMenu = null;
- private JMenuItem exitMenuItem = null;
- private JMenuItem updateMenuItem = null;
- JTree usbTree = null;
- private JSplitPane jSplitPane = null;
-
- private JTextArea jPropertiesArea = null;
-
- UsbTreeModel treeModel;
-
- JPopupMenu testAppPopup;
-
- protected JPopupMenu endpointPopup;
-
- /**
- * This is the default constructor
- */
- public UsbView() {
- super();
- initialize();
- }
-
- /**
- * This method initializes this
- *
- * @return void
- */
- private void initialize() {
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setJMenuBar(getJJMenuBar());
- this.setSize(APP_WIDTH, APP_HIGHT);
- this.setContentPane(getJContentPane());
- this.setTitle("USB View");
- }
-
- /**
- * This method initializes jContentPane
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane() {
- if (jContentPane == null) {
- jContentPane = new JPanel();
- jContentPane.setLayout(new BorderLayout());
- jContentPane.add(getJSplitPane(), java.awt.BorderLayout.CENTER);
- }
- return jContentPane;
- }
-
- /**
- * This method initializes jJMenuBar
- *
- * @return javax.swing.JMenuBar
- */
- private JMenuBar getJJMenuBar() {
- if (jJMenuBar == null) {
- jJMenuBar = new JMenuBar();
- jJMenuBar.add(getFileMenu());
- }
- return jJMenuBar;
- }
-
- /**
- * This method initializes jMenu
- *
- * @return javax.swing.JMenu
- */
- private JMenu getFileMenu() {
- if (commandsMenu == null) {
- commandsMenu = new JMenu();
- commandsMenu.setText("Commands");
- commandsMenu.add(getUpdateMenuItem());
- commandsMenu.add(getExitMenuItem());
- }
- return commandsMenu;
- }
-
- /**
- * This method initializes jMenuItem
- *
- * @return javax.swing.JMenuItem
- */
- private JMenuItem getExitMenuItem() {
- if (exitMenuItem == null) {
- exitMenuItem = new JMenuItem();
- exitMenuItem.setText("Exit");
- exitMenuItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- System.exit(0);
- }
- });
- }
- return exitMenuItem;
- }
-
- /**
- * This method initializes jMenuItem
- *
- * @return javax.swing.JMenuItem
- */
- private JMenuItem getUpdateMenuItem() {
- if (updateMenuItem == null) {
- updateMenuItem = new JMenuItem();
- updateMenuItem.setText("Update");
- updateMenuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_F5, 0, true));
- updateMenuItem
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- // open bus
- LibusbJava.usb_init();
- LibusbJava.usb_find_busses();
- LibusbJava.usb_find_devices();
-
- Usb_Bus bus = LibusbJava.usb_get_busses();
- if (bus != null) {
- treeModel.fireTreeStructureChanged(bus);
- expandAll(usbTree);
- }
- }
- });
- }
- return updateMenuItem;
- }
-
- /**
- * This method initializes usbTree
- *
- * @return javax.swing.JTree
- */
- private JTree getUsbTree() {
- if (usbTree == null) {
- // open bus
- LibusbJava.usb_init();
- LibusbJava.usb_find_busses();
- LibusbJava.usb_find_devices();
-
- Usb_Bus bus = LibusbJava.usb_get_busses();
-
- treeModel = new UsbTreeModel(bus, jPropertiesArea);
- usbTree = new JTree(treeModel);
- expandAll(usbTree);
- usbTree.addTreeSelectionListener(treeModel);
- getJTestAppPopup();
- usbTree.addMouseListener(new MouseAdapter() {
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (e.isPopupTrigger()) {
- Object source = e.getSource();
- if (source instanceof JTree) {
- JTree tree = (JTree) source;
- TreePath path = tree.getPathForLocation(e.getX(), e
- .getY());
- if (path != null
- && (path.getLastPathComponent() instanceof Usb_Interface_Descriptor)) {
- usbTree.setSelectionPath(path);
- testAppPopup.show(tree, e.getX(), e.getY());
- }
- }
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- if (e.isPopupTrigger()) {
- if (e.isPopupTrigger()) {
- Object source = e.getSource();
- if (source instanceof JTree) {
- JTree tree = (JTree) source;
- TreePath path = tree.getPathForLocation(e
- .getX(), e.getY());
- if (path != null
- && (path.getLastPathComponent() instanceof Usb_Interface_Descriptor)) {
- usbTree.setSelectionPath(path);
- testAppPopup.show(tree, e.getX(), e.getY());
- }
- }
- }
- }
- }
- });
- }
- return usbTree;
- }
-
- private void getJTestAppPopup() {
- // Create the popup menu.
- testAppPopup = new JPopupMenu();
- endpointPopup = new JPopupMenu();
- JMenuItem menuItem = new JMenuItem(
- "Start a test application using this interface");
- menuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent e) {
- initAndStartTestApp();
- }
-
- private void initAndStartTestApp() {
- JTree tree = (JTree) testAppPopup.getInvoker();
- TreePath path = tree.getSelectionPath();
- TreePath parent = path;
- Usb_Endpoint_Descriptor[] endpoints = null;
- int altinterface = -1;
- int interface_ = -1;
- int configuration = -1;
- short vendorId = -1;
- short productId = -1;
- while (parent != null
- && !(parent.getLastPathComponent() instanceof Usb_Bus)) {
- Object usbObj = parent.getLastPathComponent();
- if (usbObj instanceof Usb_Interface_Descriptor) {
- Usb_Interface_Descriptor usbIntDesc = (Usb_Interface_Descriptor) usbObj;
- endpoints = usbIntDesc.getEndpoint();
- interface_ = usbIntDesc.getBInterfaceNumber();
- altinterface = usbIntDesc.getBAlternateSetting();
- } else if (usbObj instanceof Usb_Config_Descriptor) {
- configuration = ((Usb_Config_Descriptor) usbObj)
- .getBConfigurationValue();
- } else if (usbObj instanceof Usb_Device) {
- Usb_Device_Descriptor devDesc = ((Usb_Device) usbObj)
- .getDescriptor();
- productId = devDesc.getIdProduct();
- vendorId = devDesc.getIdVendor();
- }
- parent = parent.getParentPath();
- }
- if (parent != null) {
- // present a dialog to select in/out endpoint
- // TODO: present dialog to select in/out endpoint
- Usb_Endpoint_Descriptor[] outEPs = null;
- int nofOutEPs = 0;
- Usb_Endpoint_Descriptor[] inEPs = null;
- int nofInEPs = 0;
-
- if (endpoints != null) {
- outEPs = new Usb_Endpoint_Descriptor[endpoints.length];
- inEPs = new Usb_Endpoint_Descriptor[endpoints.length];
- for (int i = 0; i < endpoints.length; i++) {
- int epAddr = endpoints[i].getBEndpointAddress() & 0xFF;
- if ((epAddr & 0x80) > 0) {
- // is IN endpoint
- inEPs[nofInEPs++] = endpoints[i];
- } else {
- // is OUT endpoint
- outEPs[nofOutEPs++] = endpoints[i];
- }
- }
- }
- // create a new TestDevice
- TestDevice testDevice = new TestDevice();
- testDevice.setIdProduct(productId);
- testDevice.setIdVendor(vendorId);
- testDevice.setAltinterface(altinterface);
- testDevice.setConfiguration(configuration);
- testDevice.setInterface(interface_);
- if (inEPs != null) {
- for (int i = 0; i < nofInEPs; i++) {
- int type = inEPs[i].getBmAttributes() & 0x03;
- switch (type) {
- case Usb_Endpoint_Descriptor.USB_ENDPOINT_TYPE_BULK:
- testDevice.setInEPBulk(inEPs[i]
- .getBEndpointAddress() & 0xff);
- testDevice.setInMode(TransferMode.Bulk);
- break;
- case Usb_Endpoint_Descriptor.USB_ENDPOINT_TYPE_INTERRUPT:
- testDevice.setInEPInt(inEPs[i]
- .getBEndpointAddress() & 0xff);
- testDevice.setInMode(TransferMode.Interrupt);
- break;
- default:
- break;
- }
- }
- }
- if (outEPs != null) {
- for (int i = 0; i < nofOutEPs; i++) {
- int type = outEPs[i].getBmAttributes() & 0x03;
- switch (type) {
- case Usb_Endpoint_Descriptor.USB_ENDPOINT_TYPE_BULK:
- testDevice.setOutEPBulk(outEPs[i]
- .getBEndpointAddress() & 0xff);
- testDevice.setOutMode(TransferMode.Bulk);
- break;
- case Usb_Endpoint_Descriptor.USB_ENDPOINT_TYPE_INTERRUPT:
- testDevice.setOutEPInt(outEPs[i]
- .getBEndpointAddress() & 0xff);
- testDevice.setOutMode(TransferMode.Interrupt);
- break;
- default:
- break;
- }
- }
- }
- // open a new testApp
- TestApp app = new TestApp(testDevice);
- app.setVisible(true);
- } else {
- System.out.println("error, could not find device node");
- // TODO: handle error
- }
- }
- });
- testAppPopup.add(menuItem);
- }
-
- /**
- * This method initializes jSplitPane
- *
- * @return javax.swing.JSplitPane
- */
- private JSplitPane getJSplitPane() {
- if (jSplitPane == null) {
- jSplitPane = new JSplitPane();
- jSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
- jSplitPane.setContinuousLayout(true);
- jSplitPane.setDividerLocation(APP_HIGHT / 2);
- jSplitPane
- .setBottomComponent(createScrollPane(getJPropertiesArea()));
- jSplitPane.setTopComponent(createScrollPane(getUsbTree()));
- }
- return jSplitPane;
- }
-
- /**
- * This method initializes jPropertiesArea
- *
- * @return javax.swing.JTextArea
- */
- private JTextArea getJPropertiesArea() {
- if (jPropertiesArea == null) {
- jPropertiesArea = new JTextArea();
- }
- return jPropertiesArea;
- }
-
- private JScrollPane createScrollPane(Component view) {
- JScrollPane scrollPane = new JScrollPane(view);
- return scrollPane;
- }
-
- /**
- * Launches this application
- */
- public static void main(String[] args) {
- UsbView application = new UsbView();
- application.setVisible(true);
- }
-
- void expandAll(JTree tree) {
- for (int row = 0; row < tree.getRowCount(); row++) {
- tree.expandRow(row);
- }
- }
-}
+/*
+ * Java libusb wrapper
+ * Copyright (c) 2005-2006 Andreas Schläpfer
+ *
+ * http://libusbjava.sourceforge.net
+ * This library is covered by the LGPL, read LGPL.txt for details.
+ */
+package ch.ntb.usb.usbView;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTextArea;
+import javax.swing.JTree;
+import javax.swing.KeyStroke;
+import javax.swing.tree.TreePath;
+
+import ch.ntb.usb.LibusbJava;
+import ch.ntb.usb.Usb_Bus;
+import ch.ntb.usb.Usb_Config_Descriptor;
+import ch.ntb.usb.Usb_Device;
+import ch.ntb.usb.Usb_Device_Descriptor;
+import ch.ntb.usb.Usb_Endpoint_Descriptor;
+import ch.ntb.usb.Usb_Interface_Descriptor;
+import ch.ntb.usb.testApp.TestApp;
+import ch.ntb.usb.testApp.TestDevice;
+import ch.ntb.usb.testApp.AbstractDeviceInfo.TransferMode;
+
+public class UsbView extends JFrame {
+
+ private static final long serialVersionUID = 4693554326612734263L;
+
+ private static final int APP_WIDTH = 600, APP_HIGHT = 800;
+
+ private JPanel jContentPane = null;
+ private JMenuBar jJMenuBar = null;
+ private JMenu commandsMenu = null;
+ private JMenuItem exitMenuItem = null;
+ private JMenuItem updateMenuItem = null;
+ JTree usbTree = null;
+ private JSplitPane jSplitPane = null;
+
+ private JTextArea jPropertiesArea = null;
+
+ UsbTreeModel treeModel;
+
+ JPopupMenu testAppPopup;
+
+ protected JPopupMenu endpointPopup;
+
+ /**
+ * This is the default constructor
+ */
+ public UsbView() {
+ super();
+ initialize();
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ this.setJMenuBar(getJJMenuBar());
+ this.setSize(APP_WIDTH, APP_HIGHT);
+ this.setContentPane(getJContentPane());
+ this.setTitle("USB View");
+ }
+
+ /**
+ * This method initializes jContentPane
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJContentPane() {
+ if (jContentPane == null) {
+ jContentPane = new JPanel();
+ jContentPane.setLayout(new BorderLayout());
+ jContentPane.add(getJSplitPane(), java.awt.BorderLayout.CENTER);
+ }
+ return jContentPane;
+ }
+
+ /**
+ * This method initializes jJMenuBar
+ *
+ * @return javax.swing.JMenuBar
+ */
+ private JMenuBar getJJMenuBar() {
+ if (jJMenuBar == null) {
+ jJMenuBar = new JMenuBar();
+ jJMenuBar.add(getFileMenu());
+ }
+ return jJMenuBar;
+ }
+
+ /**
+ * This method initializes jMenu
+ *
+ * @return javax.swing.JMenu
+ */
+ private JMenu getFileMenu() {
+ if (commandsMenu == null) {
+ commandsMenu = new JMenu();
+ commandsMenu.setText("Commands");
+ commandsMenu.add(getUpdateMenuItem());
+ commandsMenu.add(getExitMenuItem());
+ }
+ return commandsMenu;
+ }
+
+ /**
+ * This method initializes jMenuItem
+ *
+ * @return javax.swing.JMenuItem
+ */
+ private JMenuItem getExitMenuItem() {
+ if (exitMenuItem == null) {
+ exitMenuItem = new JMenuItem();
+ exitMenuItem.setText("Exit");
+ exitMenuItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ System.exit(0);
+ }
+ });
+ }
+ return exitMenuItem;
+ }
+
+ /**
+ * This method initializes jMenuItem
+ *
+ * @return javax.swing.JMenuItem
+ */
+ private JMenuItem getUpdateMenuItem() {
+ if (updateMenuItem == null) {
+ updateMenuItem = new JMenuItem();
+ updateMenuItem.setText("Update");
+ updateMenuItem.setAccelerator(KeyStroke.getKeyStroke(
+ KeyEvent.VK_F5, 0, true));
+ updateMenuItem
+ .addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ // open bus
+ LibusbJava.usb_init();
+ LibusbJava.usb_find_busses();
+ LibusbJava.usb_find_devices();
+
+ Usb_Bus bus = LibusbJava.usb_get_busses();
+ if (bus != null) {
+ treeModel.fireTreeStructureChanged(bus);
+ expandAll(usbTree);
+ }
+ }
+ });
+ }
+ return updateMenuItem;
+ }
+
+ /**
+ * This method initializes usbTree
+ *
+ * @return javax.swing.JTree
+ */
+ private JTree getUsbTree() {
+ if (usbTree == null) {
+ // open bus
+ LibusbJava.usb_init();
+ LibusbJava.usb_find_busses();
+ LibusbJava.usb_find_devices();
+
+ Usb_Bus bus = LibusbJava.usb_get_busses();
+
+ treeModel = new UsbTreeModel(bus, jPropertiesArea);
+ usbTree = new JTree(treeModel);
+ expandAll(usbTree);
+ usbTree.addTreeSelectionListener(treeModel);
+ getJTestAppPopup();
+ usbTree.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ if (e.isPopupTrigger()) {
+ Object source = e.getSource();
+ if (source instanceof JTree) {
+ JTree tree = (JTree) source;
+ TreePath path = tree.getPathForLocation(e.getX(), e
+ .getY());
+ if (path != null
+ && (path.getLastPathComponent() instanceof Usb_Interface_Descriptor)) {
+ usbTree.setSelectionPath(path);
+ testAppPopup.show(tree, e.getX(), e.getY());
+ }
+ }
+ }
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ if (e.isPopupTrigger()) {
+ if (e.isPopupTrigger()) {
+ Object source = e.getSource();
+ if (source instanceof JTree) {
+ JTree tree = (JTree) source;
+ TreePath path = tree.getPathForLocation(e
+ .getX(), e.getY());
+ if (path != null
+ && (path.getLastPathComponent() instanceof Usb_Interface_Descriptor)) {
+ usbTree.setSelectionPath(path);
+ testAppPopup.show(tree, e.getX(), e.getY());
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+ return usbTree;
+ }
+
+ private void getJTestAppPopup() {
+ // Create the popup menu.
+ testAppPopup = new JPopupMenu();
+ endpointPopup = new JPopupMenu();
+ JMenuItem menuItem = new JMenuItem(
+ "Start a test application using this interface");
+ menuItem.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ initAndStartTestApp();
+ }
+
+ private void initAndStartTestApp() {
+ JTree tree = (JTree) testAppPopup.getInvoker();
+ TreePath path = tree.getSelectionPath();
+ TreePath parent = path;
+ Usb_Endpoint_Descriptor[] endpoints = null;
+ int altinterface = -1;
+ int interface_ = -1;
+ int configuration = -1;
+ short vendorId = -1;
+ short productId = -1;
+ while (parent != null
+ && !(parent.getLastPathComponent() instanceof Usb_Bus)) {
+ Object usbObj = parent.getLastPathComponent();
+ if (usbObj instanceof Usb_Interface_Descriptor) {
+ Usb_Interface_Descriptor usbIntDesc = (Usb_Interface_Descriptor) usbObj;
+ endpoints = usbIntDesc.getEndpoint();
+ interface_ = usbIntDesc.getBInterfaceNumber();
+ altinterface = usbIntDesc.getBAlternateSetting();
+ } else if (usbObj instanceof Usb_Config_Descriptor) {
+ configuration = ((Usb_Config_Descriptor) usbObj)
+ .getBConfigurationValue();
+ } else if (usbObj instanceof Usb_Device) {
+ Usb_Device_Descriptor devDesc = ((Usb_Device) usbObj)
+ .getDescriptor();
+ productId = devDesc.getIdProduct();
+ vendorId = devDesc.getIdVendor();
+ }
+ parent = parent.getParentPath();
+ }
+ if (parent != null) {
+ // present a dialog to select in/out endpoint
+ // TODO: present dialog to select in/out endpoint
+ Usb_Endpoint_Descriptor[] outEPs = null;
+ int nofOutEPs = 0;
+ Usb_Endpoint_Descriptor[] inEPs = null;
+ int nofInEPs = 0;
+
+ if (endpoints != null) {
+ outEPs = new Usb_Endpoint_Descriptor[endpoints.length];
+ inEPs = new Usb_Endpoint_Descriptor[endpoints.length];
+ for (int i = 0; i < endpoints.length; i++) {
+ int epAddr = endpoints[i].getBEndpointAddress() & 0xFF;
+ if ((epAddr & 0x80) > 0) {
+ // is IN endpoint
+ inEPs[nofInEPs++] = endpoints[i];
+ } else {
+ // is OUT endpoint
+ outEPs[nofOutEPs++] = endpoints[i];
+ }
+ }
+ }
+ // create a new TestDevice
+ TestDevice testDevice = new TestDevice();
+ testDevice.setIdProduct(productId);
+ testDevice.setIdVendor(vendorId);
+ testDevice.setAltinterface(altinterface);
+ testDevice.setConfiguration(configuration);
+ testDevice.setInterface(interface_);
+ if (inEPs != null) {
+ for (int i = 0; i < nofInEPs; i++) {
+ int type = inEPs[i].getBmAttributes() & 0x03;
+ switch (type) {
+ case Usb_Endpoint_Descriptor.USB_ENDPOINT_TYPE_BULK:
+ testDevice.setInEPBulk(inEPs[i]
+ .getBEndpointAddress() & 0xff);
+ testDevice.setInMode(TransferMode.Bulk);
+ break;
+ case Usb_Endpoint_Descriptor.USB_ENDPOINT_TYPE_INTERRUPT:
+ testDevice.setInEPInt(inEPs[i]
+ .getBEndpointAddress() & 0xff);
+ testDevice.setInMode(TransferMode.Interrupt);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ if (outEPs != null) {
+ for (int i = 0; i < nofOutEPs; i++) {
+ int type = outEPs[i].getBmAttributes() & 0x03;
+ switch (type) {
+ case Usb_Endpoint_Descriptor.USB_ENDPOINT_TYPE_BULK:
+ testDevice.setOutEPBulk(outEPs[i]
+ .getBEndpointAddress() & 0xff);
+ testDevice.setOutMode(TransferMode.Bulk);
+ break;
+ case Usb_Endpoint_Descriptor.USB_ENDPOINT_TYPE_INTERRUPT:
+ testDevice.setOutEPInt(outEPs[i]
+ .getBEndpointAddress() & 0xff);
+ testDevice.setOutMode(TransferMode.Interrupt);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ // open a new testApp
+ TestApp app = new TestApp(testDevice);
+ app.setVisible(true);
+ } else {
+ System.out.println("error, could not find device node");
+ // TODO: handle error
+ }
+ }
+ });
+ testAppPopup.add(menuItem);
+ }
+
+ /**
+ * This method initializes jSplitPane
+ *
+ * @return javax.swing.JSplitPane
+ */
+ private JSplitPane getJSplitPane() {
+ if (jSplitPane == null) {
+ jSplitPane = new JSplitPane();
+ jSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
+ jSplitPane.setContinuousLayout(true);
+ jSplitPane.setDividerLocation(APP_HIGHT / 2);
+ jSplitPane
+ .setBottomComponent(createScrollPane(getJPropertiesArea()));
+ jSplitPane.setTopComponent(createScrollPane(getUsbTree()));
+ }
+ return jSplitPane;
+ }
+
+ /**
+ * This method initializes jPropertiesArea
+ *
+ * @return javax.swing.JTextArea
+ */
+ private JTextArea getJPropertiesArea() {
+ if (jPropertiesArea == null) {
+ jPropertiesArea = new JTextArea();
+ }
+ return jPropertiesArea;
+ }
+
+ private JScrollPane createScrollPane(Component view) {
+ JScrollPane scrollPane = new JScrollPane(view);
+ return scrollPane;
+ }
+
+ /**
+ * Launches this application
+ */
+ public static void main(String[] args) {
+ UsbView application = new UsbView();
+ application.setVisible(true);
+ }
+
+ void expandAll(JTree tree) {
+ for (int row = 0; row < tree.getRowCount(); row++) {
+ tree.expandRow(row);
+ }
+ }
+}
diff --git a/java/src/ch/ntb/usb/usbView/package.html b/src/main/java/ch/ntb/usb.r273/usbView/package.html
similarity index 95%
rename from java/src/ch/ntb/usb/usbView/package.html
rename to src/main/java/ch/ntb/usb.r273/usbView/package.html
index d5f8295..2a64b06 100644
--- a/java/src/ch/ntb/usb/usbView/package.html
+++ b/src/main/java/ch/ntb/usb.r273/usbView/package.html
@@ -1,17 +1,17 @@
-
-
-
-
-
-Displays the bus and device information of the currently attached
-devices in a tree (based on Swing).
-
-Related Resources
-
-For more information about this project visit
-http://libusbjava.sourceforge.net
-.
-
-
-
+
+
+
+
+
+Displays the bus and device information of the currently attached
+devices in a tree (based on Swing).
+
+Related Resources
+
+For more information about this project visit
+http://libusbjava.sourceforge.net
+.
+
+
+