Page 1 of 1
USB code examples
Posted: Tue May 11, 2010 3:29 am
by Avatar Engineer
I'm new to PureBasic and would like to see example code for implementing USB communications
in a Windows OS. Hopefully, there are some easy methods that work well for both WinXP & Win7
in both 32 & 64 bit. My application would be for connecting remote laboratory instruments.
Re: USB code examples
Posted: Tue May 11, 2010 3:38 pm
by Rook Zimbabwe
Well the COMmate library may be of help there... I know you can probably do it with the API as well...
http://www2.hawaii.edu/~hermany/api.htm
http://www.usb.org/developers/hidpage/microhid/
http://virtual.software.informer.com/do ... r-usb-dll/
And the last one got me thinking... many devices designed for UB come with their own drivers... Why not just communicate with those drivers?

Re: USB code examples
Posted: Tue May 11, 2010 4:52 pm
by kvitaliy
Library HID_Lib is intended for work with USB HID devices. If only be not afraid of Russian.
http://pure-basic.narod.ru/libs/HID_Lib ... --4.50.rar
Re: USB code examples
Posted: Tue May 11, 2010 4:56 pm
by Avatar Engineer
Thanks for links !
While most consumer devices may come with host drivers, I'll be connecting
to my own target hardware... The embedded controller code for USB is difficult enough
and the most expedient method is to use RS232 from the target and use a USB
converter cable to the host PC... but I'd like to "Roll my own" this time.
AE
Re: USB code examples
Posted: Tue May 11, 2010 7:30 pm
by Rook Zimbabwe
What I did when writing the drivers for my Customer Display was sourceforge and hack a USB to COM driver and open the USB Gadget as a COM3 then write to COM3 (I could read from it as well...)
Re: USB code examples
Posted: Wed May 12, 2010 8:17 pm
by Avatar Engineer
Sounds good!
can you post the code?
Re: USB code examples
Posted: Wed May 12, 2010 10:03 pm
by Rook Zimbabwe
I went to sourcefoge and grabbed these:
http://sourceforge.net/projects/libusb-win32/
http://sourceforge.net/projects/libusb/
A lot of what I did I learned from attempting to use this:
http://sourceforge.net/projects/libusbdotnet/
http://sourceforge.net/projects/npipe/
Code is being used... but you can freely use the sourceforge stuff. Easier in the long run. Just be sure to check license before distributing!
Re: USB code examples
Posted: Wed May 12, 2010 10:57 pm
by Avatar Engineer
Thanks again,... looks like I've got homework!