USB driver

Hi,
I need to write a driver for a HID device. It is not keyboard or mouse.
Actually I can access device using hid.dll.
To send and recieve data I use WriteFile and ReadFile, code I use is this:
*write:*
Result = WriteFile(DeviceHandle,OutputReport,
Capabilities.OutputReportByteLength,&BytesWritten,NULL);
*read:*
Result = ReadFile(ReadHandle,InputReport,Capabilities.InputReportByteLength,&NumberOfBytesRead,(LPOVERLAPPED)
&HIDOverlapped);
Result = WaitForSingleObject(hEventObject2,6000);
OutputReport and Inputreport are defined like this: BYTE
OutputReport[BUFFERSIZE]; BYTE InputReport[BUFFERSIZE];
In this arrays I send data, not taking care about report structure. Because
device don?t use report structures.

I’m reading DDK samples, but I don?t know which is more convinient to beggin
my driver.
FireFly looks complicated.

where I can find less complicated samples?

thanks,
Ro.

Not all HID devices are keyboards and mice. Does your device report itself as a HID device already and hidusb loads? It sounds like the answer is yes. If so, you don’t need to write a driver, you just need to use the Hid.dll APIs. Or is your device a non standard HID where you need to write your own miniport?

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Roman Gonzales
Sent: Saturday, September 15, 2007 8:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB driver

Hi,
I need to write a driver for a HID device. It is not keyboard or mouse.
Actually I can access device using hid.dll.
To send and recieve data I use WriteFile and ReadFile, code I use is this:
write:
Result = WriteFile(DeviceHandle,OutputReport,Capabilities.OutputReportByteLength,&BytesWritten,NULL);
read:
Result = ReadFile(ReadHandle,InputReport,Capabilities.InputReportByteLength,&NumberOfBytesRead,(LPOVERLAPPED) &HIDOverlapped);
Result = WaitForSingleObject(hEventObject2,6000);
OutputReport and Inputreport are defined like this: BYTE OutputReport[BUFFERSIZE]; BYTE InputReport[BUFFERSIZE];
In this arrays I send data, not taking care about report structure. Because device don?t use report structures.

I’m reading DDK samples, but I don?t know which is more convinient to beggin my driver.
FireFly looks complicated.

where I can find less complicated samples?

thanks,
Ro.

— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hi Doron,
Thank you for your answer.
My device report itself as a HID. It is a low-speed device, bandwidth 8
bytes-msec-I/O report. The HID.dll makes one transaction per 10
milliseconds.
I need to reduce this times, I think if I make my own driver I can reduce
this times.

2007/9/15, Doron Holan :
>
> Not all HID devices are keyboards and mice. Does your device report
> itself as a HID device already and hidusb loads? It sounds like the answer
> is yes. If so, you don’t need to write a driver, you just need to use the
> Hid.dll APIs. Or is your device a non standard HID where you need to
> write your own miniport?
>
>
>
> d
>
>
>
> From: xxxxx@lists.osr.com [mailto:
> xxxxx@lists.osr.com] *On Behalf Of *Roman Gonzales
> Sent: Saturday, September 15, 2007 8:00 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] USB driver
>
>
>
> Hi,
>
> I need to write a driver for a HID device. It is not keyboard or mouse.
>
> Actually I can access device using hid.dll.
>
> To send and recieve data I use WriteFile and ReadFile, code I use is this:
>
>
> write:
>
> Result = WriteFile(DeviceHandle,OutputReport,
> Capabilities.OutputReportByteLength,&BytesWritten,NULL);
>
> read:
>
> Result = ReadFile(ReadHandle,InputReport,
> Capabilities.InputReportByteLength,&NumberOfBytesRead,(LPOVERLAPPED)
> &HIDOverlapped);
> Result = WaitForSingleObject(hEventObject2,6000);
> OutputReport and Inputreport are defined like this: BYTE
> OutputReport[BUFFERSIZE]; BYTE InputReport[BUFFERSIZE];
>
> In this arrays I send data, not taking care about report structure.
> Because device don?t use report structures.
>
>
>
> I’m reading DDK samples, but I don?t know which is more convinient to
> beggin my driver.
>
> FireFly looks complicated.
>
>
>
> where I can find less complicated samples?
>
>
>
> thanks,
>
> Ro.
>
>
>
>
>
> — NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and
> other seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Roman Gonzales wrote:

Hi Doron,
Thank you for your answer.
My device report itself as a HID. It is a low-speed device, bandwidth
8 bytes-msec-I/O report. The HID.dll makes one transaction per 10
milliseconds.
I need to reduce this times, I think if I make my own driver I can
reduce this times.

It looks like you are already using overlapped I/O. If so, just make
sure you submit multiple read requests. Your problem may be that, by
the time the host controller gets the request and returns it to you,
then you do your processing and resubmit the request back to USB, you
have missed several frames.

It’s quite likely that there’s nothing you could do in your driver that
the HID driver isn’t already doing. The problem is in the way you’re
calling the driver.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

I don’t think this is a driver issue since I think that the polling rate for the hw is the limiting factor in the end, but I don’t think you are hitting that limitation yet. Rather I think you current problems is how you are sending i/o. are you sending one i/o and then waiting for it to complete? If so, try opening the handle as OVERLAPPED and sending multiple I/Os that way they will complete when the data arrives vs potentially being queued by hidclass and waiting for your i/o to arrive.

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Roman Gonzales
Sent: Monday, September 17, 2007 5:31 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] USB driver

Hi Doron,
Thank you for your answer.
My device report itself as a HID. It is a low-speed device, bandwidth 8 bytes-msec-I/O report. The HID.dll makes one transaction per 10 milliseconds.
I need to reduce this times, I think if I make my own driver I can reduce this times.

2007/9/15, Doron Holan >:

Not all HID devices are keyboards and mice. Does your device report itself as a HID device already and hidusb loads? It sounds like the answer is yes. If so, you don’t need to write a driver, you just need to use the Hid.dll APIs. Or is your device a non standard HID where you need to write your own miniport?

d

From: xxxxx@lists.osr.commailto:xxxxx [mailto: xxxxx@lists.osr.commailto:xxxxx] On Behalf Of Roman Gonzales
Sent: Saturday, September 15, 2007 8:00 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB driver

Hi,

I need to write a driver for a HID device. It is not keyboard or mouse.

Actually I can access device using hid.dll.

To send and recieve data I use WriteFile and ReadFile, code I use is this:

write:

Result = WriteFile(DeviceHandle,OutputReport,Capabilities.OutputReportByteLength,&BytesWritten,NULL);

read:

Result = ReadFile(ReadHandle,InputReport,Capabilities.InputReportByteLength,&NumberOfBytesRead,(LPOVERLAPPED) &HIDOverlapped);
Result = WaitForSingleObject(hEventObject2,6000);
OutputReport and Inputreport are defined like this: BYTE OutputReport[BUFFERSIZE]; BYTE InputReport[BUFFERSIZE];

In this arrays I send data, not taking care about report structure. Because device don?t use report structures.

I’m reading DDK samples, but I don?t know which is more convinient to beggin my driver.

FireFly looks complicated.

where I can find less complicated samples?

thanks,

Ro.

— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

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

— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

> My device report itself as a HID. It is a low-speed device, bandwidth 8

bytes-msec-I/O report. The HID.dll makes one transaction per 10 milliseconds.
I need to reduce this times, I think if I make my own driver I can reduce this times.

This is a device limitation. The framerate is 10 ms for low-speed devices.
If your device hardware supports it, you can change the firmware to full-speed, and then obtain 1 ms.
See USB specs on www.usb.org for further information about low-speed, full-speed and high-speed devices.

Leo Havmøller.

Thank you all for your answers. This helps me a lot!
where can I find information about overlapped I/O?

2007/9/17, Tim Roberts :
>
> Roman Gonzales wrote:
> > Hi Doron,
> > Thank you for your answer.
> > My device report itself as a HID. It is a low-speed device, bandwidth
> > 8 bytes-msec-I/O report. The HID.dll makes one transaction per 10
> > milliseconds.
> > I need to reduce this times, I think if I make my own driver I can
> > reduce this times.
>
> It looks like you are already using overlapped I/O. If so, just make
> sure you submit multiple read requests. Your problem may be that, by
> the time the host controller gets the request and returns it to you,
> then you do your processing and resubmit the request back to USB, you
> have missed several frames.
>
> It’s quite likely that there’s nothing you could do in your driver that
> the HID driver isn’t already doing. The problem is in the way you’re
> calling the driver.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Roman Gonzales wrote:

Thank you all for your answers. This helps me a lot!
where can I find information about overlapped I/O?

It looked like your snippet of code was already using overlapped I/O.
It is described in the SDK documentation, under APIs like CreateFile and
ReadFile. If you specify FILE_FLAG_OVERLAPPED to CreateFile, then you
are using it.

The principle is that you submit request like ReadFile, but your thread
continues to run while the read happens. You use GetOverlappedResult to
check for the actual completion (or use an I/O completion port).
Because your thread continues to run, you can submit more ReadFile
requests, so requests are waiting to run even while you are processing
the last one.

There are lots of good web resources on this. Google for “overlapped io
example”.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thank you.
Regards,
Roman.

2007/9/18, Tim Roberts :
>
> Roman Gonzales wrote:
> > Thank you all for your answers. This helps me a lot!
> > where can I find information about overlapped I/O?
>
> It looked like your snippet of code was already using overlapped I/O.
> It is described in the SDK documentation, under APIs like CreateFile and
> ReadFile. If you specify FILE_FLAG_OVERLAPPED to CreateFile, then you
> are using it.
>
> The principle is that you submit request like ReadFile, but your thread
> continues to run while the read happens. You use GetOverlappedResult to
> check for the actual completion (or use an I/O completion port).
> Because your thread continues to run, you can submit more ReadFile
> requests, so requests are waiting to run even while you are processing
> the last one.
>
> There are lots of good web resources on this. Google for “overlapped io
> example”.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>