busName added to be able to distinguish multiple instances of the same device on Linux
getRegisteredDevice fixed documentation updates and other minor improvements git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@273 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
@@ -73,7 +73,8 @@ public class DeviceTest {
|
||||
readData = new byte[testData.length];
|
||||
// initialise the device
|
||||
LibusbJava.usb_set_debug(255);
|
||||
dev = USB.getDevice(devinfo.getIdVendor(), devinfo.getIdProduct());
|
||||
dev = USB.getDevice(devinfo.getIdVendor(), devinfo.getIdProduct(),
|
||||
devinfo.getBusName(), devinfo.getFilename());
|
||||
assertNotNull(dev);
|
||||
|
||||
// print the devices
|
||||
@@ -102,6 +103,7 @@ public class DeviceTest {
|
||||
@Test
|
||||
public void initalReset() throws Exception {
|
||||
doOpen();
|
||||
// this may change the bus and file name of the device
|
||||
dev.reset();
|
||||
timeout();
|
||||
}
|
||||
@@ -153,19 +155,69 @@ public class DeviceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void openWithFilename() throws Exception {
|
||||
// get device by filename
|
||||
public void open() throws Exception {
|
||||
// get device by busname
|
||||
doOpen();
|
||||
assertNotNull(dev.getDevice());
|
||||
String oldFilename = dev.getDevice().getFilename();
|
||||
String oldBusName = dev.getDevice().getBus().getDirname();
|
||||
assertNotNull(oldFilename);
|
||||
log.info("Filename: " + oldFilename);
|
||||
assertNotNull(oldBusName);
|
||||
log.info("filename: " + oldFilename + ", busName: " + oldBusName);
|
||||
Device dev2 = USB.getDevice(devinfo.getIdVendor(), devinfo
|
||||
.getIdProduct(), oldFilename);
|
||||
assertEquals(dev, dev2);
|
||||
.getIdProduct());
|
||||
doClose();
|
||||
assertEquals(dev, dev2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void openWithBusName() throws Exception {
|
||||
// get device by busname
|
||||
doOpen();
|
||||
assertNotNull(dev.getDevice());
|
||||
String oldFilename = dev.getDevice().getFilename();
|
||||
String oldBusName = dev.getDevice().getBus().getDirname();
|
||||
assertNotNull(oldFilename);
|
||||
assertNotNull(oldBusName);
|
||||
log.info("filename: " + oldFilename + ", busName: " + oldBusName);
|
||||
Device dev2 = USB.getDevice(devinfo.getIdVendor(), devinfo
|
||||
.getIdProduct(), oldBusName, null);
|
||||
doClose();
|
||||
assertEquals(dev, dev2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void openWithFilename() throws Exception {
|
||||
// get device by busname
|
||||
doOpen();
|
||||
assertNotNull(dev.getDevice());
|
||||
String oldFilename = dev.getDevice().getFilename();
|
||||
String oldBusName = dev.getDevice().getBus().getDirname();
|
||||
assertNotNull(oldFilename);
|
||||
assertNotNull(oldBusName);
|
||||
log.info("filename: " + oldFilename + ", busName: " + oldBusName);
|
||||
Device dev2 = USB.getDevice(devinfo.getIdVendor(), devinfo
|
||||
.getIdProduct(), null, oldFilename);
|
||||
doClose();
|
||||
assertEquals(dev, dev2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void openWithBusAndFilename() throws Exception {
|
||||
// get device by busname and filename
|
||||
doOpen();
|
||||
assertNotNull(dev.getDevice());
|
||||
String oldFilename = dev.getDevice().getFilename();
|
||||
String oldBusName = dev.getDevice().getBus().getDirname();
|
||||
assertNotNull(oldFilename);
|
||||
assertNotNull(oldBusName);
|
||||
log.info("filename: " + oldFilename + ", busName: " + oldBusName);
|
||||
Device dev2 = USB.getDevice(devinfo.getIdVendor(), devinfo
|
||||
.getIdProduct(), oldBusName, oldFilename);
|
||||
doClose();
|
||||
assertEquals(dev, dev2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bulkWriteRead() throws Exception {
|
||||
checkBulkEndpoints();
|
||||
@@ -398,6 +450,7 @@ public class DeviceTest {
|
||||
return b;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void logData(byte[] data, int length) {
|
||||
if (length > 0) {
|
||||
log.info("length: " + length);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class MemoryLeakTest {
|
||||
|
||||
@Test
|
||||
public void bulkWriteReadMultiple() throws Exception {
|
||||
final int NumberOfIterations = 30000;
|
||||
final int NumberOfIterations = 3000;
|
||||
|
||||
devinfo.setMode(TransferMode.Bulk);
|
||||
doOpen();
|
||||
@@ -104,7 +104,7 @@ public class MemoryLeakTest {
|
||||
|
||||
@Test
|
||||
public void interruptWriteReadMultiple() throws Exception {
|
||||
final int NumberOfIterations = 30000;
|
||||
final int NumberOfIterations = 3000;
|
||||
|
||||
devinfo.setMode(TransferMode.Interrupt);
|
||||
doOpen();
|
||||
|
||||
@@ -216,9 +216,9 @@ public class TestLibUsbJava {
|
||||
verbose = false;
|
||||
}
|
||||
|
||||
// used for debugging. 0 = no debugging.
|
||||
// used for debugging. 0 = no debugging, 255 = with debugging
|
||||
//
|
||||
LibusbJava.usb_set_debug(0);
|
||||
LibusbJava.usb_set_debug(255);
|
||||
|
||||
LibusbJava.usb_init();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* http://libusbjava.sourceforge.net
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.usb.test;
|
||||
package ch.ntb.usb.test.devices;
|
||||
|
||||
import ch.ntb.usb.USB;
|
||||
import ch.ntb.usb.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.usb.test;
|
||||
package ch.ntb.usb.test.devices;
|
||||
|
||||
import ch.ntb.usb.USB;
|
||||
import ch.ntb.usb.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.usb.test;
|
||||
package ch.ntb.usb.test.devices;
|
||||
|
||||
import ch.ntb.usb.testApp.AbstractDeviceInfo;
|
||||
|
||||
34
java/test/ch/ntb/usb/test/devices/MousePlus.java
Normal file
34
java/test/ch/ntb/usb/test/devices/MousePlus.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.usb.test.devices;
|
||||
|
||||
import ch.ntb.usb.testApp.AbstractDeviceInfo;
|
||||
|
||||
public class MousePlus extends AbstractDeviceInfo {
|
||||
|
||||
@Override
|
||||
public void initValues() {
|
||||
setIdVendor((short) 0x046d);
|
||||
setIdProduct((short) 0xc016);
|
||||
setBusName("bus-0");
|
||||
setFilename("\\\\.\\libusb0-0001--0x046d-0xc016");
|
||||
setTimeout(2000);
|
||||
setConfiguration(1);
|
||||
setInterface(0);
|
||||
setAltinterface(0);
|
||||
setOutEPInt(-1);
|
||||
setInEPInt(0x81);
|
||||
setOutEPBulk(-1);
|
||||
setInEPBulk(-1);
|
||||
setSleepTimeout(5000);
|
||||
setMaxDataSize(4);
|
||||
setMode(TransferMode.Interrupt);
|
||||
// we only read data -> don't compare
|
||||
setDoCompareData(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user