I'm currently writing a small tool for a linux router that sets up a wwan (gsm/3g) connection when I plug an appropriate modem into its USB port. When the device is plugged in several ttys are registered and I currently maintain a list of manufacturers and devices and which of their registered ttys is the control / data port.
If possible I want to get rid of this list and find a way to somehow probe the registered ttys directly to check if they are a control port or a data port.
I examined the sourcecode of wvdial and modem-manager to see how these tools detect the right port but was unable to find suitable information. I also tried to look for information in sysfs to distinguish the ports but this wasn't successful either.
You cannot detect this via external means. The common practise is either to setup udev rules for specific modem manufacturer and model. Or you can sequentially connect to each tty and verify via AT command what type of port it is.
In the case of udev rules you can follow this process:
1) Detect modem vid and pid 2) Based on vid/pid create symlinks in /dev/serial/by-id
For example a Sierra Wireless MC8795V modem with vid = 1199 and pid 683c. I know that port 3 is always the AT command channel. Therefore you could create a symlink post-fixed with -AT at the end.
In the case of detecting via AT commands the best and more common approach is to execute the AT command to see if the tty responds at all. You should get an echo back or an OK if your configured your modem not to echo.
For example:
If you get a response this means you found either an AT control port or a PPP port. To check this simply execute a ATI command. If the response contains APP1, APP2, APP3 then you hit a PPP port. Otherwise you found your AT control port.
For example a AT control port:
For example a PPP port:
A word of warning though. In the case of Sierra Wireless modules they clearly show which port is which. In the case of other manufacturers you'll need to check the USB interface guide to see if it is possible via ATI to take this approach.