LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   USB camera enumeration (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/usb-camera-enumeration-939126/)

Lobinho 04-10-2012 01:06 PM

USB camera enumeration
 
Hi,

My board is a mini2440 SDK board, with ARM processor (400mhz) and 64mb ram. Inside it I have a custom rootfs (based on default rootfs) and kernel 2.6.32-2.
I'm working on a project with 2 usb cameras. One camera will be connected
on USB1 and another will be connected on USB2 port of a micro 2440 SDK.


Using above configuration, I have two devices on /dev/:
/dev/video0
/dev/video1

My problem is that I need to know which is connected on USB1 and which is connected on USB2.
For example, /dev/video0 is on USB2 port (1-1.2), and /dev/video1 is on USB1 port (1-1.1).

I tried to write some script calls on /etc/mdev.conf rules (to tell me which USB is being used) (mdev is a kind of udev). This works well when I plug USB cameras while system is running. But it doesn't work well when the system is restarted. The rules are not called properly (i don't know why) during initialization.


In fact, I just need to know where /dev/video0 is connected, USB1 or USB2.
Any file on system can tell me that easily (/sys/bus/usb/...), instead of write a lot of scripts?


Thanks in advance.

david1941 04-11-2012 10:25 PM

I don't know if this will help but I had a problem figuring out where my scanner was mounted and used the lsusb command like this
Code:

# Determine scanning device - Epsom Prefection 640U attached (we hope)
DEVBUS=`/sbin/lsusb |grep Epson|cut -d " " -f2`
DEVDEV=`/sbin/lsusb |grep Epson|cut -d " " -f4`
DEVDEV=`echo $DEVDEV |sed s/://`
SANE_DEFAULT_DEVICE="epson:libusb:$DEVBUS:$DEVDEV"
[ -z "$DEVDEV" ] && SANE_DEFAULT_DEVICE=""
# The above discovers the usb device.  If power has cycled on the scanner,
# the usb port changes, therefore using the environment doesn't always work.

[ -n $SANE_DEFAULT_DEVICE ] || (echo "Cannot find the scanner!" && exit 1)

It might work for you purposes.

Lobinho 04-13-2012 12:43 PM

Hi David,

Thanks for your response. I had forgot about the 'lsusb' command.
I don't have lsusb cross-compiled for ARM, so I did some tests on PC. The main problem is that I don't know exactly what usb camera my client will use... I have to support any.

I'll try to understand better the output of lsusb, and try to find a solution with this tool.

Thanks,


All times are GMT -5. The time now is 12:59 AM.