Page 1 of 1

Any USB HID Examples?

Posted: Fri Oct 16, 2009 6:04 pm
by Lucifer
Does anyone have any working example code in PB that shows how to -
1. Search list of HID's and find a specific HID & PID
2. Connect to that HID & PID and transfer data and receive data

I have done a search and the best I've found is http://www.purebasic.fr/english/viewtop ... =5&t=37721.
This does provide a list of HID's but does not provide any write functions.
I have a strange feeling that these are not the right API calls.

I am playing around with some electronics (microcontroller PIC18F4550) and would like to try USB.
I can set the HID & PID to anything and I have not planned any data structure yet but know that I will need to read and write up to 256 bytes at any one time.
RS232 connection works ok but I want to move away from this and start using USB.
I want to use HID and not CDC.

Thanks.

Re: Any USB HID Examples?

Posted: Tue Oct 20, 2009 10:25 pm
by tinman
I know you want PB example code, but you'll be dealing with the Win32 API so much that you might be as well looking at C example code. You should be able to find some good stuff here: http://www.lvr.com/hidpage.htm

AFAIR the code at a previous company I worked for simply used the Setup API to enumerate the USB devices, looking for specific VID/PID combinations, opened a file at the device path and used ReadFile and WriteFile for reading and writing custom HID reports to/from devices. I wasn't working on that code so there's not much I can tell you about it directly.

Hope that helps.

Re: Any USB HID Examples?

Posted: Mon Oct 26, 2009 4:31 pm
by Lucifer
Thanks for your reply.
I've got some examples in VB and C and they appear to use a lot of API calls.

Re: Any USB HID Examples?

Posted: Mon Nov 02, 2009 3:57 pm
by User_Russian

Re: Any USB HID Examples?

Posted: Thu Nov 05, 2009 8:46 am
by Lucifer
Thanks.
That may be a good starting point for me.

Re: Any USB HID Examples?

Posted: Thu Nov 05, 2009 2:58 pm
by mpz
Hi,

If have written in the german forum a program to read and write HID informations. You need for the program the dll file from here:
http://www.docpro.com.br/arquivos/mcHID.zip

"Hid Reader"
http://forums.purebasic.com/german/view ... 3d42868751

and i have written a USB Interface for WIN with 4xIN/6xOUT/1xAD/1xIR and 1xTemp with a PIC18F2550, you can use the code for the 4550 too:
http://forums.purebasic.com/german/view ... 3d42868751

i hope you can use a german to english translater to understand the words...

best regards,
Michael
I

Re: Any USB HID Examples?

Posted: Sat Jan 09, 2010 11:21 pm
by Lucifer
Thanks for all the help.

MPZ's solutons was the easiest to implement and my PC18F4550 is working just fine.


Thanks again.