- Corrected wrong package name in test directory
- Moved demo classes from the test tree to the application tree git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@279 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.libusbJava.test;
|
||||
package ch.ntb.inf.libusbJava.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.libusbJava.test;
|
||||
package ch.ntb.inf.libusbJava.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.libusbJava.test;
|
||||
package ch.ntb.inf.libusbJava.test;
|
||||
|
||||
import ch.ntb.inf.libusbJava.LibusbJava;
|
||||
import ch.ntb.inf.libusbJava.Usb_Bus;
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.libusbJava.test.devices;
|
||||
package ch.ntb.inf.libusbJava.test.devices;
|
||||
|
||||
import ch.ntb.inf.libusbJava.USB;
|
||||
import ch.ntb.inf.libusbJava.testApp.AbstractDeviceInfo;
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.libusbJava.test.devices;
|
||||
package ch.ntb.inf.libusbJava.test.devices;
|
||||
|
||||
import ch.ntb.inf.libusbJava.USB;
|
||||
import ch.ntb.inf.libusbJava.testApp.AbstractDeviceInfo;
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.libusbJava.test.devices;
|
||||
package ch.ntb.inf.libusbJava.test.devices;
|
||||
|
||||
import ch.ntb.inf.libusbJava.testApp.AbstractDeviceInfo;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.libusbJava.test.devices;
|
||||
package ch.ntb.inf.libusbJava.test.devices;
|
||||
|
||||
import ch.ntb.inf.libusbJava.testApp.AbstractDeviceInfo;
|
||||
|
||||
@@ -1,40 +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.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>
|
||||
*
|
||||
*
|
||||
*/
|
||||
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.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) 0x0222);
|
||||
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(0x03, 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(0x84, 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user