Any USB HID Examples?

Everything else that doesn't fall into one of the other PB categories.
Lucifer
User
User
Posts: 26
Joined: Wed Apr 30, 2003 6:11 pm
Location: UK

Any USB HID Examples?

Post 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.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Re: Any USB HID Examples?

Post 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.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Lucifer
User
User
Posts: 26
Joined: Wed Apr 30, 2003 6:11 pm
Location: UK

Re: Any USB HID Examples?

Post 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.
User_Russian
Addict
Addict
Posts: 1519
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Any USB HID Examples?

Post by User_Russian »

Last edited by User_Russian on Mon Apr 05, 2010 2:10 pm, edited 2 times in total.
Lucifer
User
User
Posts: 26
Joined: Wed Apr 30, 2003 6:11 pm
Location: UK

Re: Any USB HID Examples?

Post by Lucifer »

Thanks.
That may be a good starting point for me.
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: Any USB HID Examples?

Post 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
Working on - MP3D Library - PB 5.73 version ready for download
Lucifer
User
User
Posts: 26
Joined: Wed Apr 30, 2003 6:11 pm
Location: UK

Re: Any USB HID Examples?

Post by Lucifer »

Thanks for all the help.

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


Thanks again.
Post Reply