$ sudo apt install -y python3-pip python-virtualenv python3-virtualenv git build-essential
# Note: git only if, FortiusANT is checked out via git
$ sudo apt-get install -y libatlas-base-dev # for numpy, https://github.com/numpy/numpy/issues/11110
Note: pip
may try to build the Python package wxPython
from source code. This is sometimes too much, especially for weak hardware like the Raspberry Pi. This can be solved by installing the package globally in the system via:
$ sudo apt install -y python3-wxgtk4.0
Other packages such as numpy or pygame can also be provided via the system if necessary.
$ virtualenv -p python3 --system-site-packages venv
Afterwards, the installation of packages for FortiusANT always requires the virtualv to be activated first. This also applies to starting FortiusANT.
This is done, inital after starting a new shell session:
$ source venv/bin/activate
via git:
$ git clone https://github.com/WouterJD/FortiusANT.git
or via download
$ curl -L https://github.com/WouterJD/FortiusANT/archive/master.tar.gz | tar -xzvf -
Sadly, FortiusANT currently does not set any tags and therefore no releases. Otherwise you could directly address a special version.
Install FortiusANT dependencies:
# remember activated virtualenv required
$ pip install -r FortiusANT/pythoncode/requirements.txt
Required to not run FortiusANT as root. Depending on the ANT-Stick a different entry appears with lsusb
. In my example, "Dynastream Innovations, Inc. ANTUSB2 Stick" is used here.
$ lsusb
Bus 001 Device 005: ID 0fcf:1008 Dynastream Innovations, Inc. ANTUSB2 Stick
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. SMC9512/9514 USB Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Important here are the vendor id 0fcf
and product id 1008
.
We assign the Linux USB serial driver to the ANT stick by noting the driver with the id's:
$ sudo su
$ cat << EOF > /etc/modprobe.d/ant-usb2.conf
options usbserial vendor=0x0fcf product=0x1008
EOF
Furthermore we assign the device file to our user so that he can read and write to it. In my example the user is pi
. Please also adjust the following example with your usb ids (vendor and product). It is also possible to assign Groups. See udev rules documentation or search the web for more examples.
$ sudo su
$ cat << EOF > /etc/udev/rules.d/garmin-ant2.rules
# https://stackoverflow.com/questions/3738173/why-does-pyusb-libusb-require-root-sudo-permissions-on-linux
SUBSYSTEM=="usb" ENV{DEVTYPE}=="usb_device" MODE="0664" GROUP="pi"
SUBSYSTEM=="tty" ACTION=="add" ATTRS{idProduct}=="1008" ATTRS{idVendor}=="0fcf" MODE="0665" GROUP="pi"
EOF
More general udev rules can be found here.
Now reload the 'usbserial' driver and update / reload the udev deamon. If in doubt, re-attach the dongle and/or reboot the system completely.
Now FortiusANT (here only command line) can be tested.
$ source venv/bin/activate # load the virtualenv, if not done before
$ cd FortiusANT/pythoncode
$ python FortiusAnt.py -s -a
With the option "-s" the Tacx Head-Unit is left out, only the Ant Dongle is tested with simulated date. Please consult the manual for more commandline parameters.
Hi @martin-vi
Thank you very much for sharing the pi setup. This is really helpful.
Quick questions:
(By the way, there is hyphen missing in "$ virtualenv -p python3 --system-site packages venv" between site and packages)
Thanks once again