public void testGetStatusNonStatic() {
    /* The method being tested is:
     * public static short getStatus(byte recipient, short target)
     *                              throws usbException, IllegalArgumentException
     */

    StandardRequest standardRequest = new StandardRequest(usbDevice);

    short configurationNumber;
    byte recipientType;
    short featureSelection;
    short target;
    short wIndex;
    short status;
    short statusExpected;
    byte requestType;

    boolean usbExceptionThrown = false;

    /**
     * ********************************************************************** First, getStatus for a
     * new configuration **********************************************************************
     */
    configurationNumber = 1;
    status = 0;
    // no target needed when recipient is a device
    target = 0;
    // set recipientType to Device
    recipientType = UsbConst.REQUESTTYPE_RECIPIENT_DEVICE;
    requestType = UsbConst.REQUESTTYPE_DIRECTION_IN;
    statusExpected = 0;

    // @P2D16
    LastUsbDeviceDataEvent = null;
    LastUsbDeviceErrorEvent = null;

    try {

      status = standardRequest.getStatus(recipientType, target);

      try {
        /*
         * Wait for device event before leaving setFeature routine
         */
        for (int i = 0; i < 100; i++) {
          if ((LastUsbDeviceDataEvent != null) | (LastUsbDeviceErrorEvent != null)) {
            break;
          }
          Thread.sleep(20); // wait 20 ms before checking for event
        }
      } catch (InterruptedException e) {
        fail("Sleep was interrupted");
      }

      /*status is unknown at this point, so don't check the value yet*/

    } catch (UsbException uE) {
      fail("Got exception getting the device status. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    /* Verify proper listener event received */
    assertNotNull("DeviceDataEvent should not be null.", LastUsbDeviceDataEvent);
    assertNull("DeviceErrorEvent should be null.", LastUsbDeviceErrorEvent);

    verifyGetStatusIrp(target, requestType);

    /**
     * ********************************************************************** Now, do a setFeature
     * for the device and check getStatus
     * **********************************************************************
     */
    featureSelection = UsbConst.FEATURE_SELECTOR_DEVICE_REMOTE_WAKEUP;
    statusExpected = 2;

    try {

      standardRequest.setFeature(recipientType, featureSelection, target);
      try {
        /*Wait for setConfiguration Data event before continuing */
        Thread.sleep(250);
      } catch (InterruptedException e) {
        fail("Sleep was interrupted.");
      }

    } catch (UsbException uE) {
      fail("Got exception setting Feature. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    LastUsbDeviceDataEvent = null;
    LastUsbDeviceErrorEvent = null;

    try {

      status = standardRequest.getStatus(recipientType, target);

      try {
        /*
         * Wait for device event before leaving setFeature routine
         */
        for (int i = 0; i < 100; i++) {
          if ((LastUsbDeviceDataEvent != null) | (LastUsbDeviceErrorEvent != null)) {
            break;
          }
          Thread.sleep(20); // wait 20 ms before checking for event
        }
      } catch (InterruptedException e) {
        fail("Sleep was interrupted");
      }

      assertEquals(
          "Status is not as expected.  Expected value = "
              + statusExpected
              + ", Actual value = "
              + status,
          statusExpected,
          status);

    } catch (UsbException uE) {
      fail("Got exception getting the device status. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    /* Verify proper listener event received */
    assertNotNull("DeviceDataEvent should not be null.", LastUsbDeviceDataEvent);
    assertNull("DeviceErrorEvent should be null.", LastUsbDeviceErrorEvent);

    verifyGetStatusIrp(target, requestType);

    /**
     * ********************************************************************** Now, do a clearFeature
     * for the device and check getStatus
     * **********************************************************************
     */
    featureSelection = UsbConst.FEATURE_SELECTOR_DEVICE_REMOTE_WAKEUP;
    statusExpected = 0;

    try {

      standardRequest.clearFeature(recipientType, featureSelection, target);
      try {
        /*Wait for setConfiguration Data event before continuing */
        Thread.sleep(250);
      } catch (InterruptedException e) {
        fail("Sleep was interrupted.");
      }

    } catch (UsbException uE) {
      fail("Got exception clearing Feature. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    LastUsbDeviceDataEvent = null;
    LastUsbDeviceErrorEvent = null;

    try {

      status = standardRequest.getStatus(recipientType, target);

      try {
        /*
         * Wait for device event before leaving setFeature routine
         */
        for (int i = 0; i < 100; i++) {
          if ((LastUsbDeviceDataEvent != null) | (LastUsbDeviceErrorEvent != null)) {
            break;
          }
          Thread.sleep(20); // wait 20 ms before checking for event
        }
      } catch (InterruptedException e) {
        fail("Sleep was interrupted");
      }

      assertEquals(
          "Status is not as expected.  Expected value = "
              + statusExpected
              + ", Actual value = "
              + status,
          statusExpected,
          status);

    } catch (UsbException uE) {
      fail("Got exception getting the device status. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    /* Verify proper listener event received */
    assertNotNull("DeviceDataEvent should not be null.", LastUsbDeviceDataEvent);
    assertNull("DeviceErrorEvent should be null.", LastUsbDeviceErrorEvent);

    verifyGetStatusIrp(target, requestType);

    /**
     * ********************************************************************** GetStatus for a device
     * with an illegal argument
     * **********************************************************************
     */
    recipientType = 3;
    LastUsbDeviceDataEvent = null;
    LastUsbDeviceErrorEvent = null;

    try {

      status = standardRequest.getStatus(recipientType, target);

      try {
        /*
         * Wait for device event before leaving setFeature routine
         */
        for (int i = 0; i < 100; i++) {
          if ((LastUsbDeviceDataEvent != null) | (LastUsbDeviceErrorEvent != null)) {
            break;
          }
          Thread.sleep(20); // wait 20 ms before checking for event
        }
      } catch (InterruptedException e) {
        fail("Sleep was interrupted");
      }

    } catch (UsbException uE) {
      fail("Got exception getting the device status. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      usbExceptionThrown = true;
    } finally {
      assertTrue(
          "UsbException should have been thrown for using an illegal recipient type:  "
              + UsbUtil.toHexString(recipientType),
          usbExceptionThrown);
    }

    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      fail("Sleep was interrupted");
    }

    /* Verify proper listener event received */
    /* Don't get data or error event with illegal argument exception*/
    assertNull("DeviceDataEvent should be null.", LastUsbDeviceDataEvent);
    assertNull("DeviceErrorEvent should be null.", LastUsbDeviceErrorEvent);

    /**
     * ********************************************************************** Now getStatus for an
     * interface ***********************************************************************
     */
    configurationNumber = 1;

    // no target needed when recipient is a device
    target = 0;
    // set recipientType to Interface
    recipientType = UsbConst.REQUESTTYPE_RECIPIENT_INTERFACE;
    requestType = UsbConst.REQUESTTYPE_DIRECTION_IN + UsbConst.REQUESTTYPE_RECIPIENT_INTERFACE;
    statusExpected = 0;

    // @P2D16
    LastUsbDeviceDataEvent = null;
    LastUsbDeviceErrorEvent = null;

    try {

      try {
        usbDevice.getActiveUsbConfiguration().getUsbInterface((byte) target).claim();
      } catch (UsbClaimException uCE) {
        fail("Config " + configurationNumber + " Interface " + target + " is already claimed!");
      } catch (UsbNotActiveException uNAE) {
        fail("Config " + configurationNumber + " is not active!");
      } catch (UsbException uE) {
        fail("Config " + configurationNumber + " could not be claimed!");
      } catch (UsbDisconnectedException uDE) // @P1C
      { // @P1A
        fail("A connected device should't throw the UsbDisconnectedException!"); // @P1A
      } // @P1A
      status = standardRequest.getStatus(recipientType, target);

      try {
        /*
         * Wait for device event before leaving setFeature routine
         */
        for (int i = 0; i < 100; i++) {
          if ((LastUsbDeviceDataEvent != null) | (LastUsbDeviceErrorEvent != null)) {
            break;
          }
          Thread.sleep(20); // wait 20 ms before checking for event
        }
      } catch (InterruptedException e) {
        fail("Sleep was interrupted");
      }

      // status should be 0 since interface status cannot be changed
      status = 0;
      assertEquals(
          "Status is not as expected.  Expected value = "
              + statusExpected
              + ", Actual value = "
              + status,
          statusExpected,
          status);

    } catch (UsbException uE) {
      fail("Got exception getting the device status. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    // Verify proper listener event received
    assertNotNull("DeviceDataEvent should not be null.", LastUsbDeviceDataEvent);
    assertNull("DeviceErrorEvent should be null.", LastUsbDeviceErrorEvent);

    verifyGetStatusIrp(target, requestType);

    /**
     * ********************************************************************** Now getStatus for an
     * endpoint ***********************************************************************
     */
    short endpoint;

    configurationNumber = 1;
    status = 0;
    // no target needed when recipient is a device
    target = 0;
    // set recipientType to Interface
    recipientType = UsbConst.REQUESTTYPE_RECIPIENT_ENDPOINT;
    requestType = UsbConst.REQUESTTYPE_DIRECTION_IN + UsbConst.REQUESTTYPE_RECIPIENT_ENDPOINT;
    statusExpected = 1;
    endpoint = 0x82;

    // @P2D16
    LastUsbDeviceDataEvent = null;
    LastUsbDeviceErrorEvent = null;

    try {

      status = standardRequest.getStatus(recipientType, endpoint);

      try {
        /*
         * Wait for device event before leaving setFeature routine
         */
        for (int i = 0; i < 100; i++) {
          if ((LastUsbDeviceDataEvent != null) | (LastUsbDeviceErrorEvent != null)) {
            break;
          }
          Thread.sleep(20); // wait 20 ms before checking for event
        }
      } catch (InterruptedException e) {
        fail("Sleep was interrupted");
      }

      /*status is unknown at this point, so don't check the value yet	*/

    } catch (UsbException uE) {
      fail("Got exception getting the device status. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    /* Verify proper listener event received */
    assertNotNull("DeviceDataEvent should not be null.", LastUsbDeviceDataEvent);
    assertNull("DeviceErrorEvent should be null.", LastUsbDeviceErrorEvent);

    verifyGetStatusIrp(endpoint, requestType);

    /**
     * ********************************************************************** getStatus after
     * setting feature for the endpoint
     * ***********************************************************************
     */
    featureSelection = UsbConst.FEATURE_SELECTOR_ENDPOINT_HALT;
    statusExpected = 1;

    try {

      standardRequest.setFeature(recipientType, featureSelection, endpoint);
      try {
        /*Wait for setConfiguration Data event before continuing */
        Thread.sleep(250);
      } catch (InterruptedException e) {
        fail("Sleep was interrupted.");
      }

    } catch (UsbException uE) {
      fail("Got exception setting Feature. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    LastUsbDeviceDataEvent = null;
    LastUsbDeviceErrorEvent = null;

    try {

      status = standardRequest.getStatus(recipientType, endpoint);

      try {
        /*
         * Wait for device event before leaving setFeature routine
         */
        for (int i = 0; i < 100; i++) {
          if ((LastUsbDeviceDataEvent != null) | (LastUsbDeviceErrorEvent != null)) {
            break;
          }
          Thread.sleep(20); // wait 20 ms before checking for event
        }
      } catch (InterruptedException e) {
        fail("Sleep was interrupted");
      }

      assertEquals(
          "Status is not as expected.  Expected value = "
              + statusExpected
              + ", Actual value = "
              + status,
          statusExpected,
          status);

    } catch (UsbException uE) {
      fail("Got exception getting the device status. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    /* Verify proper listener event received */
    assertNotNull("DeviceDataEvent should not be null.", LastUsbDeviceDataEvent);
    assertNull("DeviceErrorEvent should be null.", LastUsbDeviceErrorEvent);

    verifyGetStatusIrp(endpoint, requestType);

    /**
     * ********************************************************************** Now, do a clearFeature
     * for the endpoint and check getStatus
     * **********************************************************************
     */
    featureSelection = UsbConst.FEATURE_SELECTOR_ENDPOINT_HALT;
    statusExpected = 0;

    try {

      standardRequest.clearFeature(recipientType, featureSelection, endpoint);
      try {
        /*Wait for setConfiguration Data event before continuing */
        Thread.sleep(250);
      } catch (InterruptedException e) {
        fail("Sleep was interrupted.");
      }

    } catch (UsbException uE) {
      fail("Got exception clearing Feature. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    LastUsbDeviceDataEvent = null;
    LastUsbDeviceErrorEvent = null;

    try {

      status = standardRequest.getStatus(recipientType, endpoint);

      try {
        /*
         * Wait for device event before leaving setFeature routine
         */
        for (int i = 0; i < 100; i++) {
          if ((LastUsbDeviceDataEvent != null) | (LastUsbDeviceErrorEvent != null)) {
            break;
          }
          Thread.sleep(20); // wait 20 ms before checking for event
        }
      } catch (InterruptedException e) {
        fail("Sleep was interrupted");
      }

      assertEquals(
          "Status is not as expected.  Expected value = "
              + statusExpected
              + ", Actual value = "
              + status,
          statusExpected,
          status);

    } catch (UsbException uE) {
      fail("Got exception getting the device status. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      fail("Got illegal argument exception.  Exception message" + iE.getMessage());
    }

    /* Verify proper listener event received */
    assertNotNull("DeviceDataEvent should not be null.", LastUsbDeviceDataEvent);
    assertNull("DeviceErrorEvent should be null.", LastUsbDeviceErrorEvent);

    verifyGetStatusIrp(endpoint, requestType);

    /**
     * ********************************************************************** GetStatus for an
     * endpoint with an illegal argument
     * **********************************************************************
     */

    // set recipientType to an illegal value
    recipientType = 3;
    LastUsbDeviceDataEvent = null;
    LastUsbDeviceErrorEvent = null;

    try {

      status = standardRequest.getStatus(recipientType, endpoint);

      try {
        /*
         * Wait for device event before leaving setFeature routine
         */
        for (int i = 0; i < 100; i++) {
          if ((LastUsbDeviceDataEvent != null) | (LastUsbDeviceErrorEvent != null)) {
            break;
          }
          Thread.sleep(20); // wait 20 ms before checking for event
        }
      } catch (InterruptedException e) {
        fail("Sleep was interrupted");
      }

    } catch (UsbException uE) {
      fail("Got exception getting the device status. Exception message: " + uE.getMessage());
    } catch (IllegalArgumentException iE) {
      usbExceptionThrown = true;
    } finally {
      assertTrue(
          "UsbException should have been thrown for using an illegal recipient type:  "
              + UsbUtil.toHexString(recipientType),
          usbExceptionThrown);
    }

    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      fail("Sleep was interrupted");
    }

    try {
      usbDevice.getActiveUsbConfiguration().getUsbInterface((byte) target).release();
    } catch (UsbClaimException uCE) {
      fail("Config " + configurationNumber + " Interface " + target + " is not claimed!");
    } catch (UsbException uE) {
      fail("Config " + configurationNumber + " could not be released!");
    } catch (UsbDisconnectedException uDE) // @P1C
    { // @P1A
      fail("A connected device should't throw the UsbDisconnectedException!"); // @P1A
    } // @P1A

    /* Verify proper listener event received */
    assertNull("DeviceDataEvent should be null.", LastUsbDeviceDataEvent);
    assertNull("DeviceErrorEvent should be null.", LastUsbDeviceErrorEvent);
  }
Ejemplo n.º 2
0
  protected void RoundTripIOTestShortPacket(
      byte testType,
      int syncOrAsync,
      int numIrps,
      int endpointmaxPacketSize,
      boolean[] acceptShortPacket,
      boolean[] verifyAcceptShortPacket,
      int[] OUTLength,
      int[] OUTOffset,
      int[] OUTExpectedLength,
      Exception[] OUTexpectedException,
      int[] INLength,
      int[] INOffset,
      int[] INExpectedLength,
      Exception[] INexpectedException,
      byte[] transformType) {

    // Note that this code is based on IOTests.RounTripTest which handles IRP, IRPList, and Byte
    // array.  Since only IRPs
    // are being sent in this test, some of the complexity has been removed; however,  although the
    // numIrps is always
    // one for this test, the code has not been changed to get rid of the arrays.

    // ensure all values set up
    Assert.assertEquals(numIrps, transformType.length);
    Assert.assertEquals(numIrps, OUTLength.length);
    Assert.assertEquals(numIrps, OUTOffset.length);
    Assert.assertEquals(numIrps, acceptShortPacket.length);
    Assert.assertEquals(numIrps, verifyAcceptShortPacket.length);
    Assert.assertEquals(numIrps, OUTExpectedLength.length);
    Assert.assertEquals(numIrps, OUTexpectedException.length);
    Assert.assertEquals(numIrps, INLength.length);
    Assert.assertEquals(numIrps, INOffset.length);
    Assert.assertEquals(numIrps, INExpectedLength.length);
    Assert.assertEquals(numIrps, INexpectedException.length);

    Assert.assertNotNull("usbDevice is null, but should not be null.", usbDevice);
    Assert.assertEquals("For short packet test, number of IRPs should be 1.", 1, numIrps);

    /*
     * set up Pipes and add listeners
     */
    UsbPipe inPipe = null;
    UsbPipe outPipe = null;

    // we need two int values back from method call so we'll put them in the array
    int[] pipeListIndexes = new int[2];
    int inPipeArrayIndex = 0;
    int outPipeArrayIndex = 1;

    IOMethods.findINandOUTPipesForTest(
        usbPipeListGlobal,
        endpointmaxPacketSize,
        pipeListIndexes,
        inPipeArrayIndex,
        outPipeArrayIndex);
    inPipe = (UsbPipe) usbPipeListGlobal.get(pipeListIndexes[inPipeArrayIndex]);
    outPipe = (UsbPipe) usbPipeListGlobal.get(pipeListIndexes[outPipeArrayIndex]);
    IOMethods.verifyThePipes(inPipe, outPipe, endpointmaxPacketSize);

    inPipe.addUsbPipeListener(inPipeListener);
    outPipe.addUsbPipeListener(outPipeListener);

    IOMethods.openPipe(inPipe);
    IOMethods.openPipe(outPipe);

    // define buffers to be used in IRPs or sent as byte[]
    byte[] aggregateOUTbuffer = null;
    byte[] aggregateINbuffer = null;

    // for byte array and single IRP, the OUT and IN buffers are the length specified by the tests
    aggregateOUTbuffer = new byte[OUTLength[0]];
    aggregateINbuffer = new byte[INLength[0]];

    printDebug(
        "RoundTripTestShortPacket -- IRP "
            + transmitListStrings[syncOrAsync]
            + " "
            + endpointTypeStrings[endpointType]);

    /*
     * Create the OUT and IN IRPs or byte arrrays
     */
    List transmitBuffers = new ArrayList();
    List listOfOUTIrps = new ArrayList();
    List listOfINIrps = new ArrayList();

    for (int k = 0; k < numIrps; k++) {
      // create transmit buffer for OUT and IN IRPs
      TransmitBuffer currentTransmitBuffer = new TransmitBuffer(transformType[k], OUTLength[k]);
      transmitBuffers.add(currentTransmitBuffer);

      // create OUT IRP
      UsbIrp currentOUTIrp = outPipe.createUsbIrp();
      listOfOUTIrps.add(currentOUTIrp);

      // set data in OUT IRP
      currentOUTIrp.setData(aggregateOUTbuffer, OUTOffset[k], OUTLength[k]);
      currentOUTIrp.setAcceptShortPacket(acceptShortPacket[k]);

      // OUT IRP is ready to go!

      if (endpointType == UsbConst.ENDPOINT_TYPE_ISOCHRONOUS) {
        /*
         * For isochronous transfers, all IN Irps will have an offset of zero and
         * the same buffer length.
         */
        // get the longest required buffer length for all of the IRPs. All of the IRPs in the list
        // have the same length buffer.
        int standardISOINBufferLength = INLength[0];
        for (int l = 1; l < numIrps; l++) {
          if (INLength[l] > standardISOINBufferLength) {
            standardISOINBufferLength = INLength[l];
          }
        }
        // now that the largest has been found, set the length for each in IRP to the new length
        for (int l = 0; l < numIrps; l++) {
          INLength[l] = standardISOINBufferLength;
        }
        int standardISOINBufferOffset = 0;

        // int numCopies = 1;//there will be numCopies * numIrps in the list of ISO In Irps
        int totalNumCopies = 40; // there will be numCopies * numIrps in the list of ISO In Irps
        for (int indexOfCurrentCopy = 0;
            indexOfCurrentCopy < totalNumCopies;
            indexOfCurrentCopy++) {
          // create IN IRP
          UsbIrp currentINIrp = inPipe.createUsbIrp();
          listOfINIrps.add(currentINIrp);
          byte[] currentINbuffer = new byte[standardISOINBufferLength];

          currentINIrp.setData(
              currentINbuffer, standardISOINBufferOffset, standardISOINBufferLength);
          currentINIrp.setAcceptShortPacket(acceptShortPacket[k]);
        }

      } else {
        // create IN IRP
        UsbIrp currentINIrp = inPipe.createUsbIrp();
        listOfINIrps.add(currentINIrp);
        /*
         * set data in IN IRP -- note that no data is copied to IN byte[] before setting data in IRP.
         * byte[] will be filled by IN operation.
         */
        currentINIrp.setData(aggregateINbuffer, INOffset[k], INLength[k]);
        currentINIrp.setAcceptShortPacket(acceptShortPacket[k]);
      }
    }

    // copy individual transmitbuffers into single OUT  buffer
    for (int k = 0; k < numIrps; k++) {
      TransmitBuffer currentTransmitBuffer = (TransmitBuffer) transmitBuffers.get(k);

      System.arraycopy(
          currentTransmitBuffer.getOutBuffer(), 0, aggregateOUTbuffer, OUTOffset[k], OUTLength[k]);
    }

    // ensure all events are clear before sending IRPs
    inPipeEvents.clear();
    outPipeEvents.clear();

    // send both the OUT and IN IRPs
    sendOUTandIN(testType, transmitList[syncOrAsync], inPipe, outPipe, listOfINIrps, listOfOUTIrps);

    printDebug("return from sendoutandin");
    if (endpointType == UsbConst.ENDPOINT_TYPE_ISOCHRONOUS) {
      clearOutTheINEventAndIrpListForISO(inPipeEvents, listOfINIrps);
    }

    // verify IRP data against expected values
    for (int k = 0; k < numIrps; k++) {
      UsbIrp submittedOUTIRP = (UsbIrp) listOfOUTIrps.get(k);

      // verify OUT IRP after successful transmit
      VerifyIrpMethods.verifyUsbIrpAfterEvent(
          submittedOUTIRP,
          (EventObject) outPipeEvents.get(k),
          ((TransmitBuffer) transmitBuffers.get(k)).getOutBuffer(),
          OUTExpectedLength[k],
          OUTexpectedException[k],
          acceptShortPacket[k],
          verifyAcceptShortPacket[k],
          OUTOffset[k],
          OUTLength[k]);

      UsbIrp submittedINIRP = (UsbIrp) listOfINIrps.get(k);
      byte[] expectedINBuffer = ((TransmitBuffer) transmitBuffers.get(k)).getInBuffer();

      // if exception is expected, do not verify the In buffer
      if (INexpectedException[k] != null) {
        expectedINBuffer = null;

        // if we got a USB exception as expected, then clear the endpoint
        if (submittedINIRP.isUsbException()) {

          try {

            StandardRequest.clearFeature(
                usbDevice,
                UsbConst.REQUESTTYPE_RECIPIENT_ENDPOINT,
                UsbConst.FEATURE_SELECTOR_ENDPOINT_HALT,
                inPipe.getUsbEndpoint().getUsbEndpointDescriptor().bEndpointAddress());

            printDebug("clear feature");
          } catch (Exception e) {
            Assert.fail("Exception clearing halt on enpoint after short packet exception.");
          }
        } else {
          printDebug("not clear feature");
        }
      }

      // verify IN IRP after successful submit
      VerifyIrpMethods.verifyUsbIrpAfterEvent(
          submittedINIRP,
          (EventObject) inPipeEvents.get(k),
          expectedINBuffer,
          INExpectedLength[k],
          INexpectedException[k],
          acceptShortPacket[k],
          verifyAcceptShortPacket[k],
          INOffset[k],
          INLength[k]);
    }

    IOMethods.closePipe(inPipe);
    IOMethods.closePipe(outPipe);

    inPipe.removeUsbPipeListener(inPipeListener);
    outPipe.removeUsbPipeListener(outPipeListener);
  };