USB code examples

Just starting out? Need help? Post your questions and find answers here.
User avatar
Avatar Engineer
New User
New User
Posts: 5
Joined: Tue May 11, 2010 3:18 am
Location: Scottsdale, Arizona
Contact:

USB code examples

Post 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.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: USB code examples

Post 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? :)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
kvitaliy
Enthusiast
Enthusiast
Posts: 162
Joined: Mon May 10, 2010 4:02 pm

Re: USB code examples

Post 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
User avatar
Avatar Engineer
New User
New User
Posts: 5
Joined: Tue May 11, 2010 3:18 am
Location: Scottsdale, Arizona
Contact:

Re: USB code examples

Post 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
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: USB code examples

Post 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...)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Avatar Engineer
New User
New User
Posts: 5
Joined: Tue May 11, 2010 3:18 am
Location: Scottsdale, Arizona
Contact:

Re: USB code examples

Post by Avatar Engineer »

Sounds good!

can you post the code?
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: USB code examples

Post 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!
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Avatar Engineer
New User
New User
Posts: 5
Joined: Tue May 11, 2010 3:18 am
Location: Scottsdale, Arizona
Contact:

Re: USB code examples

Post by Avatar Engineer »

Thanks again,... looks like I've got homework!
Post Reply