Udev can help to get rid of the ugly $ sudo irattach irda0 -s
in my previous blog post.
I added the following udev rule:
$ cat /etc/udev/rules.d/95-usb-irda.rules
# Connect the IRDA USB Dongle
# see http://de.gentoo-wiki.com/Udev_Rules
# use "$ lsusb -v" to get the details about the dongle
ACTION=="add", BUS=="usb", SYSFS{manufacturer}==" Sigmatel Inc ", SYSFS{product}==" IrDA/USB Bridge", NAME="%k", RUN+="/usr/local/bin/usb-irda-add.sh"
# ACTION=="remove", BUS=="usb", SYSFS{idVendor}=="066f", SYSFS{idProduct}=="4200", RUN+="/usr/local/bin/usb-irda-remove.sh"
combined with the script
# cat /usr/local/bin/usb-irda-add.sh
#!/bin/sh
# Init script for /etc/udev/rules.d/95-usb-irda.rules
# modprobe ircomm_tty
irattach irda0 -s
# http://osdir.com/ml/drivers.gnokii/2003-09/msg00014.html
echo 115200 > /proc/sys/net/irda/max_baud_rate
and voila, the dongle hotplugs.
What’s puzzling me, is that /var/log/messages
shows multiple identical entries:
Oct 3 22:06:17 sifr irattach: executing: '/sbin/modprobe irda0'
Oct 3 22:06:17 sifr irattach: executing: 'echo sifr > /proc/sys/net/irda/devname'
Oct 3 22:06:17 sifr irattach: executing: '/sbin/modprobe irda0'
Oct 3 22:06:17 sifr irattach: executing: 'echo 1 > /proc/sys/net/irda/discovery'
Oct 3 22:06:17 sifr irattach: executing: '/sbin/modprobe irda0'
Oct 3 22:06:17 sifr irattach: executing: 'echo sifr > /proc/sys/net/irda/devname'
Oct 3 22:06:17 sifr irattach: Starting device irda0
Oct 3 22:06:17 sifr irattach: executing: 'echo 1 > /proc/sys/net/irda/discovery'
Oct 3 22:06:17 sifr irattach: executing: 'echo sifr > /proc/sys/net/irda/devname'
Oct 3 22:06:17 sifr irattach: executing: '/sbin/modprobe irda0'
Oct 3 22:06:17 sifr irattach: Starting device irda0
Oct 3 22:06:17 sifr irattach: executing: 'echo 1 > /proc/sys/net/irda/discovery'
Oct 3 22:06:17 sifr irattach: executing: 'echo sifr > /proc/sys/net/irda/devname'
Oct 3 22:06:17 sifr irattach: Starting device irda0
Oct 3 22:06:17 sifr irattach: executing: 'echo 1 > /proc/sys/net/irda/discovery'
Oct 3 22:06:17 sifr irattach: Starting device irda0
and that unplugging doesn’t unload the kernel modules, despite the script
$ cat /usr/local/bin/usb-irda-remove.sh
#!/bin/sh
# Removal script for /etc/udev/rules.d/95-usb-irda.rules
rmmod ircomm_tty ircomm stir4200 irda crc_ccitt