- ant task for javadoc added

- some javadoc changes
- package descriptions added

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@160 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-08-17 10:33:43 +00:00
parent 625ce7d772
commit a3814e2443
6 changed files with 130 additions and 43 deletions

21
java/build.xml Normal file
View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="ch.ntb.usb" basedir=".">
<description>
Ant tasks for creating the javadoc (ch.ntb.usb)
</description>
<!-- javadoc properties -->
<!--
<property name="javadoc.destination" value="doc" />
-->
<property name="javadoc.destination" value="W:\inf\infoportalExternalDocs\projects\libusbWinJava\doc" />
<!-- build javadoc -->
<target name="javadoc">
<echo message="creating javadoc (\\www-server\web must be mapped to W:)" />
<javadoc destdir="${javadoc.destination}">
<fileset dir="src" defaultexcludes="yes">
</fileset>
</javadoc>
</target>
</project>

View File

@@ -22,7 +22,7 @@ public class Device {
private int idVendor, idProduct, configuration, interface_, altinterface; private int idVendor, idProduct, configuration, interface_, altinterface;
private int usb_dev_handle; private int usbDevHandle;
private boolean resetOnFirstOpen, resetDone; private boolean resetOnFirstOpen, resetDone;
@@ -44,11 +44,11 @@ public class Device {
* endpoints are found in the descriptors an exception is thrown. * endpoints are found in the descriptors an exception is thrown.
* *
* @param configuration * @param configuration
* the desired configuration * the configuration
* @param interface_ * @param interface_
* the desired interface * the interface
* @param altinterface * @param altinterface
* the desired alternative interface * the alternative interface
* @throws USBException * @throws USBException
*/ */
public void open(int configuration, int interface_, int altinterface) public void open(int configuration, int interface_, int altinterface)
@@ -59,7 +59,7 @@ public class Device {
Usb_Bus bus; Usb_Bus bus;
if (usb_dev_handle > 0) { if (usbDevHandle > 0) {
throw new USBException("device opened, close or reset first"); throw new USBException("device opened, close or reset first");
} }
@@ -88,41 +88,40 @@ public class Device {
if (res <= 0) { if (res <= 0) {
throw new USBException("LibusbWin.usb_open: " throw new USBException("LibusbWin.usb_open: "
+ LibusbWin.usb_strerror()); + LibusbWin.usb_strerror());
} else { }
usb_dev_handle = res; usbDevHandle = res;
// get endpoint wMaxPacketSize // get endpoint wMaxPacketSize
Usb_Config_Descriptor[] confDesc = dev.config; Usb_Config_Descriptor[] confDesc = dev.config;
for (int i = 0; i < confDesc.length; i++) { for (int i = 0; i < confDesc.length; i++) {
Usb_Interface[] int_ = confDesc[i].interface_; Usb_Interface[] int_ = confDesc[i].interface_;
for (int j = 0; j < int_.length; j++) { for (int j = 0; j < int_.length; j++) {
Usb_Interface_Descriptor[] intDesc = int_[j].altsetting; Usb_Interface_Descriptor[] intDesc = int_[j].altsetting;
for (int k = 0; k < intDesc.length; k++) { for (int k = 0; k < intDesc.length; k++) {
Usb_Endpoint_Descriptor[] epDesc = intDesc[k].endpoint; Usb_Endpoint_Descriptor[] epDesc = intDesc[k].endpoint;
for (int l = 0; l < epDesc.length; l++) { for (int l = 0; l < epDesc.length; l++) {
maxPacketSize = Math.max( maxPacketSize = Math.max(
epDesc[l].wMaxPacketSize, epDesc[l].wMaxPacketSize,
maxPacketSize); maxPacketSize);
}
} }
} }
} }
if (maxPacketSize <= 0) { }
throw new USBException( if (maxPacketSize <= 0) {
"No USB endpoints found. Check the device configuration"); throw new USBException(
} "No USB endpoints found. Check the device configuration");
} }
} }
dev = dev.next; dev = dev.next;
} }
bus = bus.next; bus = bus.next;
} }
if (usb_dev_handle <= 0) { if (usbDevHandle <= 0) {
throw new USBException("USB device with idVendor 0x" throw new USBException("USB device with idVendor 0x"
+ Integer.toHexString(idVendor & 0xFFFF) + Integer.toHexString(idVendor & 0xFFFF)
+ " and idProduct 0x" + " and idProduct 0x"
+ Integer.toHexString(idProduct & 0xFFFF) + " not found"); + Integer.toHexString(idProduct & 0xFFFF) + " not found");
} }
claim_interface(usb_dev_handle, configuration, interface_, altinterface); claim_interface(usbDevHandle, configuration, interface_, altinterface);
if (resetOnFirstOpen & !resetDone) { if (resetOnFirstOpen & !resetDone) {
logger.info("reset on first open"); logger.info("reset on first open");
resetDone = true; resetDone = true;
@@ -130,6 +129,7 @@ public class Device {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
//
} }
open(configuration, interface_, altinterface); open(configuration, interface_, altinterface);
} }
@@ -141,11 +141,11 @@ public class Device {
* @throws USBException * @throws USBException
*/ */
public void close() throws USBException { public void close() throws USBException {
if (usb_dev_handle <= 0) { if (usbDevHandle <= 0) {
throw new USBException("invalid device handle"); throw new USBException("invalid device handle");
} }
release_interface(usb_dev_handle, interface_); release_interface(usbDevHandle, interface_);
if (LibusbWin.usb_close(usb_dev_handle) < 0) { if (LibusbWin.usb_close(usbDevHandle) < 0) {
throw new USBException("LibusbWin.usb_close: " throw new USBException("LibusbWin.usb_close: "
+ LibusbWin.usb_strerror()); + LibusbWin.usb_strerror());
} }
@@ -161,15 +161,15 @@ public class Device {
* @throws USBException * @throws USBException
*/ */
public void reset() throws USBException { public void reset() throws USBException {
if (usb_dev_handle <= 0) { if (usbDevHandle <= 0) {
throw new USBException("invalid device handle"); throw new USBException("invalid device handle");
} }
if (LibusbWin.usb_reset(usb_dev_handle) < 0) { if (LibusbWin.usb_reset(usbDevHandle) < 0) {
usb_dev_handle = 0; usbDevHandle = 0;
throw new USBException("LibusbWin.usb_reset: " throw new USBException("LibusbWin.usb_reset: "
+ LibusbWin.usb_strerror()); + LibusbWin.usb_strerror());
} }
usb_dev_handle = 0; usbDevHandle = 0;
logger.info("device reset"); logger.info("device reset");
} }
@@ -193,7 +193,7 @@ public class Device {
*/ */
public int bulkwrite(int out_ep_address, byte[] data, int length, public int bulkwrite(int out_ep_address, byte[] data, int length,
int timeout, boolean reopenOnTimeout) throws USBException { int timeout, boolean reopenOnTimeout) throws USBException {
if (usb_dev_handle <= 0) { if (usbDevHandle <= 0) {
throw new USBException("invalid device handle"); throw new USBException("invalid device handle");
} }
if (data == null) { if (data == null) {
@@ -202,8 +202,8 @@ public class Device {
if (length <= 0) { if (length <= 0) {
throw new USBException("size must be > 0"); throw new USBException("size must be > 0");
} }
int lenWritten = LibusbWin.usb_bulk_write(usb_dev_handle, int lenWritten = LibusbWin.usb_bulk_write(usbDevHandle, out_ep_address,
out_ep_address, data, length, timeout); data, length, timeout);
if (lenWritten < 0) { if (lenWritten < 0) {
if (lenWritten == TIMEOUT_ERROR_CODE) { if (lenWritten == TIMEOUT_ERROR_CODE) {
// try to reopen the device and send the data again // try to reopen the device and send the data again
@@ -253,7 +253,7 @@ public class Device {
*/ */
public int bulkread(int in_ep_address, byte[] data, int size, int timeout, public int bulkread(int in_ep_address, byte[] data, int size, int timeout,
boolean reopenOnTimeout) throws USBException { boolean reopenOnTimeout) throws USBException {
if (usb_dev_handle <= 0) { if (usbDevHandle <= 0) {
throw new USBException("invalid device handle"); throw new USBException("invalid device handle");
} }
if (data == null) { if (data == null) {
@@ -262,7 +262,7 @@ public class Device {
if (size <= 0) { if (size <= 0) {
throw new USBException("size must be > 0"); throw new USBException("size must be > 0");
} }
int lenRead = LibusbWin.usb_bulk_read(usb_dev_handle, in_ep_address, int lenRead = LibusbWin.usb_bulk_read(usbDevHandle, in_ep_address,
data, size, timeout); data, size, timeout);
if (lenRead < 0) { if (lenRead < 0) {
if (lenRead == TIMEOUT_ERROR_CODE) { if (lenRead == TIMEOUT_ERROR_CODE) {
@@ -341,7 +341,7 @@ public class Device {
private void release_interface(int dev_handle, int interface_) private void release_interface(int dev_handle, int interface_)
throws USBException { throws USBException {
if (LibusbWin.usb_release_interface(dev_handle, interface_) < 0) { if (LibusbWin.usb_release_interface(dev_handle, interface_) < 0) {
usb_dev_handle = 0; usbDevHandle = 0;
throw new USBException("LibusbWin.usb_release_interface: " throw new USBException("LibusbWin.usb_release_interface: "
+ LibusbWin.usb_strerror()); + LibusbWin.usb_strerror());
} }
@@ -349,6 +349,8 @@ public class Device {
} }
/** /**
* Returns the product ID of the device.<br>
*
* @return the product ID of the device. * @return the product ID of the device.
*/ */
public int getIdProduct() { public int getIdProduct() {
@@ -356,6 +358,8 @@ public class Device {
} }
/** /**
* Returns the vendor ID of the device.<br>
*
* @return the vendor ID of the device. * @return the vendor ID of the device.
*/ */
public int getIdVendor() { public int getIdVendor() {
@@ -363,6 +367,9 @@ public class Device {
} }
/** /**
* Returns the alternative interface. This value is only valid after opening
* the device.<br>
*
* @return the alternative interface. This value is only valid after opening * @return the alternative interface. This value is only valid after opening
* the device. * the device.
*/ */
@@ -371,6 +378,9 @@ public class Device {
} }
/** /**
* Returns the current configuration used. This value is only valid after
* opening the device.<br>
*
* @return the current configuration used. This value is only valid after * @return the current configuration used. This value is only valid after
* opening the device. * opening the device.
*/ */
@@ -379,6 +389,9 @@ public class Device {
} }
/** /**
* Returns the current interface. This value is only valid after opening the
* device.<br>
*
* @return the current interface. This value is only valid after opening the * @return the current interface. This value is only valid after opening the
* device. * device.
*/ */
@@ -387,11 +400,14 @@ public class Device {
} }
/** /**
* Returns the current device handle. This value is only valid after opening
* the device.<br>
*
* @return the current device handle. This value is only valid after opening * @return the current device handle. This value is only valid after opening
* the device. * the device.
*/ */
public int getUsb_dev_handle() { public int getUsbDevHandle() {
return usb_dev_handle; return usbDevHandle;
} }
/** /**

View File

@@ -31,8 +31,8 @@ public class USB {
private static LinkedList<Device> devices = new LinkedList<Device>(); private static LinkedList<Device> devices = new LinkedList<Device>();
/** /**
* Create a new device an register it in a device queue or get an already * Create a new device an register it in a device queue. If the device is
* created device.<br> * already registered, a reference to it will be returned.<br>
* *
* @param idVendor * @param idVendor
* the vendor id of the USB device * the vendor id of the USB device

View File

@@ -0,0 +1,16 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head></head>
<body bgcolor="white">
Logging related classes.
<h2>Related Resources</h2>
For more information about this project visit
<a
href="http://inf.ntb.ch/infoportal/help/topic/ch.ntb.ntbHelp/projects.html">inf.ntb.ch</a>
.
</body>
</html>

View File

@@ -0,0 +1,17 @@
<!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
(requires the SWT library).
<h2>Related Resources</h2>
For more information about this project visit
<a
href="http://inf.ntb.ch/infoportal/help/topic/ch.ntb.ntbHelp/projects.html">inf.ntb.ch</a>
.
</body>
</html>

View File

@@ -0,0 +1,17 @@
<!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 (requires the SWT library).
<h2>Related Resources</h2>
For more information about this project visit
<a
href="http://inf.ntb.ch/infoportal/help/topic/ch.ntb.ntbHelp/projects.html">inf.ntb.ch</a>
.
</body>
</html>