LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-11-2008, 09:56 AM   #1
anroy
LQ Newbie
 
Registered: Aug 2006
Location: Tokyo
Distribution: Gentoo, Xandros
Posts: 18

Rep: Reputation: 0
Arrow USB programming


Hi

I have a project coming up where I will be writing a custom application in Gentoo.

It's a control application, controlling an external machine. We will have to send commands to the machine, and also receive status and measurement information from it. This machine is connected via USB. Hence, the application will have to access the USB port, both in terms of receiving and sending data to it.

I am an application programmer, and have extensive experience in C/C++. Most of my experience is in Windows, however I have done a little bit of C++ development work in Linux.

However I have to admit I am completely out to lunch on the low-level stuff, in this case accessing the USB port. (I've never done any low-level work in Windows either).

This wouldn't be driver development, since Gentoo already has the USB driver software. So I guess it would be a layer that interfaces with the driver?

My question is, can anyone point me in the direction of any resources to get started? Does anyone know of any good books or websites? I'm also open to the idea of looking for help in doing this.

Thanks.
 
Old 12-11-2008, 01:34 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Frankly, you probably don't have to do much of anything besides:

a) Figure out the right device interface (e.g. "/dev/ttyUSB")
b) Read and write to it (just as you'd do I/O with any normal file)

However - if you want some Deep Background - this looks like a good tutorial:

http://www.usb-programming.com/introduction.html

'Hope that helps .. PSM
 
Old 12-11-2008, 08:57 PM   #3
anroy
LQ Newbie
 
Registered: Aug 2006
Location: Tokyo
Distribution: Gentoo, Xandros
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by paulsm4 View Post
Frankly, you probably don't have to do much of anything besides:

a) Figure out the right device interface (e.g. "/dev/ttyUSB")
b) Read and write to it (just as you'd do I/O with any normal file)

However - if you want some Deep Background - this looks like a good tutorial:

http://www.usb-programming.com/introduction.html

'Hope that helps .. PSM
Wow, I wonder if that's all there is to it... I'll give that a try and report back here. Won't be for a while though.

There are other complications to this project. For one thing it requires almost real-time performance. (The "almost" means there is an allowable time slice of delay).

The Gentoo is actually a Gentoo/RTAI real-time OS. I have no idea what exactly the functional difference between a real-time OS and a regular OS is, will need to bone up on this as well.

There is also the fact that this is a very minimally-compiled Gentoo, such that automatic USB polling is turned off. So we won't know which of the USB ports in the PC the cable was plugged into. However it is acceptable to the client to have the operator enter some command specifying this at start time. But I'll still need to learn about how the different USB ports on the machine are accessed and referenced.

Thanks for the reply and the link, paulsm4.

Last edited by anroy; 12-11-2008 at 08:58 PM.
 
Old 12-13-2008, 01:48 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 13,623

Rep: Reputation: 2528Reputation: 2528Reputation: 2528Reputation: 2528Reputation: 2528Reputation: 2528Reputation: 2528Reputation: 2528Reputation: 2528Reputation: 2528Reputation: 2528
Example application, controller, using libusb

http://www.velleman.be/ot/en/product/view/?id=351346
http://libk8055.sourceforge.net/

http://www.linuxquestions.org/questi...ghlight=libusb
....
 
Old 12-14-2008, 01:24 AM   #5
anroy
LQ Newbie
 
Registered: Aug 2006
Location: Tokyo
Distribution: Gentoo, Xandros
Posts: 18

Original Poster
Rep: Reputation: 0
Thanks, will check this out.

I guess libusb is the API in Linux for USB functionality?

Speaking of which (and sorry if this is off-topic) does the central API in Linux have a proper name? For example, the way it's called Win32 in Windows. Proper names always help when searching.
 
  


Reply

Tags
usb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 device programming in Linux, how to R/W to USB DB-9 connector bapigoo9 Programming 7 08-28-2008 09:57 AM
usb touchscreen programming pradeepps Linux - Software 1 07-30-2008 07:46 AM
USB programming on a MAC chutsu Programming 1 03-29-2005 09:04 AM
USB programming The_Nerd Linux - Software 2 02-03-2005 11:05 AM
need some usb driver programming help glo Programming 3 10-27-2003 09:41 AM


All times are GMT -5. The time now is 09:17 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration