{"id":3,"date":"2009-07-10T09:00:12","date_gmt":"2009-07-10T08:00:12","guid":{"rendered":"http:\/\/www.arensa.net\/?p=3"},"modified":"2009-07-10T09:16:42","modified_gmt":"2009-07-10T08:16:42","slug":"writing-udev-rules-to-create-symbolic-link-for-huawei-e220-usb-gsmumts-modem","status":"publish","type":"post","link":"https:\/\/www.arensa.net\/?p=3","title":{"rendered":"Writing udev rules to create symbolic link for Huawei E220 USB GSM\/UMTS Modem"},"content":{"rendered":"<p>On an Ubuntu 8.04 server, I connected a Huawei USB modem to send SMS using <a href=\"http:\/\/code.google.com\/p\/smslib\/\">SMSLib<\/a>. Normally, the modem interface can be found under \/dev\/ttyUSB0. For some reason, the system decided to mount the modem interface using \/dev\/ttyUSB1. To avoid to always reconfigure SMSLib, if such a change occurs, I decided to use udev rules to create a specific symlink for the modem interface.<\/p>\n<p>1. Check with lsusb if the device is connected:<\/p>\n<pre>prompt&gt; lsusb<\/pre>\n<pre>Bus 005 Device 005: ID 12d1:1003 Huawei Technologies Co., Ltd. E220 HSDPA Modem<\/pre>\n<pre>....<\/pre>\n<p>2. Somewhere in \/var\/log\/messages you should find an information, to which devices the different ports of the modem have been mapped to. In my case, it is:<\/p>\n<pre>Jul  9 08:50:07 server kernel: [4378805.151459] usb 5-5.1: airprime converter now attached to ttyUSB1<\/pre>\n<pre>Jul  9 08:50:07 server kernel: [4378805.151488] usb 5-5.1: airprime converter now attached to ttyUSB2<\/pre>\n<pre>Jul  9 08:50:07 server kernel: [4378805.151513] usb 5-5.1: airprime converter now attached to ttyUSB3<\/pre>\n<p>3. After checking with minicom that ttyUSB1 is the correct port, I used<\/p>\n<pre>udevinfo -a -p $(udevinfo -q path -n \/dev\/ttyUSB1) &gt; ttyUSB1.info<\/pre>\n<pre>udevinfo -a -p $(udevinfo -q path -n \/dev\/ttyUSB3) &gt; ttyUSB3.info<\/pre>\n<p>to retrieve information about the different device information stored in the udev database. \u00a0Simply running diff on the information shows you some hints, how to differentiate the devices and only create a symbolic link for one of those ports. In my case, the diff showed following results:<\/p>\n<pre>8,9c8,9<\/pre>\n<pre>&lt;   looking at device '\/devices\/pci0000:00\/0000:00:1d.7\/usb5\/5-5\/5-5.1\/5-5.1:1.0\/ttyUSB1\/tty\/ttyUSB1':<\/pre>\n<pre>&lt;     KERNEL==\"ttyUSB1\"<\/pre>\n<pre>---<\/pre>\n<pre>&gt;   looking at device '\/devices\/pci0000:00\/0000:00:1d.7\/usb5\/5-5\/5-5.1\/5-5.1:1.0\/ttyUSB3\/tty\/ttyUSB3':<\/pre>\n<pre>&gt;     KERNEL==\"ttyUSB3\"<\/pre>\n<pre>12c12<\/pre>\n<pre>&lt;     ATTR{dev}==\"188:1\"<\/pre>\n<pre>---<\/pre>\n<pre>&gt;     ATTR{dev}==\"188:3\"<\/pre>\n<p>4. Using the information\u00a0ATTR{dev}==&#8221;188:1&#8243; and ATTRS{product}==&#8221;HUAWEI Mobile&#8221; in a parent device, I came up with the following udev rule that I put into \/etc\/udev\/rules.d\/98-modem.rules:<\/p>\n<pre>KERNEL==\"ttyUSB*\", ATTR{dev}==\"188:1\", ATTRS{product}==\"HUAWEI Mobile\", SYMLINK+=\"ttyS20\"<\/pre>\n<p>According to the great tutorial <a href=\"http:\/\/reactivated.net\/writing_udev_rules.html\">Writing udev rules<\/a> by Daniel Drake, it is not possible to mix attributes from different parent devices. This is why I used the ATTR{dev}==&#8221;188:1&#8243; and not ATTRS{port_number}==&#8221;0&#8243; as I already used ATTRS{product}==&#8221;HUAWEI Mobile&#8221; in a different parent device. (You could also ATTRS{idVendor}==&#8221;12d1&#8243; and ATTRS{idProduct}==&#8221;1003&#8243; to specify the modem instead of the product attribute.)<\/p>\n<p>5. Simply let udev know about your newly created rule and check, if the system created the correct link:<\/p>\n<pre>promtp&gt; sudo udevtrigger<\/pre>\n<pre>prompt&gt; ll \/dev\/ttyS20<\/pre>\n<pre>lrwxrwxrwx 1 root root 7 2009-07-10 08:12 \/dev\/ttyS20 -&gt; ttyUSB1<\/pre>\n<p>Now you can use the device \/dev\/ttyS20 in your SMSLib configuration. To be used in SMSLib, the symbolic link should be named to something resembling a standard serial port, like \/dev\/ttyS*. If you do not so, it is possible that SMSLib (or the used RXTX lib) does not correctly recognise the serial port. It my first try, I named the symbolic link \/dev\/huawei_modem. Minicom was fine with that, but SMSLib did not like it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On an Ubuntu 8.04 server, I connected a Huawei USB modem to send SMS using SMSLib. Normally, the modem interface can be found under \/dev\/ttyUSB0. For some reason, the system decided to mount the modem interface using \/dev\/ttyUSB1. To avoid to always reconfigure SMSLib, if such a change occurs, I decided to use udev rules &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.arensa.net\/?p=3\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Writing udev rules to create symbolic link for Huawei E220 USB GSM\/UMTS Modem&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[5,3,4],"_links":{"self":[{"href":"https:\/\/www.arensa.net\/index.php?rest_route=\/wp\/v2\/posts\/3"}],"collection":[{"href":"https:\/\/www.arensa.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.arensa.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.arensa.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.arensa.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3"}],"version-history":[{"count":29,"href":"https:\/\/www.arensa.net\/index.php?rest_route=\/wp\/v2\/posts\/3\/revisions"}],"predecessor-version":[{"id":32,"href":"https:\/\/www.arensa.net\/index.php?rest_route=\/wp\/v2\/posts\/3\/revisions\/32"}],"wp:attachment":[{"href":"https:\/\/www.arensa.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.arensa.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.arensa.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}