- AbstractDeviceInfo moved to ch.ntb.usb.testApp (no more references to test directory)
- initialization parameters for TestDevice added git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@229 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
151
java/src/ch/ntb/usb/testApp/AbstractDeviceInfo.java
Normal file
151
java/src/ch/ntb/usb/testApp/AbstractDeviceInfo.java
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Java libusb wrapper
|
||||
* Copyright (c) 2005-2006 Andreas Schl<68>pfer <libusb@drip.ch>
|
||||
*
|
||||
* This library is covered by the LGPL, read LGPL.txt for details.
|
||||
*/
|
||||
package ch.ntb.usb.testApp;
|
||||
|
||||
public abstract class AbstractDeviceInfo {
|
||||
|
||||
private short idVendor;
|
||||
|
||||
private short idProduct;
|
||||
|
||||
private int timeout;
|
||||
|
||||
private int configuration;
|
||||
|
||||
private int interface_;
|
||||
|
||||
private int altinterface;
|
||||
|
||||
private int outEPBulk;
|
||||
|
||||
private int inEPBulk;
|
||||
|
||||
private int outEPInt;
|
||||
|
||||
private int inEPInt;
|
||||
|
||||
private int sleepTimeout;
|
||||
|
||||
private int maxDataSize;
|
||||
|
||||
private TransferMode mode;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,9 +14,8 @@ import ch.ntb.usb.Device;
|
||||
import ch.ntb.usb.USB;
|
||||
import ch.ntb.usb.USBException;
|
||||
import ch.ntb.usb.logger.LogUtil;
|
||||
import ch.ntb.usb.test.AT90USB1287;
|
||||
|
||||
public class TestDevice extends AT90USB1287 {
|
||||
public class TestDevice extends AbstractDeviceInfo {
|
||||
|
||||
private static final Logger logger = LogUtil.getLogger("ch.ntb.usb.test");
|
||||
|
||||
@@ -41,6 +40,23 @@ public class TestDevice extends AT90USB1287 {
|
||||
outMode = TransferMode.Bulk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initValues() {
|
||||
setIdVendor((short) 0x8235);
|
||||
setIdProduct((short) 0x0222);
|
||||
setTimeout(2000);
|
||||
setConfiguration(1);
|
||||
setInterface(0);
|
||||
setAltinterface(-1);
|
||||
setOutEPBulk(0x01);
|
||||
setInEPBulk(0x82);
|
||||
setOutEPInt(0x03);
|
||||
setInEPInt(0x84);
|
||||
setSleepTimeout(2000);
|
||||
setMaxDataSize(USB.FULLSPEED_MAX_BULK_PACKET_SIZE);
|
||||
setMode(TransferMode.Bulk);
|
||||
}
|
||||
|
||||
public void openUsbDevice() {
|
||||
dev = USB.getDevice(getIdVendor(), getIdProduct());
|
||||
try {
|
||||
|
||||
@@ -34,9 +34,9 @@ import ch.ntb.usb.Usb_Device;
|
||||
import ch.ntb.usb.Usb_Device_Descriptor;
|
||||
import ch.ntb.usb.Usb_Endpoint_Descriptor;
|
||||
import ch.ntb.usb.Usb_Interface_Descriptor;
|
||||
import ch.ntb.usb.test.AbstractDeviceInfo.TransferMode;
|
||||
import ch.ntb.usb.testApp.TestApp;
|
||||
import ch.ntb.usb.testApp.TestDevice;
|
||||
import ch.ntb.usb.testApp.AbstractDeviceInfo.TransferMode;
|
||||
|
||||
public class UsbView extends JFrame {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user