Problem getting data from a USB device

I use the following code to read data from my USB device. It works
apparently any problem on Windows XP and Windows 2003, both 32 and 64
bit. But on Win2k IoCallDriver() consistently fails with code C000000D
(STATUS_INVALID_PARAMETER).
Anyone is able to tell me what’s wrong?
Thanks a lot,

Loris



//
// Format the URB
//
UsbBuildInterruptOrBulkTransferRequest(myurb,
sizeof(_URB_BULK_OR_INTERRUPT_TRANSFER),
pdx->bulk_in,
mybuffer,
NULL,
MAX_PACKET_SIZE,
USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
NULL);

//
// Allocate the IRP
//
Irp = IoAllocateIrp(pdx->LowerDeviceObject->StackSize, FALSE);
if(!Irp)
{
KdPrint((DRIVERNAME “/” FUNCTION “: ERROR: unable to allocate IRP
for sending URB\n”));

return STATUS_INSUFFICIENT_RESOURCES;
}

//
// Init the stack location
//
PIO_STACK_LOCATION stack = IoGetNextIrpStackLocation(Irp);
stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
stack->Parameters.Others.Argument1 = (PVOID) myurb;
stack->Parameters.DeviceIoControl.IoControlCode =
IOCTL_INTERNAL_USB_SUBMIT_URB;

//
// Set the completion routine
//
IoSetCompletionRoutine(Irp, (PIO_COMPLETION_ROUTINE)
MyCompletionRoutine, (PVOID) context, TRUE, TRUE, TRUE);

//
// Send the IRP down to the bus driver
//
status = IoCallDriver(pdx->LowerDeviceObject, Irp);

On Tue, May 23, 2006 at 09:31:31PM -0700, Loris Degioanni wrote:

I use the following code to read data from my USB device. It works
apparently any problem on Windows XP and Windows 2003, both 32 and 64
bit. But on Win2k IoCallDriver() consistently fails with code C000000D
(STATUS_INVALID_PARAMETER).
Anyone is able to tell me what's wrong?
Thanks a lot,

Loris


//
// Format the URB
//
UsbBuildInterruptOrBulkTransferRequest(myurb,
sizeof(_URB_BULK_OR_INTERRUPT_TRANSFER),
pdx->bulk_in,
mybuffer,
NULL,
MAX_PACKET_SIZE,
USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
NULL);

How big is MAX_PACKET_SIZE?

xxxxx@probo.com wrote:

On Tue, May 23, 2006 at 09:31:31PM -0700, Loris Degioanni wrote:
> I use the following code to read data from my USB device. It works
> apparently any problem on Windows XP and Windows 2003, both 32 and 64
> bit. But on Win2k IoCallDriver() consistently fails with code C000000D
> (STATUS_INVALID_PARAMETER).
> Anyone is able to tell me what’s wrong?
> Thanks a lot,
>
> Loris
>
> ------------------------------------------------------------
>
> //
> // Format the URB
> //
> UsbBuildInterruptOrBulkTransferRequest(myurb,
> sizeof(_URB_BULK_OR_INTERRUPT_TRANSFER),
> pdx->bulk_in,
> mybuffer,
> NULL,
> MAX_PACKET_SIZE,
> USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
> NULL);

How big is MAX_PACKET_SIZE?

#define MAX_PACKET_SIZE 8000

Loris

What is the Max Packet size of the pdx->bulk_in pipe?

Just as a thought you might want to make your MAX_PACKET_SIZE less than that
number and see if it works.

Cheers,
-Randy

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Loris Degioanni
Sent: Tuesday, May 23, 2006 9:57 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Problem getting data from a USB device

xxxxx@probo.com wrote:

On Tue, May 23, 2006 at 09:31:31PM -0700, Loris Degioanni wrote:
> I use the following code to read data from my USB device. It works
> apparently any problem on Windows XP and Windows 2003, both 32 and 64
> bit. But on Win2k IoCallDriver() consistently fails with code C000000D
> (STATUS_INVALID_PARAMETER).
> Anyone is able to tell me what’s wrong?
> Thanks a lot,
>
> Loris
>
> ------------------------------------------------------------
>
> //
> // Format the URB
> //
> UsbBuildInterruptOrBulkTransferRequest(myurb,
> sizeof(_URB_BULK_OR_INTERRUPT_TRANSFER),
> pdx->bulk_in,
> mybuffer,
> NULL,
> MAX_PACKET_SIZE,
> USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
> NULL);

How big is MAX_PACKET_SIZE?

#define MAX_PACKET_SIZE 8000

Loris


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

On Tue, May 23, 2006 at 09:56:42PM -0700, Loris Degioanni wrote:

xxxxx@probo.com wrote:

> How big is MAX_PACKET_SIZE?

#define MAX_PACKET_SIZE 8000

Windows 2000 is more restrictive on the size of the URBs it is able
to chop up. Remember that your bulk endpoint packet size is much smaller
than that, so the host controller driver has to chop it up.

I don't remember the exact limit on Win2K. You might try 4096 or 2048
to see if you achieve good results.