SPEC-3723: restructure meta-agl-demo
[AGL/meta-agl-demo.git] / recipes-navigation / gpsd / gpsd / sw-device-hook
diff --git a/recipes-navigation/gpsd/gpsd/sw-device-hook b/recipes-navigation/gpsd/gpsd/sw-device-hook
new file mode 100644 (file)
index 0000000..e1e6f7a
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Figure out the parent usb device
+USBDEV=`ls -l "$1" |sed -ne 's!^c[^ ]* [0-9]* [^ ]* [^ ]* \([0-9]*\), \([0-9]*\) .*!/sys/dev/char/\1:\2/device/../..!p'`
+
+# Silently ignore any non-USB ports
+if [ ! -r "$USBDEV/idVendor" ] || [ ! -r "$USBDEV/idProduct" ]; then
+       exit 0
+fi 
+
+VID=`cat "$USBDEV/idVendor"`
+PID=`cat "$USBDEV/idProduct"`
+case "$2" in
+       ACTIVATE) CMD=START ;;
+       *) CMD=STOP ;;
+esac
+
+case "$VID:$PID" in
+       "1199:9071"|"1199:9079") echo \$GPS_$CMD >"$1" ;;
+       *) ;;
+esac
+
+exit 0