LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 10-19-2011, 06:10 AM   #1
schliz
LQ Newbie
 
Registered: May 2011
Posts: 8

Rep: Reputation: Disabled
Enumerate USB devices C / C++ embedded Linux


I need to enumerate my USB devices on my Angstrom embedded Linux device in C / C++.
I use codesourcery Sourcery_G++_Lite 2009q3.

For Ubuntu Desktop I found:
#include <libudev.h>
libudev-dev

but how to use that for the embedded device.

Thank you very much in advance.

Georg
 
Old 10-19-2011, 06:56 AM   #2
sunnydrake
Member
 
Registered: Jul 2009
Location: Kiev,Ukraine
Distribution: Ubuntu,Slax,RedHat
Posts: 289
Blog Entries: 1

Rep: Reputation: 61
ls /dev/bus/usb/ ? or grab source of lsusb and look
 
Old 10-19-2011, 07:46 AM   #3
schliz
LQ Newbie
 
Registered: May 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
ls reports:

ls /dev/bus/usb
001 002

how can I use that?

Thank's again.
Georg
 
Old 10-20-2011, 01:36 AM   #4
schliz
LQ Newbie
 
Registered: May 2011
Posts: 8

Original Poster
Rep: Reputation: Disabled
Recommendations

I was now able to run the following program using libusb on my Angstrom board:
http://www.dreamincode.net/forums/to...ing-libusb-10/
http://libusb.sourceforge.net/api-1.0/index.html

I get now get the USB class code, but how can I now determine sdXY?

Thank you in advance.

Georg

Last edited by schliz; 10-20-2011 at 02:00 AM.
 
Old 10-20-2011, 06:15 AM   #5
sunnydrake
Member
 
Registered: Jul 2009
Location: Kiev,Ukraine
Distribution: Ubuntu,Slax,RedHat
Posts: 289
Blog Entries: 1

Rep: Reputation: 61
/dev/bus/usb/ give access to usb bus! Device detection and /dev/sdXX creation made by kernel and/or udev.
so you need to decide:you need to work with raw data on usb bus like sending enumerate signals etc.. or just list detected by kernel/udev and created devices in system = this is different levels with different api.
lsusb is tool, it's enumerate and print usb devices info. look code at http://www.koders.com/c/fidCE88EE326...EA27E46BD.aspx
list devices part
Quote:
static int list_devices(int busnum, int devnum, int vendorid, int productid)
{
struct usb_bus *bus;
struct usb_device *dev;
char vendor[128], product[128];
int status;

status=1; /* 1 device not found, 0 device found */
for (bus = usb_busses; bus; bus = bus->next) {
 
Old 10-20-2011, 06:27 AM   #6
sunnydrake
Member
 
Registered: Jul 2009
Location: Kiev,Ukraine
Distribution: Ubuntu,Slax,RedHat
Posts: 289
Blog Entries: 1

Rep: Reputation: 61
about mknod /dev/sdXX here some info when i insert flash drive
Quote:
sunnydrake@main:~$ udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[6489.821719] add /devices/pci0000:00/0000:00:02.1/usb1/1-3 (usb)
KERNEL[6489.823127] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0 (usb)
KERNEL[6489.826142] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7 (scsi)
KERNEL[6489.826205] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/scsi_host/host7 (scsi_host)
UDEV [6489.832780] add /devices/pci0000:00/0000:00:02.1/usb1/1-3 (usb)
UDEV [6489.836369] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0 (usb)
UDEV [6489.839974] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7 (scsi)
UDEV [6489.842296] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/scsi_host/host7 (scsi_host)
KERNEL[6490.864441] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0 (scsi)
KERNEL[6490.864505] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0 (scsi)
KERNEL[6490.864535] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/scsi_disk/7:0:0:0 (scsi_disk)
KERNEL[6490.864563] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/scsi_device/7:0:0:0 (scsi_device)
KERNEL[6490.868426] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/scsi_generic/sg2 (scsi_generic)
UDEV [6490.868485] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0 (scsi)
KERNEL[6490.868520] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/bsg/7:0:0:0 (bsg)
UDEV [6490.868549] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0 (scsi)
UDEV [6490.870417] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/scsi_device/7:0:0:0 (scsi_device)
KERNEL[6490.871136] add /devices/virtual/bdi/8:32 (bdi)
UDEV [6490.874909] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/bsg/7:0:0:0 (bsg)
UDEV [6490.876379] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/scsi_disk/7:0:0:0 (scsi_disk)
UDEV [6490.878567] add /devices/virtual/bdi/8:32 (bdi)
UDEV [6490.880498] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/scsi_generic/sg2 (scsi_generic)
KERNEL[6490.953707] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/block/sdc (block)
KERNEL[6490.953769] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/block/sdc/sdc1 (block)
UDEV [6491.141430] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/block/sdc (block)
UDEV [6491.253973] add /devices/pci0000:00/0000:00:02.1/usb1/1-3/1-3:1.0/host7/target7:0:0/7:0:0:0/block/sdc/sdc1 (block)
 
  


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
Anyone else getting tired of Linux embedded devices not being compatible with... darkstarbyte Linux - General 3 12-04-2010 09:48 PM
Embedded USB hub NOT detecting any usb devices zaks_974 Linux - Embedded & Single-board computer 2 09-16-2010 12:47 AM
Using two identical USB devices on an Embedded ARM running debian JeffLangille83 Debian 6 08-13-2008 05:25 PM
Linux Performance on embedded devices Thread7 Linux - General 3 01-28-2007 10:41 PM
Linux embedded on all devices, to shunt ms off there pedastool matthewhardwick Linux - Hardware 3 12-01-2003 03:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 11:41 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