Memanfaatkan Fasilitas UDEV di Linux untuk Pengalamatan Hardware
Sekedar Informasi:
Berawal dari sebuah kebutuhan untuk memasang 5 USB GSM Modem pada sebuah mesin Linux.
Untuk mengaktifkan GSM Modem dan berkomunikasi dengan si alat mungkin bukan masalah yang berat, tetapi bagaimana jika alat tersebut lebih dari 1, semua nya 1 tipe.
Permasalahannya adalah bagaimana memaksa agar GSM Modem yg bernomer X akan selalu beralamatkan USB0, GSM Modem dengan SIM Card Y ada di alamat USB1, dst.
Ternyata kita bisa menyiasatinya dengan UDEV.
Di kasus ini, terdapat 2 USB Hub, dan anggap saja 8 USB GSM Modem … maka hal yg perlu dilakukan:
1. Ketahui urutan alamat Port di USB Hub, mana yg USB Hub pertama dan mana USB Hub yang kedua, lalu di masing2 USB HUB … cari tau mana port 1, 2, 3, dan 4 (atau lebih).
Caranya:
- jalankan dmesg atau tail -f /var/log/messages … dan colokan USB GSM Modem/USB apapun di salah satu port di USB Hub
usb 2-2.4: new full speed USB device using ohci_hcd and address 7
pl2303 2-2.4:1.0: PL-2303 converter detected
—> (2-2.4) artinya USB Hub kedua, port ke-4
atau
usb 2-1.3: new full speed USB device using ohci_hcd and address 8
pl2303 2-1.3:1.0: PL-2303 converter detected
usb 2-1.3: PL-2303 converter now attached to ttyUSB4
—> (2-1.3) artinya USB Hub pertama, port ke-3
Untuk mendapatkan informasi lebih detil, jalankan:
udevinfo -a -p /sys/class/tty/ttyUSB4
Hasilnya:
udevinfo starts with the device the node belongs to and then walks up the
device chain, to print for every device found, all possibly useful attributes
in the udev key format.
Only attributes within one device section may be used together in one rule,
to match the device for which the node will be created.
looking at class device '/sys/class/tty/ttyUSB4':
SYSFS{dev}="188:4"
follow the class device's "device"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:01.3/usb2/2-1/2-1.1/2-1.1:1.0/ttyUSB4':
BUS="usb-serial"
ID="ttyUSB4"
SYSFS{detach_state}="0"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:01.3/usb2/2-1/2-1.1/2-1.1:1.0':
BUS="usb"
ID="2-1.1:1.0"
SYSFS{bAlternateSetting}=" 0"
SYSFS{bInterfaceClass}="ff"
SYSFS{bInterfaceNumber}="00"
SYSFS{bInterfaceProtocol}="00"
SYSFS{bInterfaceSubClass}="00"
SYSFS{bNumEndpoints}="03"
SYSFS{detach_state}="0"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:01.3/usb2/2-1/2-1.1':
BUS="usb"
ID="2-1.1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}="500mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0001"
SYSFS{bmAttributes}="80"
SYSFS{detach_state}="0"
SYSFS{devnum}="11"
SYSFS{idProduct}="1080"
SYSFS{idVendor}="0eba"
SYSFS{manufacturer}="Prolific Technology Inc."
SYSFS{maxchild}="0"
SYSFS{product}="USB-Serial Controller"
SYSFS{speed}="12"
SYSFS{version}=" 1.10"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:01.3/usb2/2-1':
BUS="usb"
ID="2-1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="09"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}="100mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0312"
SYSFS{bmAttributes}="e0"
SYSFS{detach_state}="0"
SYSFS{devnum}="10"
SYSFS{idProduct}="9254"
SYSFS{idVendor}="058f"
SYSFS{manufacturer}="ALCOR"
SYSFS{maxchild}="4"
SYSFS{product}="Generic USB Hub"
SYSFS{speed}="12"
SYSFS{version}=" 1.10"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:01.3/usb2':
BUS="usb"
ID="usb2"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="09"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}=" 0mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 1"
SYSFS{bcdDevice}="0206"
SYSFS{bmAttributes}="c0"
SYSFS{detach_state}="0"
SYSFS{devnum}="1"
SYSFS{idProduct}="0000"
SYSFS{idVendor}="0000"
SYSFS{manufacturer}="Linux 2.6.11-1.27_FC3 ohci_hcd"
SYSFS{maxchild}="2"
SYSFS{product}="OHCI Host Controller"
SYSFS{serial}="0000:00:01.3"
SYSFS{speed}="12"
SYSFS{version}=" 1.10"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:01.3':
BUS="pci"
ID="0000:00:01.3"
SYSFS{class}="0x0c0310"
SYSFS{detach_state}="0"
SYSFS{device}="0x7001"
SYSFS{irq}="9"
SYSFS{local_cpus}="1"
SYSFS{subsystem_device}="0x7000"
SYSFS{subsystem_vendor}="0x1039"
SYSFS{vendor}="0x1039"
looking at the device chain at '/sys/devices/pci0000:00':
BUS=""
ID="pci0000:00"
SYSFS{detach_state}="0"
Nah, sekarang saatnya bermain dengan UDEV ….
File yang kita mainkan cukup dengan file yg sudah ada saja … /etc/udev/rules.d/50-udev.rules
Tambahkan di baris2 terakhir saja … seperti berikut
BUS="usb", ID="2-1.1", NAME="ttyUSB0", SYMLINK="gsm-modem1"
BUS="usb", ID="2-1.2", NAME="ttyUSB1", SYMLINK="gsm-modem2"
BUS="usb", ID="2-1.3", NAME="ttyUSB2", SYMLINK="gsm-modem3"
BUS="usb", ID="2-1.4", NAME="ttyUSB3", SYMLINK="gsm-modem4"
BUS="usb", ID="2-2.1", NAME="ttyUSB4", SYMLINK="gsm-modem5"
BUS="usb", ID="2-2.2", NAME="ttyUSB5", SYMLINK="gsm-modem6"
BUS="usb", ID="2-2.3", NAME="ttyUSB6", SYMLINK="gsm-modem7"
BUS="usb", ID="2-2.4", NAME="ttyUSB7", SYMLINK="gsm-modem8"
Symlink merupakan symbolic link dari ttyUSB0 ke sebuah file tersendiri yg kita sukai.
Jangan lupa jalankan:
udevstart
untuk mengaktifkan konfigurasi tadi.
- Ati2 dengan Kernel Fedora Core 4 => 2.6.14-1.1644_FC4
- Install USB Modem 3G Huawei E220 di Linux
- Membangun Sistem CCTV dari USB WebCam Sederhana dgn Menggunakan Motion


