Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm forced to work with a bunch of point-of-sale systems running SuSE 8. They are my client's computers. We are stuck dealing with these old systems until they get to upgrade their whole fleet to SLE 11.

The problem: the system now has two devices that compete for the ttyUSB* character device nodes. They have different vendor ID and product ID. SuSE 8 doesn't have udev, it has devfs instead.

Knowing the device's vendor ID and product ID, and the kernel module responsible for the device (it's the ipaq kernel module), how do I find out what character device node it has been assigned to, in a way that it can be stored in a string (e.g. $DeviceNode) in a POSIX shell script?

Right now, I'm doing it in a really really dumb way in my shell script:

DeviceNode=$(dmesg | tac | grep "PocketPC PDA converter now attached to" | set -n 's/.*now attached to \([[:alnum:]]\{1,\}\).*/\1/p')

So I get, for instance

> echo $DeviceNode
ttyUSB1
>

Of course, one of the problems is that the device may have already been unplugged and I wouldn't be able to tell with this naïve method.

Is there any better way?

EDIT: So I found this article this morning. Can I assume that, in /proc/tty/driver/usbserial, from the 2nd line onward, the first number of each line is the minor number of one of the ttyUSBx?

EDIT 2: An alternate (and perhaps better) solution would be to get persistent node association (e.g. always getting a device with a known vendor ID and a known product ID to be associated with ttyUSB1). Is that achievable in devfs?

share|improve this question
    
Is there a /proc/tty/driver/usbserial on that old kernel? –  Stéphane Chazelas Nov 2 '12 at 13:29
    
I don't have access to the test machine right now. It's Friday night, well past office hour here in Hong Kong; and my client's office doesn't open on Saturday/Sunday. But assuming that it does have /proc/tty/driver/usbserial, what do I do with it? I have googled a bit about /proc/tty/driver/usbserial and it seems that it would contain some entries like: usbserinfo:1.0 driver:2.0 0: module:ftdi_sio name:"FTDI USB Serial Device" vendor:0403 product:6001 num_ports:1 port:1 path:usb-0000:00:1d.2-2 Which part of it is the x number (of ttyUSBx) that I want? –  Kal Nov 2 '12 at 15:33
1  
For anyone else coming across this question: let me stress that using udev and the links in /dev/serial/by-id is the right solution. This question only exists because the asker is using a Linux distribution that is more than a decade old. –  Jim Paris Nov 2 '12 at 18:31
    
Actually, given udev, I wouldn't even have to find the corresponding ttyUSBx; I could just set a udev rule and assign the node name I want. But alas, udev only exists from SuSE 9 up (as far as the SuSE lineage is concerned). –  Kal Nov 3 '12 at 1:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.