public UsbEndpointAssert hasDirection(int direction) { isNotNull(); int actualDirection = actual.getDirection(); assertThat(actualDirection) // .overridingErrorMessage("Expected direction <%s> but was <%s>.", direction, actualDirection) // .isEqualTo(direction); return this; }
public UsbEndpointAssert hasType(int type) { isNotNull(); int actualType = actual.getType(); assertThat(actualType) // .overridingErrorMessage("Expected type <%s> but was <%s>.", type, actualType) // .isEqualTo(type); return this; } }
public UsbEndpointAssert hasMaximumPacketSize(int size) { isNotNull(); int actualSize = actual.getMaxPacketSize(); assertThat(actualSize) // .overridingErrorMessage("Expected maximum packet size <%s> but was <%s>.", size, actualSize) // .isEqualTo(size); return this; }
Log.d(TAG, "EP " + i + ": " + ep.getType()); if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) { if (ep.getDirection() == UsbConstants.USB_DIR_OUT) { epOut = ep; } else if (ep.getDirection() == UsbConstants.USB_DIR_IN) { epIn = ep;
private String getEndpointText(final UsbEndpoint endpoint, final int index) { final String addressInBinary = padLeft(Integer.toBinaryString(endpoint.getAddress()), "0", 8); final String addressInHex = padLeft(Integer.toHexString(endpoint.getAddress()), "0", 2); final String attributesInBinary = padLeft(Integer.toBinaryString(endpoint.getAttributes()), "0", 8); String endpointText = "#" + index + "\n"; endpointText += getString(R.string.address_) + "0x" + addressInHex + " (" + addressInBinary + ")\n"; endpointText += getString(R.string.number_) + endpoint.getEndpointNumber() + "\n"; endpointText += getString(R.string.direction_) + UsbConstantResolver.resolveUsbEndpointDirection(endpoint.getDirection()) + "\n"; endpointText += getString(R.string.type_) + UsbConstantResolver.resolveUsbEndpointType(endpoint.getType()) + "\n"; endpointText += getString(R.string.poll_interval_) + endpoint.getInterval() + "\n"; endpointText += getString(R.string.max_packet_size_) + endpoint.getMaxPacketSize() + "\n"; endpointText += getString(R.string.attributes_) + attributesInBinary; return endpointText; }
private UsbMidiInterface asMidiInterface(UsbInterface iface) { // We really ought to check interface class and subclass, but we don't since a lot of MIDI // devices don't fully comply with the standard. // if (iface.getInterfaceClass() != 1 || iface.getInterfaceSubclass() != 3) return null; List<UsbMidiInput> inputs = new ArrayList<UsbMidiInput>(); List<UsbMidiOutput> outputs = new ArrayList<UsbMidiOutput>(); int epCount = iface.getEndpointCount(); for (int j = 0; j < epCount; ++j) { UsbEndpoint ep = iface.getEndpoint(j); // If the endpoint looks like a MIDI endpoint, assume that it is one. My reading of the USB // MIDI specification is that the max // packet size ought to be 0x40, but I've seen at least one interface (Focusrite Scarlett 2i4) // that reports a max packet size // of 0x200. So, we'll just check the minimum requirement for the rest of this class to work, // i.e., the max packet size must be // a positive multiple of 4. if ((ep.getType() & UsbConstants.USB_ENDPOINT_XFERTYPE_MASK) == UsbConstants.USB_ENDPOINT_XFER_BULK && (ep.getMaxPacketSize() & 0x03) == 0 && ep.getMaxPacketSize() > 0) { if ((ep.getDirection() & UsbConstants.USB_ENDPOINT_DIR_MASK) == UsbConstants.USB_DIR_IN) { inputs.add(new UsbMidiInput(iface, ep)); } else { outputs.add(new UsbMidiOutput(iface, ep)); } } } return (inputs.isEmpty() && outputs.isEmpty()) ? null : new UsbMidiInterface(iface, inputs, outputs); }
Log.i(logTag,"constructor: [endpoint 0 (IN)] address: " + usbEndpointIN.getAddress() + " attributes: " + usbEndpointIN.getAttributes() + " direction: " + usbEndpointIN.getDirection() + " max_packet_size: " + usbEndpointIN.getMaxPacketSize()); Log.i(logTag,"constructor: [endpoint 1 (OUT)] address: " + usbEndpointOUT.getAddress() + " attributes: " + usbEndpointOUT.getAttributes() + " direction: " + usbEndpointOUT.getDirection() + " max_packet_size: " + usbEndpointOUT.getMaxPacketSize());
for (int i = 0; i < usbInterface.getEndpointCount(); i++) { UsbEndpoint ep = usbInterface.getEndpoint(i); if (readEndpoint == null && ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT && ep.getAddress() == 0x81) { // number = 1 ; dir = USB_DIR_IN readEndpoint = ep; continue; if (writeEndpoint == null && ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT && (ep.getAddress() == 0x01 || ep.getAddress() == 0x02)) { // number = 1 ; dir = USB_DIR_OUT writeEndpoint = ep; continue; if (readEndpoint.getMaxPacketSize() != 64) { Timber.e(TAG, "tryGetDevice: Wrong packet size for read endpoint"); continue; if (writeEndpoint.getMaxPacketSize() != 64) { Timber.e(TAG, "tryGetDevice: Wrong packet size for write endpoint"); continue;
public UsbEndpointAssert hasAddress(int address) { isNotNull(); int actualAddress = actual.getAddress(); assertThat(actualAddress) // .overridingErrorMessage("Expected address <%s> but was <%s>.", address, actualAddress) // .isEqualTo(address); return this; }
public UsbEndpointAssert hasEndpointNumber(int number) { isNotNull(); int actualNumber = actual.getEndpointNumber(); assertThat(actualNumber) // .overridingErrorMessage("Expected endpoint number <%s> but was <%s>.", number, actualNumber) // .isEqualTo(number); return this; }
public UsbEndpointAssert hasAttributes(int attributes) { isNotNull(); int actualAttributes = actual.getAttributes(); assertThat(actualAttributes) // .overridingErrorMessage("Expected attributes <%s> but was <%s>.", attributes, actualAttributes) // .isEqualTo(attributes); return this; }
public UsbEndpointAssert hasInterval(int interval) { isNotNull(); int actualInterval = actual.getInterval(); assertThat(actualInterval) // .overridingErrorMessage("Expected interval <%s> but was <%s>.", interval, actualInterval) // .isEqualTo(interval); return this; }
UsbInterface intf = device.getInterface(0); // checks for 2 endpoints if (intf.getEndpointCount() != 2) { Toast toast = Toast.makeText(context, "could not find endpoint", duration); toast.show(); return; } UsbEndpoint ep = intf.getEndpoint(0); if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) { if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
Log.i(TAG," ++++ ++++ ++++"); Log.i(TAG," Endpoint index: " + epi); Log.i(TAG," Attributes: " + mEndpoint.getAttributes()); Log.i(TAG," Direction: " + mEndpoint.getDirection()); Log.i(TAG," Number: " + mEndpoint.getEndpointNumber()); Log.i(TAG," Interval: " + mEndpoint.getInterval()); Log.i(TAG," Packet size: " + mEndpoint.getMaxPacketSize()); Log.i(TAG," Type: " + mEndpoint.getType());
byte[] recordIn = new byte[mEndpointIn.getMaxPacketSize()]; int receivedLength = mDeviceConnection.bulkTransfer(mEndpointIn, recordIn, recordIn.length, mTimeout); UsbEndpoint usbEndpoint = mInterface.getEndpoint(i); if (usbEndpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_INT) { if (usbEndpoint.getDirection() == UsbConstants.USB_DIR_OUT) { usbEndpointOut = usbEndpoint;
public UsbEndpointAssert hasAddress(int address) { isNotNull(); int actualAddress = actual.getAddress(); assertThat(actualAddress) // .overridingErrorMessage("Expected address <%s> but was <%s>.", address, actualAddress) // .isEqualTo(address); return this; }
public UsbEndpointAssert hasEndpointNumber(int number) { isNotNull(); int actualNumber = actual.getEndpointNumber(); assertThat(actualNumber) // .overridingErrorMessage("Expected endpoint number <%s> but was <%s>.", number, actualNumber) // .isEqualTo(number); return this; }
public UsbEndpointAssert hasAttributes(int attributes) { isNotNull(); int actualAttributes = actual.getAttributes(); assertThat(actualAttributes) // .overridingErrorMessage("Expected attributes <%s> but was <%s>.", attributes, actualAttributes) // .isEqualTo(attributes); return this; }
public UsbEndpointAssert hasInterval(int interval) { isNotNull(); int actualInterval = actual.getInterval(); assertThat(actualInterval) // .overridingErrorMessage("Expected interval <%s> but was <%s>.", interval, actualInterval) // .isEqualTo(interval); return this; }
if (usbEndpointTemp.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) { if (usbEndpointTemp.getDirection() == UsbConstants.USB_DIR_IN) { } else if (usbEndpointTemp.getDirection() == UsbConstants.USB_DIR_OUT) {