7 Comments
hallo juni,ich habe dein homepage gefunden,toll!
aber ich kann nicht verstehen: )
schade
mas dicky, gsm modem yg bagus dan multiport apa ya?
multiport itu maksudnya seperti gimana ya ?
gsm modem kayaknya bagus2 aja … termasuk HP+cable data juga sudah cukup bagus utk dijadikan GSM Modem.
yg pernah aku coba sih merk itegno.
maksudnya multiport itu misalnya port serialnya ada 2 atau lebih. Sejauh yg pernah di coba dg itegno tsb, berapa message per menit yg bisa di kirim?
emang ada ya device yg sampe multiport gitu ? baru denger soalnya
kl soal kecepatan gsm modem, sama aja ama hp biasa.
1 sms sekitar 5-10 detik.
jadi 1 menit = 5-12 sms.
Mas, aku make netac a840 usb cdma modem. ketika aku colokin, kemudian aku dmesg, yang keluar cuman:
usb 1-2: new full speed USB device using address 2
Bagaimana agar bisa dikenal dan di-map ke device name yang sesuai?
bagian yang ini …
BUS=”usb”, ID=”2-2.1″, NAME=”ttyUSB4″, SYMLINK=”gsm-modem5″ BUS=”usb”, ID=”2-2.2″, NAME=”ttyUSB5″, SYMLINK=”gsm-modem6″ BUS=”usb”, ID=”2-2.3″, NAME=”ttyUSB6″, SYMLINK=”gsm-modem7″ BUS=”usb”, ID=”2-2.4″, NAME=”ttyUSB7″, SYMLINK=”gsm-modem8″
edit aja yg perlu … udah dicoba belum?
Leave a reply