LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 06-13-2007, 09:14 PM   #1
go939
LQ Newbie
 
Registered: Jun 2007
Posts: 15

Rep: Reputation: 0
how to control a device through USB, using C++


hey guys! can somebody gv me ideas or hints on how to control any device through USB, using the C++ language? thanks!
 
Old 06-14-2007, 05:46 PM   #2
wilsonsamm
Member
 
Registered: Aug 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 105

Rep: Reputation: 15
Umm, don't take me for a Linux God or anything, but I have some thoghts on the issue I'm just sharing since no-one else is replying

but wouldn't you rather communicate with your device through your driver or kernel or whatever? this will be safer and ensure more portability of your program. But I'm sure you know all that anyway.

On home computers in the early eighties you'd solder up a piece of hardware, plug it in, and then write a program to use it, in the computer's built in language. But this isn't something people do these days.

Anyway, what are you looking to communicate with?
If you want to send a string to a port, then use something like

echo "we like sheep" > /dev/ttyS0

I have a teletype on ttyS0, so I get this text appear on there.
 
Old 06-14-2007, 06:03 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by go939
hey guys! can somebody gv me ideas or hints on how to control any device through USB, using the C++ language? thanks!
Do you have the interface definition for the device?
 
Old 06-14-2007, 07:46 PM   #4
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
Without getting into writing your own kernel drivers, there are a couple things you can use. For user-level access to usb functions have a look at libusb. There is an LQ article here:

http://www.linuxquestions.org/linux/...ing_Libusb_API

(read the comments also). For the USB human interface device protocol there is also libhid:

http://libhid.alioth.debian.org/

Both these will let you interact with USB devices with C++ code.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
USB drive not working properly, read only device? (USB key storage device) Arodef Linux - Hardware 14 01-01-2010 07:32 AM
How to force kernel to use a USB 2.0-compatible device (ehci_hcd) as a USB 1.1 device eze Linux - Hardware 0 05-16-2006 05:24 AM
Network Device Control (Gnome 2.8) McLaren2 Linux - Networking 1 11-17-2004 03:31 AM
HP Deskjet (USB) & CUPS & Slackware 9.1: Unable to open USB device "usb:/dev/usb/lp0&qu arnostienen Slackware 2 01-29-2004 03:22 PM
No 'Network Device Control'? WHY! HelloDoogle Linux - Newbie 2 12-17-2003 03:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 07:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration