Newbie USB: How To Implement A Proper INT Pipe Xfer

Hello everyone,

Sorry for the newbie question but I need to implement
a way to listen to interrupt (IN) transfers on a USB
device on Win98.

I’ve appropriately managed to obtain a handle to the
Interrupt Pipe on my default configuration.

3 Questions:
a. What sort of method should I use to listen on this
Interrupt pipe? Does anyone have any template code I
could look through? The DDK only has examples on
handling Isochronous and Bulk transfers unfortunately.

b. I also noticed that call to KeWaitForSingleObject
(time:0) effectively hangs Win98 (from a user mode
DevIoCtrl call to my driver) when I tried to listen in
the Interrupt pipe doesn’t help. Setting up a
CompletionRoutine either doesn’t help (code below).

I would appreciate it very much if someone could point
me the way.

Thanks in advance.

  • Edward
    Addvalue Technologies

{

// Build Do Bulk or Interrupt transfer request
UsbBuildInterruptOrBulkTransferRequest(
urb, UrbSize, dx->hIntPipe, dx->intdata,
NULL, 5, USBD_TRANSFER_DIRECTION_IN |
USBD_SHORT_TRANSFER_OK, NULL);

status=SendUSB( dx, urb, IOCTL_INTERNAL_USB_SUBMIT_URB
);


}

NTSTATUS SendUsb (PDEVICE_EXTENSION dx,
PVOID UrbEtc,ULONG IoControlCode)
{
IO_STATUS_BLOCK IoStatus;
KEVENT event;
PIRP Irp;
PIO_STACK_LOCATION NextIrpStack;
NTSTATUS status;

KeInitializeEvent (&event, NotificationEvent, FALSE);

Irp = IoBuildDeviceIoControlRequest (
IoControlCode, dx->LowerDevObj,
NULL, 0, NULL, 0, TRUE, &event, &IoStatus);

NextIrpStack = IoGetNextIrpStackLocation (Irp);

NextIrpStack->MajorFunction =
IRP_MJ_INTERNAL_DEVICE_CONTROL;
NextIrpStack->Parameters.Others.Argument1 = UrbEtc;
NextIrpStack->Parameters.Others.Argument2 = (PVOID)0;

status = IoCallDriver (dx->LowerDevObj, Irp);
if (status == STATUS_PENDING) {
status = KeWaitForSingleObject (
&event, Executive, KernelMode, FALSE, NULL);
}
return status;
}


Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine’s Day
http://shopping.yahoo.com

To “listen” to an interrupt IN pipe, pass a URB down and set a completion
routine. When the completion routine fires your interrupt has arrived.

  • Dennis

Dennis Merrill
Embedded Systems Engineer
Thermo?Electron Corporation

-----Original Message-----
From: J MI [mailto:xxxxx@yahoo.com]
Sent: Friday, February 14, 2003 4:01 AM
To: NT Developers Interest List
Subject: [ntdev] Newbie USB: How To Implement A Proper INT Pipe Xfer

Hello everyone,

Sorry for the newbie question but I need to implement
a way to listen to interrupt (IN) transfers on a USB
device on Win98.

I’ve appropriately managed to obtain a handle to the
Interrupt Pipe on my default configuration.

3 Questions:
a. What sort of method should I use to listen on this
Interrupt pipe? Does anyone have any template code I
could look through? The DDK only has examples on
handling Isochronous and Bulk transfers unfortunately.

b. I also noticed that call to KeWaitForSingleObject
(time:0) effectively hangs Win98 (from a user mode
DevIoCtrl call to my driver) when I tried to listen in
the Interrupt pipe doesn’t help. Setting up a
CompletionRoutine either doesn’t help (code below).

I would appreciate it very much if someone could point
me the way.

Thanks in advance.

  • Edward
    Addvalue Technologies

{

// Build Do Bulk or Interrupt transfer request
UsbBuildInterruptOrBulkTransferRequest(
urb, UrbSize, dx->hIntPipe, dx->intdata,
NULL, 5, USBD_TRANSFER_DIRECTION_IN |
USBD_SHORT_TRANSFER_OK, NULL);

status=SendUSB( dx, urb, IOCTL_INTERNAL_USB_SUBMIT_URB
);


}

NTSTATUS SendUsb (PDEVICE_EXTENSION dx,
PVOID UrbEtc,ULONG IoControlCode)
{
IO_STATUS_BLOCK IoStatus;
KEVENT event;
PIRP Irp;
PIO_STACK_LOCATION NextIrpStack;
NTSTATUS status;

KeInitializeEvent (&event, NotificationEvent, FALSE);

Irp = IoBuildDeviceIoControlRequest (
IoControlCode, dx->LowerDevObj,
NULL, 0, NULL, 0, TRUE, &event, &IoStatus);

NextIrpStack = IoGetNextIrpStackLocation (Irp);

NextIrpStack->MajorFunction =
IRP_MJ_INTERNAL_DEVICE_CONTROL;
NextIrpStack->Parameters.Others.Argument1 = UrbEtc;
NextIrpStack->Parameters.Others.Argument2 = (PVOID)0;

status = IoCallDriver (dx->LowerDevObj, Irp);
if (status == STATUS_PENDING) {
status = KeWaitForSingleObject (
&event, Executive, KernelMode, FALSE, NULL);
}
return status;
}


Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine’s Day
http://shopping.yahoo.com


You are currently subscribed to ntdev as: xxxxx@thermo.com
To unsubscribe send a blank email to xxxxx@lists.osr.com