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.

Is there a way to autodetect modem devices in Linux and then symlink them to /dev/modem using a udev rule?

Currently, I wrote a program that probes each serial port, sending AT and waiting for OK. I have a udev script that runs this for every ttyS and ttyUSB device. However, I've now been informed that there's other devices, such as OBD-II diagnostic bridges, that also speak with AT commands.

share|improve this question
    
Also if it's a serial printer then your AT command is going to get printed on paper, which isn't good either. Serial ports predate plug and play, and so were not designed to be able to do auto detection. –  psusi Feb 1 '12 at 15:11
    
@psusi The issue is USB->Serial converters don't always appear in the same order; you can't permanently say the modem will be /dev/ttyUSB1 for example. –  David Pfeffer Feb 1 '12 at 15:17
    
The USB->Serial converter should have a serial number or other unique USB identifier you can check. –  psusi Feb 1 '12 at 15:19
add comment

2 Answers

You could play a little with cts, rts or other serial status lines and check if the modem responds to lowering/raising that signal correspondingly. But your modem may be configured to ignore these lines, or there might be other devices that also react to those changes.

I think psusi got the correct answer.

I remember I once debugged hylafax to get the idea how it derived the type of modem. Basically it did the same as you did - send AT-commands and check the "typical" answer.

share|improve this answer
add comment

Detect the properties of each serial port. Look at the vendor and model strings. For example,

# udevadm info --query="property" --name=/dev/ttyUSB0**

UDEV_LOG=3
DEVPATH=/devices/platform/orion-ehci.0/usb1/1-1/1-1:1.0/ttyUSB0 /tty/ttyUSB0
MAJOR=188
MINOR=0
DEVNAME=/dev/ttyUSB0
SUBSYSTEM=tty
ID_PORT=0
ID_PATH=platform-orion-ehci.0-usb-0:1:1.0
ID_VENDOR=FTDI
ID_VENDOR_ENC=FTDI
ID_VENDOR_ID=0403
ID_MODEL=FT232R_USB_UART
ID_MODEL_ENC=FT232R\x20USB\x20UART
ID_MODEL_ID=6001
ID_REVISION=0600
ID_SERIAL=FTDI_FT232R_USB_UART_A40135O1
ID_SERIAL_SHORT=A40135O1
ID_TYPE=generic
ID_BUS=usb
ID_USB_INTERFACES=:ffffff:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=ftdi_sio
ID_IFACE=00
ID_VENDOR_FROM_DATABASE=Future Technology Devices International, Ltd
ID_MODEL_FROM_DATABASE=FT232 USB-Serial (UART) IC
DEVLINKS=/dev/char/188:0 /dev/serial/by-path/platform-orion-ehci.0-usb-0:1:1.0-port0 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A40135O1-if00-port0
share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.