Skip to content

Instantly share code, notes, and snippets.

@jgmel
Last active November 9, 2017 15:50
Show Gist options
  • Save jgmel/8aba673986094a08c1d249db70e65e88 to your computer and use it in GitHub Desktop.
Save jgmel/8aba673986094a08c1d249db70e65e88 to your computer and use it in GitHub Desktop.
Phoenix Card Reader-USB Smartcard Reader
#!/bin/sh
main(){
NCARD=0
PREFIX=phoenix
rm -f /etc/udev/rules.d/99-usb-serial.rules
for n in /dev/ttyUSB*; do
let NCARD++
UDEV_SERIAL=`udevadm info -a -p $(udevadm info -q path -n ${n}) | grep -B 12 'FT232R USB UART' | grep 'ATTRS{serial}'`
cat >> /etc/udev/rules.d/99-usb-serial.rules <<EOT
SUBSYSTEMS=="usb", KERNEL=="ttyUSB?", ${UDEV_SERIAL}, SYMLINK+="${PREFIX}${NCARD}"
EOT
echo "$n ==> /dev/${PREFIX}${NCARD}"
if [ ! -e /dev/${PREFIX}${NCARD} ]; then
ln -s $n /dev/${PREFIX}${NCARD}
fi
done
}
main
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment