Towards building jlibusb with gradle
* rename package ch.ntb.inf.libusbJava to ch.ntb.usb/Device.java * separate main, app, test and demo source files * reorganise static library files * add prebuilt libraries for testing purposes * move auxiliary files to appropriate directories * remove obsolete files
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Java libusb wrapper
|
||||
* Copyright (c) 2005-2006 Andreas Schl<68>pfer <spandi at users.sourceforge.net>
|
||||
*
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava.demo;
|
||||
|
||||
import ch.ntb.inf.libusbJava.LibusbJava;
|
||||
import ch.ntb.inf.libusbJava.Usb_Bus;
|
||||
import ch.ntb.inf.libusbJava.Utils;
|
||||
|
||||
/**
|
||||
* Initalises Libusb and prints the bus(ses) with attached devices to the
|
||||
* standard out.<br>
|
||||
*
|
||||
* @deprecated This class will be removed with the legacy {@link LibusbJava}
|
||||
* class
|
||||
*/
|
||||
public class LogBus {
|
||||
|
||||
private static void logBus() {
|
||||
// if you don't use the ch.ntb.inf.libusbJava.Device class you must
|
||||
// initialise
|
||||
// Libusb before use
|
||||
LibusbJava.usb_init();
|
||||
LibusbJava.usb_find_busses();
|
||||
LibusbJava.usb_find_devices();
|
||||
|
||||
// retrieve a object tree representing the bus with its devices and
|
||||
// descriptors
|
||||
Usb_Bus bus = LibusbJava.usb_get_busses();
|
||||
|
||||
// log the bus structure to standard out
|
||||
Utils.logBus(bus);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
logBus();
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Java libusb wrapper
|
||||
* Copyright (c) 2005-2006 Andreas Schl<68>pfer <spandi at users.sourceforge.net>
|
||||
*
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava.demo;
|
||||
|
||||
import ch.ntb.inf.libusbJava.Device;
|
||||
import ch.ntb.inf.libusbJava.USB;
|
||||
import ch.ntb.inf.libusbJava.USBException;
|
||||
|
||||
/**
|
||||
* Demo class to demonstrate simple read and write operations to an USB device.<br>
|
||||
*
|
||||
*/
|
||||
public class ReadWrite {
|
||||
|
||||
private static void logData(byte[] data) {
|
||||
System.out.print("Data: ");
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
System.out.print("0x" + Integer.toHexString(data[i] & 0xff) + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// get a device instance with vendor id and product id
|
||||
Device dev = USB.getDevice((short) 0x8235, (short) 0x0100);
|
||||
try {
|
||||
// data to write to the device
|
||||
byte[] data = new byte[] { 0, 1, 2, 3 };
|
||||
// data read from the device
|
||||
byte[] readData = new byte[data.length];
|
||||
|
||||
// open the device with configuration 1, interface 0 and without
|
||||
// altinterface
|
||||
// this will initialise Libusb for you
|
||||
dev.open(1, 0, -1);
|
||||
// write some data to the device
|
||||
// 0x03 is the endpoint address of the OUT endpoint 3 (from PC to
|
||||
// device)
|
||||
dev.writeInterrupt(0x02, data, data.length, 2000, false);
|
||||
// read some data from the device
|
||||
// 0x84 is the endpoint address of the IN endpoint 4 (from PC to
|
||||
// device)
|
||||
// bit 7 (0x80) is set in case of an IN endpoint
|
||||
dev.readInterrupt(0x86, readData, readData.length, 2000, false);
|
||||
// log the data from the device
|
||||
logData(readData);
|
||||
// close the device
|
||||
dev.close();
|
||||
} catch (USBException e) {
|
||||
// if an exception occures during connect or read/write an exception
|
||||
// is thrown
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,211 +0,0 @@
|
||||
/*
|
||||
* Java libusb wrapper
|
||||
* Copyright (c) 2005-2006 Andreas Schl<68>pfer <spandi at users.sourceforge.net>
|
||||
*
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava.testApp;
|
||||
|
||||
public abstract class AbstractDeviceInfo {
|
||||
|
||||
private short idVendor;
|
||||
|
||||
private short idProduct;
|
||||
|
||||
private String filename = null;
|
||||
|
||||
private String busName = null;
|
||||
|
||||
private int timeout;
|
||||
|
||||
private int configuration;
|
||||
|
||||
private int interface_;
|
||||
|
||||
private int altinterface;
|
||||
|
||||
private int outEPBulk = -1;
|
||||
|
||||
private int inEPBulk = -1;
|
||||
|
||||
private int outEPInt = -1;
|
||||
|
||||
private int inEPInt = -1;
|
||||
|
||||
private int sleepTimeout;
|
||||
|
||||
private int maxDataSize;
|
||||
|
||||
private TransferMode mode;
|
||||
|
||||
private boolean compareData = true;
|
||||
|
||||
private String manufacturer = null;
|
||||
|
||||
private String product = null;
|
||||
|
||||
private String serialVersion = null;
|
||||
|
||||
public static enum TransferMode {
|
||||
Bulk, Interrupt
|
||||
}
|
||||
|
||||
public AbstractDeviceInfo() {
|
||||
initValues();
|
||||
}
|
||||
|
||||
abstract public void initValues();
|
||||
|
||||
public int getAltinterface() {
|
||||
return altinterface;
|
||||
}
|
||||
|
||||
public int getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public short getIdProduct() {
|
||||
return idProduct;
|
||||
}
|
||||
|
||||
public short getIdVendor() {
|
||||
return idVendor;
|
||||
}
|
||||
|
||||
public int getInEPBulk() {
|
||||
return inEPBulk;
|
||||
}
|
||||
|
||||
public int getInEPInt() {
|
||||
return inEPInt;
|
||||
}
|
||||
|
||||
public int getInterface() {
|
||||
return interface_;
|
||||
}
|
||||
|
||||
public int getMaxDataSize() {
|
||||
return maxDataSize;
|
||||
}
|
||||
|
||||
public int getOutEPBulk() {
|
||||
return outEPBulk;
|
||||
}
|
||||
|
||||
public int getOutEPInt() {
|
||||
return outEPInt;
|
||||
}
|
||||
|
||||
public int getSleepTimeout() {
|
||||
return sleepTimeout;
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setAltinterface(int altinterface) {
|
||||
this.altinterface = altinterface;
|
||||
}
|
||||
|
||||
public void setConfiguration(int configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public void setIdProduct(short idProduct) {
|
||||
this.idProduct = idProduct;
|
||||
}
|
||||
|
||||
public void setIdVendor(short idVendor) {
|
||||
this.idVendor = idVendor;
|
||||
}
|
||||
|
||||
public void setInEPBulk(int in_ep_bulk) {
|
||||
this.inEPBulk = in_ep_bulk;
|
||||
}
|
||||
|
||||
public void setInEPInt(int in_ep_int) {
|
||||
this.inEPInt = in_ep_int;
|
||||
}
|
||||
|
||||
public void setInterface(int interface_) {
|
||||
this.interface_ = interface_;
|
||||
}
|
||||
|
||||
public void setMaxDataSize(int maxDataSize) {
|
||||
this.maxDataSize = maxDataSize;
|
||||
}
|
||||
|
||||
public void setOutEPBulk(int out_ep_bulk) {
|
||||
this.outEPBulk = out_ep_bulk;
|
||||
}
|
||||
|
||||
public void setOutEPInt(int out_ep_int) {
|
||||
this.outEPInt = out_ep_int;
|
||||
}
|
||||
|
||||
public void setSleepTimeout(int sleepTimeout) {
|
||||
this.sleepTimeout = sleepTimeout;
|
||||
}
|
||||
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public TransferMode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(TransferMode mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public boolean doCompareData() {
|
||||
return compareData;
|
||||
}
|
||||
|
||||
public void setDoCompareData(boolean compareData) {
|
||||
this.compareData = compareData;
|
||||
}
|
||||
|
||||
public String getManufacturer() {
|
||||
return manufacturer;
|
||||
}
|
||||
|
||||
public void setManufacturer(String manufacturer) {
|
||||
this.manufacturer = manufacturer;
|
||||
}
|
||||
|
||||
public String getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
public void setProduct(String product) {
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
public String getSerialVersion() {
|
||||
return serialVersion;
|
||||
}
|
||||
|
||||
public void setSerialVersion(String serialVersion) {
|
||||
this.serialVersion = serialVersion;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String getBusName() {
|
||||
return busName;
|
||||
}
|
||||
|
||||
public void setBusName(String busName) {
|
||||
this.busName = busName;
|
||||
}
|
||||
}
|
||||
@@ -1,709 +0,0 @@
|
||||
/*
|
||||
* Java libusb wrapper
|
||||
* Copyright (c) 2005-2006 Andreas Schl<68>pfer <spandi at users.sourceforge.net>
|
||||
*
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava.testApp;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.event.ItemEvent;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
public class TestApp extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 994508729204158681L;
|
||||
TestDevice dev;
|
||||
private JPanel rootPanel = null;
|
||||
private JPanel sendReceivePanel = null;
|
||||
private JPanel settingsPanel = null;
|
||||
private JButton openDeviceButton = null;
|
||||
private JButton closeDevice = null;
|
||||
private JButton resetButton = null;
|
||||
private JPanel settingsPanelTop = null;
|
||||
private JPanel settingsPanelBottom = null;
|
||||
JTextField vendorIDText = null;
|
||||
JTextField productIDText = null;
|
||||
private JPanel vendorIDPanel = null;
|
||||
private JPanel productIDPanel = null;
|
||||
private JPanel configurationPanel = null;
|
||||
JTextField configurationText = null;
|
||||
private JPanel interfacePanel = null;
|
||||
JTextField interfaceText = null;
|
||||
private JPanel altInterfacePanel = null;
|
||||
JTextField altInterfaceText = null;
|
||||
private JPanel settingsPanelTop2Left = null;
|
||||
private JPanel settingsPanelTop2Right = null;
|
||||
private JPanel outEpPanel = null;
|
||||
JTextField outEpText = null;
|
||||
private JPanel inEpPanel = null;
|
||||
JTextField inEpText = null;
|
||||
private JPanel timeoutPanel = null;
|
||||
private JTextField timeoutText = null;
|
||||
private JPanel sendDataPanel = null;
|
||||
private JPanel sendRecButtonsPanel = null;
|
||||
private JButton sendButton = null;
|
||||
private JButton recButton = null;
|
||||
JTextField sendDataText = null;
|
||||
JComboBox sendTypeComboBox = null;
|
||||
private JComboBox recTypeComboBox = null;
|
||||
private JPanel sendRecButtonsPanelTop = null;
|
||||
private JPanel sendRecButtonsPanelBottom = null;
|
||||
|
||||
public TestApp(TestDevice devInfo) {
|
||||
super();
|
||||
this.dev = devInfo;
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
|
||||
this.setTitle("USB Test Application");
|
||||
|
||||
this.setContentPane(getRootPanel());
|
||||
|
||||
// read default values
|
||||
this.vendorIDText.setText(toHexString(dev.getIdVendor() & 0xffff));
|
||||
this.productIDText.setText(toHexString(dev.getIdProduct() & 0xffff));
|
||||
this.configurationText.setText(new Integer(dev.getConfiguration())
|
||||
.toString());
|
||||
this.interfaceText.setText(new Integer(dev.getInterface()).toString());
|
||||
this.altInterfaceText.setText(new Integer(dev.getAltinterface())
|
||||
.toString());
|
||||
this.timeoutText.setText(new Integer(dev.getTimeout()).toString());
|
||||
this.sendDataText.setText(dev.getSendData());
|
||||
setOutEpAddr();
|
||||
setInEpAddr();
|
||||
|
||||
this.pack();
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
void setOutEpAddr() {
|
||||
switch (dev.getOutMode()) {
|
||||
case Bulk:
|
||||
this.outEpText.setText(toHexString(dev.getOutEPBulk()));
|
||||
break;
|
||||
case Interrupt:
|
||||
this.outEpText.setText(toHexString(dev.getOutEPInt()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setInEpAddr() {
|
||||
switch (dev.getInMode()) {
|
||||
case Bulk:
|
||||
this.inEpText.setText(toHexString(dev.getInEPBulk()));
|
||||
break;
|
||||
case Interrupt:
|
||||
this.inEpText.setText(toHexString(dev.getInEPInt()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private JPanel getRootPanel() {
|
||||
if (rootPanel == null) {
|
||||
rootPanel = new JPanel();
|
||||
rootPanel
|
||||
.setLayout(new BoxLayout(getRootPanel(), BoxLayout.Y_AXIS));
|
||||
rootPanel.add(getSettingsPanel(), null);
|
||||
rootPanel.add(getSendReceivePanel(), null);
|
||||
}
|
||||
return rootPanel;
|
||||
}
|
||||
|
||||
private JPanel getSendReceivePanel() {
|
||||
if (sendReceivePanel == null) {
|
||||
BorderLayout borderLayout2 = new BorderLayout();
|
||||
borderLayout2.setHgap(5);
|
||||
sendReceivePanel = new JPanel();
|
||||
sendReceivePanel.setLayout(borderLayout2);
|
||||
sendReceivePanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"Send and Receive Data",
|
||||
TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
sendReceivePanel.add(getSendRecButtonsPanel(), BorderLayout.NORTH);
|
||||
sendReceivePanel.add(getSendDataPanel(), BorderLayout.SOUTH);
|
||||
}
|
||||
return sendReceivePanel;
|
||||
}
|
||||
|
||||
private JPanel getSettingsPanel() {
|
||||
if (settingsPanel == null) {
|
||||
settingsPanel = new JPanel();
|
||||
settingsPanel.setLayout(new BoxLayout(getSettingsPanel(),
|
||||
BoxLayout.Y_AXIS));
|
||||
settingsPanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"Device Settings", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
settingsPanel.add(getSettingsPanelTop(), null);
|
||||
settingsPanel.add(getSettingsPanelBottom(), null);
|
||||
}
|
||||
return settingsPanel;
|
||||
}
|
||||
|
||||
private JButton getOpenDeviceButton() {
|
||||
if (openDeviceButton == null) {
|
||||
openDeviceButton = new JButton();
|
||||
openDeviceButton.setText("Open Device");
|
||||
openDeviceButton
|
||||
.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||
// update values for the device
|
||||
dev.setIdVendor((short) parseInt(vendorIDText
|
||||
.getText().trim()));
|
||||
dev.setIdProduct((short) parseInt(productIDText
|
||||
.getText().trim()));
|
||||
dev.setConfiguration(parseInt(configurationText
|
||||
.getText().trim()));
|
||||
dev.setInterface(parseInt(interfaceText.getText()
|
||||
.trim()));
|
||||
dev.setAltinterface(parseInt(altInterfaceText
|
||||
.getText().trim()));
|
||||
// opent the device
|
||||
dev.openUsbDevice();
|
||||
}
|
||||
});
|
||||
}
|
||||
return openDeviceButton;
|
||||
}
|
||||
|
||||
private JButton getCloseDevice() {
|
||||
if (closeDevice == null) {
|
||||
closeDevice = new JButton();
|
||||
closeDevice.setText("Close Device");
|
||||
closeDevice.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||
dev.closeUsbDevice();
|
||||
}
|
||||
});
|
||||
}
|
||||
return closeDevice;
|
||||
}
|
||||
|
||||
private JButton getResetButton() {
|
||||
if (resetButton == null) {
|
||||
resetButton = new JButton();
|
||||
resetButton.setText("Reset Device");
|
||||
resetButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||
dev.resetUsbDevice();
|
||||
}
|
||||
});
|
||||
}
|
||||
return resetButton;
|
||||
}
|
||||
|
||||
private JPanel getSettingsPanelTop() {
|
||||
if (settingsPanelTop == null) {
|
||||
FlowLayout flowLayout = new FlowLayout();
|
||||
flowLayout.setVgap(1);
|
||||
flowLayout.setAlignment(FlowLayout.LEFT);
|
||||
settingsPanelTop = new JPanel();
|
||||
settingsPanelTop.setLayout(flowLayout);
|
||||
settingsPanelTop.add(getVendorIDPanel(), null);
|
||||
settingsPanelTop.add(getProductIDPanel(), null);
|
||||
settingsPanelTop.add(getConfigurationPanel(), null);
|
||||
settingsPanelTop.add(getInterfacePanel(), null);
|
||||
settingsPanelTop.add(getAltInterfacePanel(), null);
|
||||
}
|
||||
return settingsPanelTop;
|
||||
}
|
||||
|
||||
private JPanel getSettingsPanelBottom() {
|
||||
if (settingsPanelBottom == null) {
|
||||
FlowLayout flowLayout1 = new FlowLayout();
|
||||
flowLayout1.setVgap(1);
|
||||
flowLayout1.setHgap(0);
|
||||
flowLayout1.setAlignment(FlowLayout.LEFT);
|
||||
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
|
||||
gridBagConstraints1.gridx = -1;
|
||||
gridBagConstraints1.gridy = -1;
|
||||
settingsPanelBottom = new JPanel();
|
||||
settingsPanelBottom.setLayout(flowLayout1);
|
||||
settingsPanelBottom.add(getSettingsPanelTop2Left(), null);
|
||||
settingsPanelBottom.add(getSettingsPanelTop2Right(), null);
|
||||
}
|
||||
return settingsPanelBottom;
|
||||
}
|
||||
|
||||
private JTextField getVendorIDText() {
|
||||
if (vendorIDText == null) {
|
||||
vendorIDText = new JTextField();
|
||||
vendorIDText.setPreferredSize(new Dimension(100, 20));
|
||||
}
|
||||
return vendorIDText;
|
||||
}
|
||||
|
||||
private JTextField getProductIDText() {
|
||||
if (productIDText == null) {
|
||||
productIDText = new JTextField();
|
||||
productIDText.setPreferredSize(new Dimension(100, 20));
|
||||
}
|
||||
return productIDText;
|
||||
}
|
||||
|
||||
private JPanel getVendorIDPanel() {
|
||||
if (vendorIDPanel == null) {
|
||||
GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
|
||||
gridBagConstraints3.fill = GridBagConstraints.VERTICAL;
|
||||
gridBagConstraints3.gridy = -1;
|
||||
gridBagConstraints3.weightx = 1.0;
|
||||
gridBagConstraints3.gridx = -1;
|
||||
GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
|
||||
gridBagConstraints5.gridx = -1;
|
||||
gridBagConstraints5.gridy = -1;
|
||||
vendorIDPanel = new JPanel();
|
||||
vendorIDPanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"VendorID", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
vendorIDPanel.setLayout(new BoxLayout(getVendorIDPanel(),
|
||||
BoxLayout.X_AXIS));
|
||||
vendorIDPanel.add(getVendorIDText(), null);
|
||||
}
|
||||
return vendorIDPanel;
|
||||
}
|
||||
|
||||
private JPanel getProductIDPanel() {
|
||||
if (productIDPanel == null) {
|
||||
GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
|
||||
gridBagConstraints4.fill = GridBagConstraints.VERTICAL;
|
||||
gridBagConstraints4.gridy = -1;
|
||||
gridBagConstraints4.weightx = 1.0;
|
||||
gridBagConstraints4.gridx = -1;
|
||||
productIDPanel = new JPanel();
|
||||
productIDPanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"ProductID", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
productIDPanel.setLayout(new BoxLayout(getProductIDPanel(),
|
||||
BoxLayout.X_AXIS));
|
||||
productIDPanel.add(getProductIDText(), null);
|
||||
}
|
||||
return productIDPanel;
|
||||
}
|
||||
|
||||
private JPanel getConfigurationPanel() {
|
||||
if (configurationPanel == null) {
|
||||
configurationPanel = new JPanel();
|
||||
configurationPanel.setLayout(new BoxLayout(getConfigurationPanel(),
|
||||
BoxLayout.X_AXIS));
|
||||
configurationPanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"Configuration", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
configurationPanel.add(getConfigurationText(), null);
|
||||
}
|
||||
return configurationPanel;
|
||||
}
|
||||
|
||||
private JTextField getConfigurationText() {
|
||||
if (configurationText == null) {
|
||||
configurationText = new JTextField();
|
||||
configurationText.setPreferredSize(new Dimension(100, 20));
|
||||
}
|
||||
return configurationText;
|
||||
}
|
||||
|
||||
private JPanel getInterfacePanel() {
|
||||
if (interfacePanel == null) {
|
||||
interfacePanel = new JPanel();
|
||||
interfacePanel.setLayout(new BoxLayout(getInterfacePanel(),
|
||||
BoxLayout.X_AXIS));
|
||||
interfacePanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"Interface", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
interfacePanel.add(getInterfaceText(), null);
|
||||
}
|
||||
return interfacePanel;
|
||||
}
|
||||
|
||||
private JTextField getInterfaceText() {
|
||||
if (interfaceText == null) {
|
||||
interfaceText = new JTextField();
|
||||
interfaceText.setPreferredSize(new Dimension(100, 20));
|
||||
}
|
||||
return interfaceText;
|
||||
}
|
||||
|
||||
private JPanel getAltInterfacePanel() {
|
||||
if (altInterfacePanel == null) {
|
||||
altInterfacePanel = new JPanel();
|
||||
altInterfacePanel.setLayout(new BoxLayout(getAltInterfacePanel(),
|
||||
BoxLayout.X_AXIS));
|
||||
altInterfacePanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"Alternate Int", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
altInterfacePanel.add(getAltInterfaceText(), null);
|
||||
}
|
||||
return altInterfacePanel;
|
||||
}
|
||||
|
||||
private JTextField getAltInterfaceText() {
|
||||
if (altInterfaceText == null) {
|
||||
altInterfaceText = new JTextField();
|
||||
altInterfaceText.setPreferredSize(new Dimension(100, 20));
|
||||
}
|
||||
return altInterfaceText;
|
||||
}
|
||||
|
||||
private JPanel getSettingsPanelTop2Left() {
|
||||
if (settingsPanelTop2Left == null) {
|
||||
FlowLayout flowLayout2 = new FlowLayout();
|
||||
flowLayout2.setVgap(2);
|
||||
flowLayout2.setAlignment(FlowLayout.LEFT);
|
||||
flowLayout2.setHgap(5);
|
||||
settingsPanelTop2Left = new JPanel();
|
||||
settingsPanelTop2Left.setLayout(flowLayout2);
|
||||
settingsPanelTop2Left.add(getOutEpPanel(), null);
|
||||
settingsPanelTop2Left.add(getInEpPanel(), null);
|
||||
settingsPanelTop2Left.add(getTimeoutPanel(), null);
|
||||
}
|
||||
return settingsPanelTop2Left;
|
||||
}
|
||||
|
||||
private JPanel getSettingsPanelTop2Right() {
|
||||
if (settingsPanelTop2Right == null) {
|
||||
FlowLayout flowLayout3 = new FlowLayout();
|
||||
flowLayout3.setVgap(2);
|
||||
settingsPanelTop2Right = new JPanel();
|
||||
settingsPanelTop2Right.setLayout(flowLayout3);
|
||||
settingsPanelTop2Right.add(getOpenDeviceButton(), null);
|
||||
settingsPanelTop2Right.add(getCloseDevice(), null);
|
||||
settingsPanelTop2Right.add(getResetButton(), null);
|
||||
}
|
||||
return settingsPanelTop2Right;
|
||||
}
|
||||
|
||||
private JPanel getOutEpPanel() {
|
||||
if (outEpPanel == null) {
|
||||
outEpPanel = new JPanel();
|
||||
outEpPanel.setLayout(new BoxLayout(getOutEpPanel(),
|
||||
BoxLayout.X_AXIS));
|
||||
outEpPanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"OUT EP", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
outEpPanel.add(getOutEpText(), null);
|
||||
}
|
||||
return outEpPanel;
|
||||
}
|
||||
|
||||
private JTextField getOutEpText() {
|
||||
if (outEpText == null) {
|
||||
outEpText = new JTextField();
|
||||
outEpText.setPreferredSize(new Dimension(100, 20));
|
||||
}
|
||||
return outEpText;
|
||||
}
|
||||
|
||||
private JPanel getInEpPanel() {
|
||||
if (inEpPanel == null) {
|
||||
inEpPanel = new JPanel();
|
||||
inEpPanel
|
||||
.setLayout(new BoxLayout(getInEpPanel(), BoxLayout.X_AXIS));
|
||||
inEpPanel.setBorder(BorderFactory.createTitledBorder(null, "IN EP",
|
||||
TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
inEpPanel.add(getInEpText(), null);
|
||||
}
|
||||
return inEpPanel;
|
||||
}
|
||||
|
||||
private JTextField getInEpText() {
|
||||
if (inEpText == null) {
|
||||
inEpText = new JTextField();
|
||||
inEpText.setPreferredSize(new Dimension(100, 20));
|
||||
}
|
||||
return inEpText;
|
||||
}
|
||||
|
||||
private JPanel getTimeoutPanel() {
|
||||
if (timeoutPanel == null) {
|
||||
timeoutPanel = new JPanel();
|
||||
timeoutPanel.setLayout(new BoxLayout(getTimeoutPanel(),
|
||||
BoxLayout.X_AXIS));
|
||||
timeoutPanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"Timeout", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
timeoutPanel.add(getTimeoutText(), null);
|
||||
}
|
||||
return timeoutPanel;
|
||||
}
|
||||
|
||||
private JTextField getTimeoutText() {
|
||||
if (timeoutText == null) {
|
||||
timeoutText = new JTextField();
|
||||
timeoutText.setPreferredSize(new Dimension(100, 20));
|
||||
}
|
||||
return timeoutText;
|
||||
}
|
||||
|
||||
private JPanel getSendDataPanel() {
|
||||
if (sendDataPanel == null) {
|
||||
FlowLayout flowLayout4 = new FlowLayout();
|
||||
flowLayout4.setAlignment(FlowLayout.LEFT);
|
||||
sendDataPanel = new JPanel();
|
||||
sendDataPanel.setLayout(flowLayout4);
|
||||
sendDataPanel.setBorder(BorderFactory.createTitledBorder(null,
|
||||
"Data to send [hex]", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
sendDataPanel.add(getSendRecDataText(), null);
|
||||
}
|
||||
return sendDataPanel;
|
||||
}
|
||||
|
||||
private JPanel getSendRecButtonsPanel() {
|
||||
if (sendRecButtonsPanel == null) {
|
||||
FlowLayout flowLayout5 = new FlowLayout();
|
||||
flowLayout5.setAlignment(FlowLayout.LEFT);
|
||||
flowLayout5.setVgap(0);
|
||||
sendRecButtonsPanel = new JPanel();
|
||||
sendRecButtonsPanel.setLayout(flowLayout5);
|
||||
sendRecButtonsPanel.add(getSendRecButtonsPanelTop(), null);
|
||||
sendRecButtonsPanel.add(getSendRecButtonsPanelBottom(), null);
|
||||
}
|
||||
return sendRecButtonsPanel;
|
||||
}
|
||||
|
||||
private JButton getSendButton() {
|
||||
if (sendButton == null) {
|
||||
sendButton = new JButton();
|
||||
sendButton.setText("Send");
|
||||
sendButton.setName("sendButton");
|
||||
sendButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||
int index = sendTypeComboBox.getSelectedIndex();
|
||||
if (index == TestDevice.TransferMode.Bulk.ordinal()) {
|
||||
dev.setOutEPBulk(parseInt(outEpText.getText().trim()));
|
||||
dev.setMode(TestDevice.TransferMode.Bulk);
|
||||
} else if (index == TestDevice.TransferMode.Interrupt
|
||||
.ordinal()) {
|
||||
dev.setOutEPInt(parseInt(outEpText.getText().trim()));
|
||||
dev.setMode(TestDevice.TransferMode.Interrupt);
|
||||
}
|
||||
byte[] data = parseByteArray(sendDataText.getText().trim());
|
||||
dev.write(data, data.length);
|
||||
}
|
||||
});
|
||||
}
|
||||
return sendButton;
|
||||
}
|
||||
|
||||
private JButton getRecButton() {
|
||||
if (recButton == null) {
|
||||
recButton = new JButton();
|
||||
recButton.setText("Receive");
|
||||
recButton.setName("recButton");
|
||||
recButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||
int index = sendTypeComboBox.getSelectedIndex();
|
||||
if (index == TestDevice.TransferMode.Bulk.ordinal()) {
|
||||
dev.setInEPBulk(parseInt(inEpText.getText().trim()));
|
||||
dev.setMode(TestDevice.TransferMode.Bulk);
|
||||
} else if (index == TestDevice.TransferMode.Interrupt
|
||||
.ordinal()) {
|
||||
dev.setInEPInt(parseInt(inEpText.getText().trim()));
|
||||
dev.setMode(TestDevice.TransferMode.Interrupt);
|
||||
}
|
||||
dev.read();
|
||||
}
|
||||
});
|
||||
}
|
||||
return recButton;
|
||||
}
|
||||
|
||||
private JTextField getSendRecDataText() {
|
||||
if (sendDataText == null) {
|
||||
sendDataText = new JTextField();
|
||||
sendDataText.setPreferredSize(new Dimension(650, 20));
|
||||
}
|
||||
return sendDataText;
|
||||
}
|
||||
|
||||
int parseInt(String s) {
|
||||
if (s == "")
|
||||
return 0;
|
||||
if (s.indexOf('x') > 0) {
|
||||
// is hex number
|
||||
if (s.length() <= 2) { // exception for "0x"
|
||||
return 0;
|
||||
}
|
||||
return Integer.parseInt(
|
||||
s.substring(s.indexOf('x') + 1, s.length()), 16);
|
||||
}
|
||||
// is decimal number
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
|
||||
byte[] parseByteArray(String s) {
|
||||
final int HEX_WIDTH = 5;
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int stringIndex = 0, spaceIndex = 0;
|
||||
String ss;
|
||||
while (stringIndex + 3 < s.length()) {
|
||||
ss = s.substring(spaceIndex, spaceIndex + 4);
|
||||
spaceIndex = s.indexOf(' ', stringIndex) + 1;
|
||||
sb.append((char) parseInt(ss));
|
||||
stringIndex += HEX_WIDTH;
|
||||
}
|
||||
return sb.toString().getBytes();
|
||||
}
|
||||
|
||||
private static String toHexString(int value) {
|
||||
return "0x" + Integer.toHexString(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes sendTypeComboBox
|
||||
*
|
||||
* @return javax.swing.JComboBox
|
||||
*/
|
||||
private JComboBox getSendTypeComboBox() {
|
||||
if (sendTypeComboBox == null) {
|
||||
sendTypeComboBox = new JComboBox(dev.getTransferTypes());
|
||||
sendTypeComboBox.setSelectedIndex(dev.getOutMode().ordinal());
|
||||
sendTypeComboBox.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
String mode = (String) e.getItem();
|
||||
if (mode.equalsIgnoreCase("Bulk")) {
|
||||
dev.setOutMode(TestDevice.TransferMode.Bulk);
|
||||
setOutEpAddr();
|
||||
} else if (mode.equalsIgnoreCase("Interrupt")) {
|
||||
dev.setOutMode(TestDevice.TransferMode.Interrupt);
|
||||
setOutEpAddr();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return sendTypeComboBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes recTypeComboBox
|
||||
*
|
||||
* @return javax.swing.JComboBox
|
||||
*/
|
||||
private JComboBox getRecTypeComboBox() {
|
||||
if (recTypeComboBox == null) {
|
||||
recTypeComboBox = new JComboBox(dev.getTransferTypes());
|
||||
recTypeComboBox.setSelectedIndex(dev.getInMode().ordinal());
|
||||
recTypeComboBox.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
String mode = (String) e.getItem();
|
||||
if (mode.equalsIgnoreCase("Bulk")) {
|
||||
dev.setInMode(TestDevice.TransferMode.Bulk);
|
||||
setInEpAddr();
|
||||
} else if (mode.equalsIgnoreCase("Interrupt")) {
|
||||
dev.setInMode(TestDevice.TransferMode.Interrupt);
|
||||
setInEpAddr();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// recTypeComboBox.addActionListener(new
|
||||
// java.awt.event.ActionListener() {
|
||||
// public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||
// JComboBox source = (JComboBox) e.getSource();
|
||||
// String mode = "";
|
||||
// } if (mode.equalsIgnoreCase("Bulk")) {
|
||||
// dev.setInMode(TestDevice.TransferMode.Bulk);
|
||||
// setInEpAddr();
|
||||
// } else if (mode.equalsIgnoreCase("Interrupt")) {
|
||||
// dev.setInMode(TestDevice.TransferMode.Interrupt);
|
||||
// setInEpAddr();
|
||||
// }
|
||||
//
|
||||
// });
|
||||
}
|
||||
return recTypeComboBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes sendRecButtonsPanelTop
|
||||
*
|
||||
* @return javax.swing.JPanel
|
||||
*/
|
||||
private JPanel getSendRecButtonsPanelTop() {
|
||||
if (sendRecButtonsPanelTop == null) {
|
||||
BorderLayout borderLayout1 = new BorderLayout();
|
||||
borderLayout1.setHgap(5);
|
||||
sendRecButtonsPanelTop = new JPanel();
|
||||
sendRecButtonsPanelTop.setBorder(BorderFactory.createTitledBorder(
|
||||
null, "OUT", TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
sendRecButtonsPanelTop.setLayout(borderLayout1);
|
||||
sendRecButtonsPanelTop.add(getSendButton(), BorderLayout.EAST);
|
||||
sendRecButtonsPanelTop
|
||||
.add(getSendTypeComboBox(), BorderLayout.WEST);
|
||||
}
|
||||
return sendRecButtonsPanelTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes sendRecButtonsPanelBottom
|
||||
*
|
||||
* @return javax.swing.JPanel
|
||||
*/
|
||||
private JPanel getSendRecButtonsPanelBottom() {
|
||||
if (sendRecButtonsPanelBottom == null) {
|
||||
BorderLayout borderLayout = new BorderLayout();
|
||||
borderLayout.setHgap(5);
|
||||
sendRecButtonsPanelBottom = new JPanel();
|
||||
sendRecButtonsPanelBottom.setBorder(BorderFactory
|
||||
.createTitledBorder(null, "IN",
|
||||
TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
TitledBorder.DEFAULT_POSITION, new Font("Dialog",
|
||||
Font.BOLD, 12), new Color(51, 51, 51)));
|
||||
sendRecButtonsPanelBottom.setLayout(borderLayout);
|
||||
sendRecButtonsPanelBottom.add(getRecButton(), BorderLayout.EAST);
|
||||
sendRecButtonsPanelBottom.add(getRecTypeComboBox(),
|
||||
BorderLayout.WEST);
|
||||
}
|
||||
return sendRecButtonsPanelBottom;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// set LookAndFeel
|
||||
try {
|
||||
UIManager
|
||||
.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TestApp app = new TestApp(new TestDevice());
|
||||
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
/*
|
||||
* Java libusb wrapper
|
||||
* Copyright (c) 2005-2006 Andreas Schl<68>pfer <spandi at users.sourceforge.net>
|
||||
*
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava.testApp;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import ch.ntb.inf.libusbJava.Device;
|
||||
import ch.ntb.inf.libusbJava.USB;
|
||||
import ch.ntb.inf.libusbJava.USBException;
|
||||
import ch.ntb.inf.libusbJava.logger.LogUtil;
|
||||
|
||||
public class TestDevice extends AbstractDeviceInfo {
|
||||
|
||||
private static final Logger logger = LogUtil.getLogger("ch.ntb.inf.libusbJava.test");
|
||||
|
||||
private String sendData = "0x5b 0x02 0x01 0x00 0x03 0x03 0xf0 0xf0 0x1f";
|
||||
|
||||
private Vector<String> transferTypes;
|
||||
|
||||
private static Device dev = null;
|
||||
|
||||
private TransferMode inMode;
|
||||
private TransferMode outMode;
|
||||
|
||||
public TestDevice() {
|
||||
logger.setLevel(Level.ALL);
|
||||
// create a vector for transfer types
|
||||
transferTypes = new Vector<String>();
|
||||
transferTypes
|
||||
.add(TransferMode.Bulk.ordinal(), TransferMode.Bulk.name());
|
||||
transferTypes.add(TransferMode.Interrupt.ordinal(),
|
||||
TransferMode.Interrupt.name());
|
||||
inMode = TransferMode.Bulk;
|
||||
outMode = TransferMode.Bulk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initValues() {
|
||||
setIdVendor((short) 0x8235);
|
||||
setIdProduct((short) 0x0200);
|
||||
setTimeout(2000);
|
||||
setConfiguration(1);
|
||||
setInterface(0);
|
||||
setAltinterface(-1);
|
||||
setOutEPBulk(0x01);
|
||||
setInEPBulk(0x82);
|
||||
setOutEPInt(0x01);
|
||||
setInEPInt(0x82);
|
||||
setSleepTimeout(2000);
|
||||
setMaxDataSize(USB.FULLSPEED_MAX_BULK_PACKET_SIZE);
|
||||
setMode(TransferMode.Bulk);
|
||||
}
|
||||
|
||||
public void openUsbDevice() {
|
||||
dev = USB.getDevice(getIdVendor(), getIdProduct());
|
||||
try {
|
||||
dev.open(getConfiguration(), getInterface(), getAltinterface());
|
||||
logger.info("device opened, interface claimed");
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void closeUsbDevice() {
|
||||
try {
|
||||
if (dev != null) {
|
||||
dev.close();
|
||||
logger.info("device closed");
|
||||
} else {
|
||||
logger.warning("no device to close -> open first");
|
||||
}
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void resetUsbDevice() {
|
||||
try {
|
||||
if (dev != null) {
|
||||
dev.reset();
|
||||
logger.info("device reset");
|
||||
} else {
|
||||
logger.warning("no device to reset -> open first");
|
||||
}
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void write(byte[] data, int length) {
|
||||
int lenWritten = 0;
|
||||
try {
|
||||
if (dev != null) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
switch (getOutMode()) {
|
||||
case Bulk:
|
||||
lenWritten = dev.writeBulk(getOutEPBulk(), data, length,
|
||||
getTimeout(), false);
|
||||
sb.append("write_bulk, ep: 0x"
|
||||
+ Integer.toHexString(getOutEPBulk()) + ", "
|
||||
+ lenWritten + " Bytes sent: ");
|
||||
break;
|
||||
case Interrupt:
|
||||
lenWritten = dev.writeInterrupt(getOutEPInt(), data,
|
||||
length, getTimeout(), false);
|
||||
sb.append("write_interrupt, ep: 0x"
|
||||
+ Integer.toHexString(getOutEPInt()) + ", "
|
||||
+ lenWritten + " Bytes sent: ");
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < lenWritten; i++) {
|
||||
sb.append("0x" + String.format("%1$02X", data[i]) + " ");
|
||||
}
|
||||
logger.info(sb.toString());
|
||||
} else {
|
||||
logger.warning("no device opened");
|
||||
}
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void read() {
|
||||
if (dev != null) {
|
||||
byte[] data = new byte[dev.getMaxPacketSize()];
|
||||
int lenRead = 0;
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
switch (getInMode()) {
|
||||
case Bulk:
|
||||
lenRead = dev.readBulk(getInEPBulk(), data, dev
|
||||
.getMaxPacketSize(), getTimeout(), false);
|
||||
sb.append("read_bulk, ep: 0x"
|
||||
+ Integer.toHexString(getInEPBulk()) + ", "
|
||||
+ lenRead + " Bytes received: Data: ");
|
||||
break;
|
||||
case Interrupt:
|
||||
lenRead = dev.readInterrupt(getInEPInt(), data, dev
|
||||
.getMaxPacketSize(), getTimeout(), false);
|
||||
sb.append("read_interrupt, ep: 0x"
|
||||
+ Integer.toHexString(getInEPInt()) + ", "
|
||||
+ lenRead + " Bytes received: Data: ");
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < lenRead; i++) {
|
||||
sb.append("0x" + String.format("%1$02X", data[i]) + " ");
|
||||
}
|
||||
logger.info(sb.toString());
|
||||
} catch (USBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
logger.warning("no device opened");
|
||||
}
|
||||
}
|
||||
|
||||
public String getSendData() {
|
||||
return sendData;
|
||||
}
|
||||
|
||||
public void setSendData(String sendData) {
|
||||
this.sendData = sendData;
|
||||
}
|
||||
|
||||
public Vector<String> getTransferTypes() {
|
||||
return transferTypes;
|
||||
}
|
||||
|
||||
public TransferMode getOutMode() {
|
||||
return outMode;
|
||||
}
|
||||
|
||||
public void setOutMode(TransferMode outMode) {
|
||||
this.outMode = outMode;
|
||||
}
|
||||
|
||||
public TransferMode getInMode() {
|
||||
return inMode;
|
||||
}
|
||||
|
||||
public void setInMode(TransferMode inMode) {
|
||||
this.inMode = inMode;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head></head>
|
||||
<body bgcolor="white">
|
||||
|
||||
A test application with a GUI to write to and read from a device (based on Swing).
|
||||
|
||||
<h2>Related Resources</h2>
|
||||
|
||||
For more information about this project visit
|
||||
<a
|
||||
href="http://libusbjava.sourceforge.net">http://libusbjava.sourceforge.net</a>
|
||||
.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,525 +0,0 @@
|
||||
/*
|
||||
* Java libusb wrapper
|
||||
* Copyright (c) 2005-2006 Andreas Schl<68>pfer <spandi at users.sourceforge.net>
|
||||
*
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava.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.inf.libusbJava.LibusbJava1;
|
||||
import ch.ntb.inf.libusbJava.Usb_Bus;
|
||||
import ch.ntb.inf.libusbJava.Usb_Config_Descriptor;
|
||||
import ch.ntb.inf.libusbJava.Usb_Device;
|
||||
import ch.ntb.inf.libusbJava.Usb_Device_Descriptor;
|
||||
import ch.ntb.inf.libusbJava.Usb_Endpoint_Descriptor;
|
||||
import ch.ntb.inf.libusbJava.Usb_Interface;
|
||||
import ch.ntb.inf.libusbJava.Usb_Interface_Descriptor;
|
||||
import ch.ntb.inf.libusbJava.exceptions.LibusbError;
|
||||
|
||||
public class UsbTreeModel implements TreeModel, TreeSelectionListener {
|
||||
|
||||
private Usb_Bus rootBus;
|
||||
|
||||
private static final String USB_ROOT = "USB";
|
||||
|
||||
private JTextArea textArea;
|
||||
|
||||
private Vector<TreeModelListener> treeModelListeners = new Vector<TreeModelListener>();
|
||||
|
||||
/**
|
||||
* Default constructor.<br>
|
||||
*
|
||||
* @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)) {
|
||||
try {
|
||||
sb.append("\nString descriptors\n");
|
||||
long handle = LibusbJava1.libusb_open(dev);
|
||||
|
||||
try {
|
||||
if (dev.getDescriptor().getIManufacturer() > 0) {
|
||||
String manufacturer = LibusbJava1
|
||||
.libusb_get_string_descriptor_ascii(
|
||||
handle,
|
||||
devDesc.getIManufacturer(),
|
||||
255);
|
||||
if (manufacturer == null)
|
||||
manufacturer = "unable to fetch manufacturer string";
|
||||
sb.append("\tiManufacturer: "
|
||||
+ manufacturer + "\n");
|
||||
}
|
||||
if (dev.getDescriptor().getIProduct() > 0) {
|
||||
String product = LibusbJava1
|
||||
.libusb_get_string_descriptor_ascii(
|
||||
handle,
|
||||
devDesc.getIProduct(),
|
||||
255);
|
||||
if (product == null)
|
||||
product = "unable to fetch product string";
|
||||
sb.append("\tiProduct: " + product
|
||||
+ "\n");
|
||||
}
|
||||
if (dev.getDescriptor().getISerialNumber() > 0) {
|
||||
String serialNumber = LibusbJava1
|
||||
.libusb_get_string_descriptor_ascii(
|
||||
handle,
|
||||
devDesc.getISerialNumber(),
|
||||
255);
|
||||
if (serialNumber == null)
|
||||
serialNumber = "unable to fetch serial number string";
|
||||
sb.append("\tiSerialNumber: "
|
||||
+ serialNumber + "\n");
|
||||
}
|
||||
} catch (LibusbError ex) {
|
||||
sb.append("\terror getting descriptors: "
|
||||
+ ex.getErrorString() + "\n");
|
||||
} finally {
|
||||
LibusbJava1.libusb_close(handle);
|
||||
}
|
||||
} catch (LibusbError ex) {
|
||||
sb.append("\terror opening the device"
|
||||
+ ex.getErrorString() + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
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)) {
|
||||
try {
|
||||
sb.append("\nString descriptors\n");
|
||||
long handle = LibusbJava1.libusb_open(dev);
|
||||
|
||||
try {
|
||||
String configuration = LibusbJava1
|
||||
.libusb_get_string_descriptor_ascii(
|
||||
handle,
|
||||
confDesc.getIConfiguration(),
|
||||
255);
|
||||
if (configuration == null)
|
||||
configuration = "unable to fetch configuration string";
|
||||
sb.append("\tiConfiguration: "
|
||||
+ configuration + "\n");
|
||||
} catch (LibusbError e1) {
|
||||
sb.append("\terror getting config descriptor: "
|
||||
+ e1.getErrorString() + "\n");
|
||||
} finally {
|
||||
LibusbJava1.libusb_close(handle);
|
||||
}
|
||||
} catch (LibusbError e1) {
|
||||
sb.append("\terror opening the device: "
|
||||
+ e1.getErrorString() + "\n");
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
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) {
|
||||
try {
|
||||
long handle = LibusbJava1.libusb_open(dev);
|
||||
|
||||
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)) {
|
||||
sb.append("\nString descriptors\n");
|
||||
try {
|
||||
String interface_ = LibusbJava1
|
||||
.libusb_get_string_descriptor_ascii(
|
||||
handle,
|
||||
intDesc.getIInterface(),
|
||||
255);
|
||||
if (interface_ == null)
|
||||
interface_ = "unable to fetch interface string";
|
||||
sb.append("\tiInterface: "
|
||||
+ interface_ + "\n");
|
||||
} catch (LibusbError e1) {
|
||||
sb.append("\terror while reading descriptors: "
|
||||
+ e1.getErrorString()
|
||||
+ "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LibusbJava1.libusb_close(handle);
|
||||
} catch (LibusbError e1) {
|
||||
sb.append("\terror opening the device: "
|
||||
+ e1.getErrorString() + "\n");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,403 +0,0 @@
|
||||
/*
|
||||
* Java libusb wrapper
|
||||
* Copyright (c) 2005-2006 Andreas Schl<68>pfer <spandi at users.sourceforge.net>
|
||||
*
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava.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.inf.libusbJava.LibusbJava;
|
||||
import ch.ntb.inf.libusbJava.Usb_Bus;
|
||||
import ch.ntb.inf.libusbJava.Usb_Config_Descriptor;
|
||||
import ch.ntb.inf.libusbJava.Usb_Device;
|
||||
import ch.ntb.inf.libusbJava.Usb_Device_Descriptor;
|
||||
import ch.ntb.inf.libusbJava.Usb_Endpoint_Descriptor;
|
||||
import ch.ntb.inf.libusbJava.Usb_Interface_Descriptor;
|
||||
import ch.ntb.inf.libusbJava.testApp.TestApp;
|
||||
import ch.ntb.inf.libusbJava.testApp.TestDevice;
|
||||
import ch.ntb.inf.libusbJava.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_TRANSFER_TYPE_BULK:
|
||||
testDevice.setInEPBulk(inEPs[i]
|
||||
.getBEndpointAddress() & 0xff);
|
||||
testDevice.setInMode(TransferMode.Bulk);
|
||||
break;
|
||||
case Usb_Endpoint_Descriptor.USB_ENDPOINT_TRANSFER_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_TRANSFER_TYPE_BULK:
|
||||
testDevice.setOutEPBulk(outEPs[i]
|
||||
.getBEndpointAddress() & 0xff);
|
||||
testDevice.setOutMode(TransferMode.Bulk);
|
||||
break;
|
||||
case Usb_Endpoint_Descriptor.USB_ENDPOINT_TRANSFER_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head></head>
|
||||
<body bgcolor="white">
|
||||
|
||||
Displays the bus and device information of the currently attached
|
||||
devices in a tree (based on Swing).
|
||||
|
||||
<h2>Related Resources</h2>
|
||||
|
||||
For more information about this project visit
|
||||
<a
|
||||
href="http://libusbjava.sourceforge.net">http://libusbjava.sourceforge.net</a>
|
||||
.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,12 +5,12 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import ch.ntb.inf.libusbJava.logger.LogUtil;
|
||||
import ch.ntb.usb.logger.LogUtil;
|
||||
|
||||
/**
|
||||
* This class represents an USB device.<br>
|
||||
@@ -10,9 +10,9 @@
|
||||
* 18.10.2010 NTB / Roger Millischer change from native interface to compatibility layer
|
||||
*
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
import ch.ntb.inf.libusbJava.exceptions.LibusbError;
|
||||
import ch.ntb.usb.exceptions.LibusbError;
|
||||
|
||||
/**
|
||||
* This class is used as compatibility layer for libusb 0.1 projects.
|
||||
@@ -60,14 +60,14 @@ public class LibusbJava {
|
||||
if (defaultCTX != 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
/*try {
|
||||
defaultCTX = LibusbJava1.libusb_init();
|
||||
} catch (LibusbError e) {
|
||||
System.err.println("LibusbJava-1.0 init failed with errorcode: "
|
||||
+ e.getMessage());
|
||||
e.printStackTrace();
|
||||
defaultCTX = 0;
|
||||
}
|
||||
}*/
|
||||
LibusbJava1.libusb_set_debug(0, 0);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
*
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
import ch.ntb.inf.libusbJava.exceptions.LibusbError;
|
||||
import ch.ntb.usb.exceptions.LibusbError;
|
||||
|
||||
import com.github.boukefalos.jlibloader.Native;
|
||||
|
||||
/**
|
||||
* This class represents the Java Native Interface to the shared library which
|
||||
@@ -1378,12 +1380,7 @@ public class LibusbJava1 {
|
||||
public static native String libusb_strerror();
|
||||
|
||||
static {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.contains("Windows")) {
|
||||
System.loadLibrary("LibusbJava-1_0");
|
||||
} else {
|
||||
System.loadLibrary("usbJava-1.0");
|
||||
}
|
||||
Native.load("com.github.boukefalos", "jlibusb");
|
||||
|
||||
/*
|
||||
* After loading the library, we register a "shutdown hook" to be called
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
public class Libusb_event {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
public class Libusb_pollfd {
|
||||
int fd;
|
||||
@@ -5,13 +5,13 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import ch.ntb.inf.libusbJava.logger.LogUtil;
|
||||
import ch.ntb.usb.logger.LogUtil;
|
||||
|
||||
/**
|
||||
* This class manages all USB devices and defines some USB specific constants.<br>
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
public class USBTimeoutException extends USBException {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
/**
|
||||
* Represents an USB bus.<br>
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
/**
|
||||
* Represents the descriptor of a USB configuration.<br>
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
/**
|
||||
* Common USB descriptor values.<br>
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
/**
|
||||
* Represents an USB device.<br>
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
/**
|
||||
* Represents the descriptor of a USB device.<br>
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
/**
|
||||
* Represents the descriptor of an USB endpoint.<br>
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
/**
|
||||
* Represents an USB interface.<br>
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
/**
|
||||
* Represents the descriptor of a USB interface.<br>
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava;
|
||||
package ch.ntb.usb;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ch.ntb.inf.libusbJava.exceptions;
|
||||
package ch.ntb.usb.exceptions;
|
||||
|
||||
public class LibusbError extends Exception {
|
||||
private static final long serialVersionUID = 9096323614080207236L;
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.inf.libusbJava.logger;
|
||||
package ch.ntb.usb.logger;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
Reference in New Issue
Block a user