How to find out which /dev/ttyUSB* can be used for 3G modem connection?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to find out which /dev/ttyUSB* can be used for 3G modem connection?
Hi
I am writing a Perl script that detects USB 3G modem (of various types), switches it and then creates a connection with the ISP provider.
My problem is that several /dev/ttyUSB* files are created, and most cannot be used to connect.
I managed to filter some out by using modem command such as "at+csq" or "ati" (I receive a "timeout" on unconnected ttyUSBs).
But in some cases I am left with more than one /dev/ttyUSB* that respond correctly to these commands, but only one ttyUSB will actually work correctly with pppd.
For a more concrete example: USB stick Alcatel X220 (Vendor 1bbb product 0017). Both ttyUSB3 and ttyUSB4 respond to ati commands, but only ttyUSB4 will actually create the ppp connection (on ttyUSB3 pppd sends configuration requests but no answers are received).
Is there a way I can find out which ttyUSB is usable through a script?
This way should be generic for all USB modem types
The only way I can think of now is to add specific udev rules for ALL supported USB modems. And every time we add another supported modem, to add another rule.
Will be very thankful if there is an easier way to find out which ttyUSB to use
Is /dev/ttyUSB* a file or a link to a file in /dev/bus/usb/00?
If it is not a link then maybe you can get the information you need from dmesg, otherwise you can use udev rules (create your own in /dev/udev/rules.d) to map your device to the same filename when connected to the system.
You will have to read de documentation to create your own rule (check this link), but you can also look inside the ones already created by the system (the one for the CD could help) and you will get a notion about how you should create your own.
In a nutshell - I cannibalized usb_modeswitch way of switching:
I added to the udev rules a reference if it finds a tty file to call my script
I modified the usb_modeswitch scripts to my specific needs and it ended by creating a symbolic link (e.g /dev/modem3g) to the specific ttyUsb that is active
So far it has not failed me.
it has been a while since I did it and the code is no longer available to me immediately
Try to have a look at the way usb_modeswitch does it. If u still have trouble, I will try to dig around and find exactly what I did
Did you use the script usb_modeswitch.tcl?
I find that it seems to this script can make one a symbolic link to the specific ttyUSB, but I did not use the PC linux ,it based on the embedded Linux. So I can not use the tcl .
Thank you .
Yes ,I have tried wvdial
And I also find that wvdialconf will create a ttyUSB in the config file.
but this ttyUSB was not the PPP always ,it is just the first port between the AT and ppp.
For example , the at port is ttyUSB1 and the ppp port is ttyUSB2 ,the wvdialconf will create ttyUSB1 in the conf.
However , I'm now trying to porting the wvdial in my board , it will help me find the two ports, although will not find the true ppp port .
I do not know tcl and was too lazy to learn, although I could read it well enough
I took the idea and re-wrote it in Perl (slim possibility of bash, I do not remember)
I will try to upload the script on Monday
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.