LinuxQuestions.org
Visit Jeremy's Blog.
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 11-23-2007, 03:09 AM   #1
ShadyCraig
LQ Newbie
 
Registered: Jan 2001
Location: UK - Midlands
Distribution: Redhat various
Posts: 29

Rep: Reputation: 15
alternative to syslog for finding devine names


Hello,

I'm working with a itx mobo running a cut down version of redhat with uclibc and busy box.

My C application makes use of a number of usb devices (up to about 16) that are normally physically present at boot time.
Currently I'm reading /proc/bus/usb/devices and then using the device number to parse through syslog() output to find my device name (eg /dev/ttyUSBx).

Although this works ok there are a number of pitfalls:
1. syslog() only keeps 4k of buffer so it's possible that the items of interest might roll off. (It might be possible to increase this buffer that's a poor fix)
2. Doing string comparisons is slow and error-prone
3. The usb devices are accessed by different threads, each thread needs to know it's appropriate device names, so I must repeat the effort for each thread. (It's can't be done by a controlling thread or startup process)

Is there anyway to get the device name (/dev/ttyUSBx) without using syslog?
Or perhaps I can fix certain devices to always get the same name?

Any ideas?

Craig
 
Old 11-23-2007, 10:28 AM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by ShadyCraig View Post
Is there anyway to get the device name (/dev/ttyUSBx) without using syslog?
Or perhaps I can fix certain devices to always get the same name?
You can do both. You can find out nodes associated with actual devices through the /sys filesystem. Also, you can assign names to devices through udev (youíll have to pick something distinguishable about the device such as serial number or port where itís plugged in).

If you need help with specifics, just post. Also, thereís this thread.
 
Old 11-28-2007, 02:48 AM   #3
ShadyCraig
LQ Newbie
 
Registered: Jan 2001
Location: UK - Midlands
Distribution: Redhat various
Posts: 29

Original Poster
Rep: Reputation: 15
Thumbs up

Thanks osor,

I think /sys is what I'm looking for!

I didn't have the /sys directory though and didn't have sysfs mounted so I did this:

# mkdir /sys
# mount -t sysfs none /sys

and now it's all there


Thanks again,
Craig
 
  


Reply

Tags
device, dmesg, mount, probe, sysfs, syslog, udev


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
Finding the names of files deleted through samba? LLuna Linux - Software 3 02-26-2007 07:13 AM
LXer: Centralized Syslog Server Using syslog-NG LXer Syndicated Linux News 0 04-28-2006 06:21 PM
finding the workgroups and share names. bruse Mandriva 1 03-28-2005 01:12 AM
Logical device names and instant names Gins Linux - General 8 11-30-2004 08:17 PM
SAMBA: display of share names is OK but files names are wrong superandrzej Linux - Software 5 02-02-2004 09:14 AM


All times are GMT -5. The time now is 12:26 PM.

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