本文整理汇总了Java中android.hardware.usb.UsbConstants.USB_DIR_OUT属性的典型用法代码示例。如果您正苦于以下问题:Java UsbConstants.USB_DIR_OUT属性的具体用法?Java UsbConstants.USB_DIR_OUT怎么用?Java UsbConstants.USB_DIR_OUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.hardware.usb.UsbConstants
的用法示例。
在下文中一共展示了UsbConstants.USB_DIR_OUT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AdbDevice
public AdbDevice(AdbTestActivity activity, UsbDeviceConnection connection,
UsbInterface intf) {
mActivity = activity;
mDeviceConnection = connection;
mSerial = connection.getSerial();
UsbEndpoint epOut = null;
UsbEndpoint epIn = null;
// look for our bulk endpoints
for (int i = 0; i < intf.getEndpointCount(); i++) {
UsbEndpoint ep = intf.getEndpoint(i);
if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
epOut = ep;
} else {
epIn = ep;
}
}
}
if (epOut == null || epIn == null) {
throw new IllegalArgumentException("not all endpoints found");
}
mEndpointOut = epOut;
mEndpointIn = epIn;
}
示例2: UsbHidDevice
private UsbHidDevice(UsbDevice usbDevice, UsbInterface usbInterface, UsbManager usbManager) {
mUsbDevice = usbDevice;
mUsbInterface = usbInterface;
mUsbManager= usbManager;
for (int i = 0; i < mUsbInterface.getEndpointCount(); i++) {
UsbEndpoint endpoint = mUsbInterface.getEndpoint(i);
int dir = endpoint.getDirection();
int type = endpoint.getType();
if (mInUsbEndpoint == null && dir == UsbConstants.USB_DIR_IN && type == UsbConstants.USB_ENDPOINT_XFER_INT) {
mInUsbEndpoint = endpoint;
}
if (mOutUsbEndpoint == null && dir == UsbConstants.USB_DIR_OUT && type == UsbConstants.USB_ENDPOINT_XFER_INT) {
mOutUsbEndpoint = endpoint;
}
}
}
示例3: bulkTransfer
int bulkTransfer(int interfaceNumber, int endpointNumber, int direction,
byte[] buffer, int timeout)
throws UsbError {
if (direction == UsbConstants.USB_DIR_OUT) {
echoBytes = buffer;
return echoBytes.length;
}
// IN transfer.
if (echoBytes == null) {
return 0;
}
int len = Math.min(echoBytes.length, buffer.length);
System.arraycopy(echoBytes, 0, buffer, 0, len);
echoBytes = null;
return len;
}
示例4: interruptTransfer
int interruptTransfer(int interfaceNumber, int endpointNumber, int direction,
byte[] buffer, int timeout)
throws UsbError {
if (direction == UsbConstants.USB_DIR_OUT) {
echoBytes = buffer;
return echoBytes.length;
}
// IN transfer.
if (echoBytes == null) {
return 0;
}
int len = Math.min(echoBytes.length, buffer.length);
System.arraycopy(echoBytes, 0, buffer, 0, len);
echoBytes = null;
return len;
}
示例5: ConnectedUsbDevice
public ConnectedUsbDevice(UsbDeviceConnection connection, UsbInterface usbInterface) {
this.connection = connection;
this.usbInterface = usbInterface;
initConnection(connection);
int endPoints = usbInterface.getEndpointCount();
int interfaceProtocol = usbInterface.getInterfaceProtocol();
System.out.println("EndPoints: " + endPoints + " | interfaces: " + interfaceProtocol);
out = usbInterface.getEndpoint(1);
in = usbInterface.getEndpoint(2);
for (int x = 0; x < endPoints; x++) {
UsbEndpoint endpoint = usbInterface.getEndpoint(x);
boolean bulk = endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK;
boolean crtl = endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_CONTROL;
boolean inDir = endpoint.getDirection() == UsbConstants.USB_DIR_IN;
boolean outDir = endpoint.getDirection() == UsbConstants.USB_DIR_OUT;
System.out.println("ID: " + x + " Bulk: " + bulk + " Ctrl: " + crtl + " Out: " + outDir + " In: " + inDir);
}
}
示例6: UsbMidiDeviceAndroid
/**
* Constructs a UsbMidiDeviceAndroid.
* @param manager
* @param device The USB device which this object is assocated with.
*/
UsbMidiDeviceAndroid(UsbManager manager, UsbDevice device) {
mConnection = manager.openDevice(device);
mEndpointMap = new HashMap<Integer, UsbEndpoint>();
mRequestMap = new HashMap<UsbEndpoint, UsbRequest>();
for (int i = 0; i < device.getInterfaceCount(); ++i) {
UsbInterface iface = device.getInterface(i);
if (iface.getInterfaceClass() != UsbConstants.USB_CLASS_AUDIO ||
iface.getInterfaceSubclass() != MIDI_SUBCLASS) {
continue;
}
mConnection.claimInterface(iface, true);
for (int j = 0; j < iface.getEndpointCount(); ++j) {
UsbEndpoint endpoint = iface.getEndpoint(j);
if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) {
mEndpointMap.put(endpoint.getEndpointNumber(), endpoint);
}
}
}
}
示例7: SonyInitiator
/**
* Constructs a class driver object, if the device supports
* operations according to Annex D of the PTP specification.
*
* @param dev the first PTP interface will be used
* @param connection
* @throws IllegalArgumentException if the device has no
* Digital Still Imaging Class or PTP interfaces
*/
public SonyInitiator(UsbDevice dev, UsbDeviceConnection connection) throws PTPException {
super();
this.mConnection = connection;
if (dev == null) {
throw new PTPException ("dev = null");//IllegalArgumentException();
}
session = new Session();
this.device = dev;
intf = findUsbInterface (dev);
if (intf == null) {
//if (usbInterface == null) {
throw new PTPException("No PTP interfaces associated to the device");
}
for (int i = 0; i < intf.getEndpointCount(); i++) {
UsbEndpoint ep = intf.getEndpoint(i);
if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
epOut = ep;
} else {
epIn = ep;
}
}
if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT){
epEv = ep;
}
}
endpointSanityCheck();
inMaxPS = epOut.getMaxPacketSize();
intrMaxPS = epIn.getMaxPacketSize();
// clear epOut any previous state
reset();
}
示例8: nameForDirection
public static String nameForDirection(int direction) {
switch (direction) {
case UsbConstants.USB_DIR_IN:
return "IN";
case UsbConstants.USB_DIR_OUT:
return "OUT";
default:
return "Unknown Direction";
}
}
示例9: openCH34X
private boolean openCH34X()
{
if(connection.claimInterface(mInterface, true))
{
Log.i(CLASS_ID, "Interface succesfully claimed");
}else
{
Log.i(CLASS_ID, "Interface could not be claimed");
return false;
}
// Assign endpoints
int numberEndpoints = mInterface.getEndpointCount();
for(int i=0;i<=numberEndpoints-1;i++)
{
UsbEndpoint endpoint = mInterface.getEndpoint(i);
if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
&& endpoint.getDirection() == UsbConstants.USB_DIR_IN)
{
inEndpoint = endpoint;
}else if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
&& endpoint.getDirection() == UsbConstants.USB_DIR_OUT)
{
outEndpoint = endpoint;
}
}
return init() == 0;
}
示例10: openCDC
private boolean openCDC()
{
if(connection.claimInterface(mInterface, true))
{
Log.i(CLASS_ID, "Interface succesfully claimed");
}else
{
Log.i(CLASS_ID, "Interface could not be claimed");
return false;
}
// Assign endpoints
int numberEndpoints = mInterface.getEndpointCount();
for(int i=0;i<=numberEndpoints-1;i++)
{
UsbEndpoint endpoint = mInterface.getEndpoint(i);
if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
&& endpoint.getDirection() == UsbConstants.USB_DIR_IN)
{
inEndpoint = endpoint;
}else if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
&& endpoint.getDirection() == UsbConstants.USB_DIR_OUT)
{
outEndpoint = endpoint;
}
}
if(outEndpoint == null || inEndpoint == null)
{
Log.i(CLASS_ID, "Interface does not have an IN or OUT interface");
return false;
}
// Default Setup
setControlCommand(CDC_SET_LINE_CODING, 0, getInitialLineCoding());
setControlCommand(CDC_SET_CONTROL_LINE_STATE, CDC_CONTROL_LINE_ON, null);
return true;
}
示例11: SmartCardChannel
/** Constructor. Inicia los EndPoints del Interfaz del dispositivo
* @param usbDevCon
* @param usbInterface */
protected SmartCardChannel(final UsbDeviceConnection usbDevCon, final UsbInterface usbInterface) {
this.usbDeviceConnection = usbDevCon;
for (int i = 0; i < usbInterface.getEndpointCount(); i++) {
final UsbEndpoint usbEndPoint = usbInterface.getEndpoint(i);
if (usbEndPoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
if (usbEndPoint.getDirection() == UsbConstants.USB_DIR_IN) {
this.endPointIn = usbEndPoint;
}
else if (usbEndPoint.getDirection() == UsbConstants.USB_DIR_OUT) {
this.endPointOut = usbEndPoint;
}
}
}
}
示例12: openCDC
private boolean openCDC()
{
if(connection.claimInterface(mInterface, true))
{
Log.i(CLASS_ID, "Interface succesfully claimed");
}else
{
Log.i(CLASS_ID, "Interface could not be claimed");
return false;
}
// Assign endpoints
int numberEndpoints = mInterface.getEndpointCount();
for(int i=0;i<=numberEndpoints-1;i++)
{
UsbEndpoint endpoint = mInterface.getEndpoint(i);
if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
&& endpoint.getDirection() == UsbConstants.USB_DIR_IN)
{
inEndpoint = endpoint;
}else if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
&& endpoint.getDirection() == UsbConstants.USB_DIR_OUT)
{
outEndpoint = endpoint;
}
}
if(outEndpoint == null || inEndpoint == null)
{
Log.i(CLASS_ID, "Interface does not have an IN or OUT interface");
return false;
}
// Default Setup
setControlCommand(CDC_SET_LINE_CODING, 0, CDC_DEFAULT_LINE_CODING);
setControlCommand(CDC_SET_CONTROL_LINE_STATE, CDC_CONTROL_LINE_ON, null);
return true;
}
示例13: FcUsbDevice
public FcUsbDevice(MainActivity activity, UsbDeviceConnection connection,
UsbInterface intf, Map<String, UAVTalkXMLObject> xmlObjects) {
super(activity);
//mActivity = activity;
mDeviceConnection = connection;
mObjectTree = new UAVTalkObjectTree();
mObjectTree.setXmlObjects(xmlObjects);
mActivity.setPollThreadObjectTree(mObjectTree);
UsbEndpoint epOut = null;
UsbEndpoint epIn = null;
// look for our bulk endpoints
for (int i = 0; i < intf.getEndpointCount(); i++) {
UsbEndpoint ep = intf.getEndpoint(i);
if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT) {
if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
epOut = ep;
} else {
epIn = ep;
}
}
}
if (epOut == null || epIn == null) {
throw new IllegalArgumentException("not all endpoints found");
}
mEndpointOut = epOut;
mEndpointIn = epIn;
mWaiterThread = new FcUsbWaiterThread(this, mDeviceConnection, mEndpointIn);
}
示例14: open
/**
* 打开PL2303HXA设备
*
* @throws PL2303Exception
* 打开失败异常,如果未授权或不支持的设置参数
*/
public void open() throws PL2303Exception {
usbDeviceConnection = usbManager.openDevice(usbDevice);
if (usbDeviceConnection != null) {
Log.i(TAG, "openDevice()=>ok!");
Log.i(TAG, "getInterfaceCount()=>" + usbDevice.getInterfaceCount());
usbInterface = usbDevice.getInterface(0);
for (int i = 0; i < usbInterface.getEndpointCount(); ++i) {
UsbEndpoint ue = usbInterface.getEndpoint(i);
if (ue.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK && ue.getDirection() == UsbConstants.USB_DIR_IN) {
uein = ue;
} else if (ue.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK && ue.getDirection() == UsbConstants.USB_DIR_OUT) {
ueout = ue;
}
}
if (uein != null && ueout != null) {
Log.i(TAG, "get Endpoint ok!");
usbDeviceConnection.claimInterface(usbInterface, true);
byte[] buffer = new byte[1];
controlTransfer(192, 1, 33924, 0, buffer, 1, transferTimeOut);
controlTransfer(64, 1, 1028, 0, null, 0, transferTimeOut);
controlTransfer(192, 1, 33924, 0, buffer, 1, transferTimeOut);
controlTransfer(192, 1, 33667, 0, buffer, 1, transferTimeOut);
controlTransfer(192, 1, 33924, 0, buffer, 1, transferTimeOut);
controlTransfer(64, 1, 1028, 1, null, 0, transferTimeOut);
controlTransfer(192, 1, 33924, 0, buffer, 1, transferTimeOut);
controlTransfer(192, 1, 33667, 0, buffer, 1, transferTimeOut);
controlTransfer(64, 1, 0, 1, null, 0, transferTimeOut);
controlTransfer(64, 1, 1, 0, null, 0, transferTimeOut);
controlTransfer(64, 1, 2, 68, null, 0, transferTimeOut);
reset();
opened = true;
}
} else {
Log.e(TAG, "openDevice()=>fail!");
throw new PL2303Exception("usbManager.openDevice failed!");
}
}
示例15: UsbMidiDeviceAndroid
/**
* Constructs a UsbMidiDeviceAndroid.
* @param manager
* @param device The USB device which this object is assocated with.
*/
UsbMidiDeviceAndroid(UsbManager manager, UsbDevice device) {
mConnection = manager.openDevice(device);
mEndpointMap = new SparseArray<UsbEndpoint>();
mRequestMap = new HashMap<UsbEndpoint, UsbRequest>();
mHandler = new Handler();
mUsbDevice = device;
mIsClosed = false;
mHasInputThread = false;
mNativePointer = 0;
for (int i = 0; i < device.getInterfaceCount(); ++i) {
UsbInterface iface = device.getInterface(i);
if (iface.getInterfaceClass() != UsbConstants.USB_CLASS_AUDIO
|| iface.getInterfaceSubclass() != MIDI_SUBCLASS) {
continue;
}
mConnection.claimInterface(iface, true);
for (int j = 0; j < iface.getEndpointCount(); ++j) {
UsbEndpoint endpoint = iface.getEndpoint(j);
if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) {
mEndpointMap.put(endpoint.getEndpointNumber(), endpoint);
}
}
}
// Start listening for input endpoints.
// This function will create and run a thread if there is USB-MIDI endpoints in the
// device. Note that because UsbMidiDevice is shared among all tabs and the thread
// will be terminated when the device is disconnected, at most one thread can be created
// for each connected USB-MIDI device.
startListen(device);
}