LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (http://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   alternative to syslog for finding devine names (http://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/alternative-to-syslog-for-finding-devine-names-601832/)

ShadyCraig 11-23-2007 04:09 AM

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

osor 11-23-2007 11:28 AM

Quote:

Originally Posted by ShadyCraig (Post 2968220)
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.

ShadyCraig 11-28-2007 03:48 AM

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


All times are GMT -5. The time now is 11:18 PM.