#!/bin/bash # Install library for AIRSPY (HF) DISCOVERY SDR USB device, ref: http://airspy.com # # note: this is getting code from github.com # install the udev rules, see below. # run: # % sudo udevadm monitor -e # Now plug it in a USB port. # # cat /etc/udev/rules.d/52-airspy.rules # Gives: # ATTR{idVendor}=="1d50", ATTR{idProduct}=="60a1", SYMLINK+="airspy-%k", MODE="660", GROUP="plugdev" # # I see from "dmesg" this is wrong. # from running "sudo udevadm monitor -e" # ID_VENDOR_ID=03eb # # After plugging in the device running "dmesg" as root shows # [1682676.090509] usb 1-12: New USB device found, idVendor=03eb, idProduct=800c, bcdDevice= 1.00 # # So # ATTR{idVendor}=="03eb", ATTR{idProduct}=="800c", SYMLINK+="airspy-%k", MODE="660", GROUP="plugdev" # or # ATTR{idVendor}=="03eb", ATTR{idProduct}=="800c", SYMLINK+="airspyhf-%k", MODE="660", GROUP="plugdev" # # Both where installed in file /etc/udev/rules.d/52-airspy.rules and both # worked in a test; re-plugging the USB between tests. # # We see file: /dev/airspy-1-12 # set -exo pipefail tag=1.6.8 tarname=airspyhf-$tag # This works for our hardware USB device: # # Note: the escape sequence hell (\\\) is required in order to triple # process it, once with bash = here, once with cat, and one more time with # cut and paste into an interactive bash shell by a user of this bash # script. esc_udev_rule="ATTR{idVendor}==\\\"03eb\\\", ATTR{idProduct}==\\\"800c\\\",\ SYMLINK+=\\\"airspyhf-%k\\\", MODE=\\\"660\\\", GROUP=\\\"plugdev\\\"" sha512sum= cd "$(dirname ${BASH_SOURCE[0]})" try=0 tarnameTry=$tarname-try-$try while [ -d "${tarnameTry}" ] ; do let try=$try+1 tarnameTry=$tarname-try-$try done builddir="${tarnameTry}" url=https://github.com/airspy/airspyhf/tarball/$tag prefix=/usr/local/encap/$tarnameTry tarfile=$tarname.tar.gz case "$tag" in 1.6.8) sha512sum= ;; esac if [ ! -e "$tarfile" ] ; then wget --no-check-certificate $url -O $tarfile fi if [ -n "$sha512sum" ] ; then echo "$sha512sum $tarfile" | sha512sum -c - else set +x sha512sum $tarfile set -x fi mkdir "$builddir" cd $builddir tar --strip-components=1 -xzf ../$tarfile mkdir BUILD cd BUILD # INSTALL_UDEV_RULES could be used to install as root, but we avoided that # and copied it by hand: #-DINSTALL_UDEV_RULES=ON\ cmake .. -G"Unix Makefiles"\ -DINSTALL_UDEV_RULES=OFF\ -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE\ -DCMAKE_INSTALL_PREFIX:PATH="${prefix}"\ -DCMAKE_INSTALL_RPATH:PATH="${prefix}/lib"\ -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=TRUE make VERBOSE=1 -j4 make install set +x cat << EOF SUCCESSFULLY installed $tarname in $prefix You may want to: sudo echo "$esc_udev_rule" > /etc/udev/rules.d/52-airspy.rules EOF