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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-19-2011, 07:10 AM
|
#1
|
LQ Newbie
Registered: May 2011
Posts: 8
Rep:
|
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
|
|
|
10-19-2011, 07:56 AM
|
#2
|
Member
Registered: Jul 2009
Location: Kiev,Ukraine
Distribution: Ubuntu,Slax,RedHat
Posts: 289
Rep:
|
ls /dev/bus/usb/ ? or grab source of lsusb and look
|
|
|
10-19-2011, 08:46 AM
|
#3
|
LQ Newbie
Registered: May 2011
Posts: 8
Original Poster
Rep:
|
ls reports:
ls /dev/bus/usb
001 002
how can I use that?
Thank's again.
Georg
|
|
|
10-20-2011, 07:15 AM
|
#5
|
Member
Registered: Jul 2009
Location: Kiev,Ukraine
Distribution: Ubuntu,Slax,RedHat
Posts: 289
Rep:
|
/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) {
|
|
|
|
10-20-2011, 07:27 AM
|
#6
|
Member
Registered: Jul 2009
Location: Kiev,Ukraine
Distribution: Ubuntu,Slax,RedHat
Posts: 289
Rep:
|
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)
|
|
|
|
All times are GMT -5. The time now is 03:52 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|