Tigge/Garmin-Forerunner-610-Extractor — Issue #4: run as non root
Author: euri10
Created: 2012-02-13 10:12:49+00:00
State: open

I hate running scripts as root.
well, the 70-ant-usbstick2.rules you created was ok but here is what I changed for it to work on debian.
I will copy the process I used to create it as the mileage may vary depending on distributions.
1st step :
determine where is your ant2 usb stick with a lsusb :
....
Bus 002 Device 111: ID 0fcf:1008 Dynastream Innovations, Inc.
ok now you got those informations, you can use udevadm to print the needed info to create a udev rule :
# udevadm info --query=all --name=/dev/bus/usb/002/111 --attribute-walk

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

looking at device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1':
KERNEL=="2-1"
SUBSYSTEM=="usb"
DRIVER=="usb"
ATTR{configuration}=="ANT USBStick2"
ATTR{bNumInterfaces}==" 1"
ATTR{bConfigurationValue}=="1"
ATTR{bmAttributes}=="80"
ATTR{bMaxPower}=="100mA"
ATTR{urbnum}=="5123"
ATTR{idVendor}=="0fcf"
ATTR{idProduct}=="1008"
ATTR{bcdDevice}=="0100"
ATTR{bDeviceClass}=="00"
ATTR{bDeviceSubClass}=="00"
ATTR{bDeviceProtocol}=="00"
ATTR{bNumConfigurations}=="1"
ATTR{bMaxPacketSize0}=="32"
ATTR{speed}=="12"
ATTR{busnum}=="2"
ATTR{devnum}=="111"
ATTR{devpath}=="1"
ATTR{version}==" 2.00"
ATTR{maxchild}=="0"
ATTR{quirks}=="0x0"
ATTR{avoid_reset_quirk}=="0"
ATTR{authorized}=="1"
ATTR{manufacturer}=="Dynastream Innovations"
ATTR{product}=="ANT USBStick2"
ATTR{serial}=="104"

Now you got those info you can create a udev rule under /etc/udev/rules.d
At first I named mine 90-ant.rules, we'll see after that 90 at least on Debian isn't high enough but let's do that anyway :
KERNEL=="2-1", SUBSYSTEM=="usb", ATTR{idVendor}=="0fcf", ATTR{idProduct}=="1008", SYMLINK+="ttyANT", MODE="0666", ACTION=="add"

then let's test it (the /devices/.... comes from above) :
udevadm test /devices/pci0000:00/0000:00:1d.0/usb2/2-1

well if you look at the result you'll see that /lib/udev/rules.d/91-permissions.rules put the permission back to a state below 666, so I just renamed 90-ant.rules to 92-ant.rules and that did the trick.
On top of that I have a symbolic link to /dev/ttyANT to access it easily (from http://www.thisisant.com/component/option,com_fireboard/Itemid,146/func,view/catid,25/id,799/limit,6/limitstart,6/#1752)