Skip navigation.
Home
The QNX Community Portal

View topic - USB driver programing

USB driver programing

General Help about QNX

USB driver programing

Postby bai12345633 » Tue May 21, 2013 12:05 pm

hi,I am a starter of QNX,i want to develop a USB camera driver.but i don't have a USB DDK,it seems like i should pay for the ddk.

so i can just use the IDE's help doc,and i had a problem when i use it:


A class driver typically performs the following operations:

1.Connect to the USB stack (usbd_connect()) and provide two callbacks: one for insertion and one for removal.
2.In the insertion callback:
1.Connect to the USB device (usbd_attach()).
2.Get descriptors (usbd_descriptor()).
3.Select the configuration (usbd_select_config()) and interface (usbd_select_interface()).
4.Set up communications pipes to the appropriate endpoint (usbd_open_pipe()).
3.In the removal callback, detach from the USB device (usbd_detach()).
4.Set up all data communications (e.g. reading and writing data, sending and receiving control information, etc.) via the usbd_setup_* () functions (usbd_setup_bulk(), usbd_setup_interrupt(), etc.).
5.Initiate data transfer using the usbd_io() function (with completion callbacks if required).

that are the steps the help doc provide to create a class driver,and my questiom is that how the functions in step3,4,5 to use the variable created in the insertion callback?for example,a struct usbd_device *device is created in usbd_attach(),how the usbd_detach() use the *device,i mean that the insertion callback and the removal callback do not have any parameter passing or the *device is a global variable? please give me some advices,thanks.

White
bai12345633
New Member
 
Posts: 3
Joined: Tue May 21, 2013 11:21 am

Re: USB driver programing

Postby Tim » Tue May 21, 2013 4:58 pm

White,

The first thing you need to do is make sure your camera isn't showing up as a HID device. You can find that out by issuing usb commands from the shell prompt and seeing what's connected. If the camera is operating as a HID device you'll need to tell devi-hid not to attach to it since you want to control it yourself. Hopefully that's not the case but it's worth mentioning before you start your driver because I have seen devi-hid grab my usb devices before my driver can.

Attached is some sample code from the DDK for a mouse driver. It's old sample code now but it will give you an idea of how the basic calls work which is what you are asking about.

Tim
Attachments
mouse.rar
(5.96 KiB) Downloaded 275 times
Tim
Senior Member
 
Posts: 1388
Joined: Wed Mar 10, 2004 12:28 am

Re: USB driver programing

Postby maschoen » Tue May 21, 2013 5:21 pm

bai12345633 wrote:hi,I am a starter of QNX,i want to develop a USB camera driver.but i don't have a USB DDK,it seems like i should pay for the ddk.


What version of QNX are you using? Earlier versions required paying for the DDK separately. I'm fairly sure that 6.5 comes with the ddk.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: USB driver programing

Postby bai12345633 » Wed May 22, 2013 1:30 am

maschoen wrote:
bai12345633 wrote:hi,I am a starter of QNX,i want to develop a USB camera driver.but i don't have a USB DDK,it seems like i should pay for the ddk.


What version of QNX are you using? Earlier versions required paying for the DDK separately. I'm fairly sure that 6.5 comes with the ddk.

thanks for your reply,i think my QNX's version is 6.5,and this is the output of "uname -a":QNX localhost 6.5.0 2012/06/20-13:50:50EDT x86pc x86
But,i can not find a directory about ddk,and i can not find a driver example either.i doubt the reason is that the QNX i use is the one installed in a vmware,or any other reasons?
My QNX SDP's version is 6.5 too,installed in windows.And i can not find any information or sourcecode about the ddk in the directory where i installed.please give me some more help,thanks very much!
bai12345633
New Member
 
Posts: 3
Joined: Tue May 21, 2013 11:21 am

Re: USB driver programing

Postby bai12345633 » Wed May 22, 2013 1:53 am

Tim wrote:
The first thing you need to do is make sure your camera isn't showing up as a HID device.can.

hi,Tim
thanks for your advice,i use the command "usb -vvv" and find that the camera is not a HID device,lucky.

Attached is some sample code from the DDK for a mouse driver. It's old sample code now but it will give you an idea of how the basic calls work which is what you are asking about.

would you please give some advices about how to get the sample code of a USB device,because i don't even have an old sample.what i have is just few steps in the IDE's help doc,and i think it is a little hard to understand.thanks a lot!
bai12345633
New Member
 
Posts: 3
Joined: Tue May 21, 2013 11:21 am

Re: USB driver programing

Postby maschoen » Wed May 22, 2013 6:47 pm

Look closely at all the posts in this topic. He uploaded the mouse driver source, which you can download.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 2 guests