altoslib: Add support for TeleGPS v2
[fw/altos] / ao-bringup / turnon_teledongle
index e6750c453a0e72ca11c197e2ad18f8ed4f3607ca..983f1010340004b69b1c7e0a74f2d5e61118a5e6 100755 (executable)
@@ -28,8 +28,21 @@ echo "\t$PRODUCT_NAME v$VERSION powered from USB"
 echo "\t\twith ST-Link-V2 cabled to debug header"
 echo "\t\twith coax from UHF to frequency counter"
 echo
-echo -n "$PRODUCT_NAME-$VERSION serial number: "
-read SERIAL
+
+case $# in
+    1)
+       SERIAL="$1"
+       echo "$PRODUCT-$VERSION serial number: $SERIAL" 
+       ;;
+    0)
+       echo -n "$PRODUCT-$VERSION serial number: "
+       read SERIAL
+       ;;
+    *)
+       echo "Usage: $0 <serial-number>" 1>&2
+       exit 1;
+       ;;
+esac
 
 BINARIES=$HOME/altusmetrumllc/Binaries
 
@@ -58,7 +71,9 @@ esac
 
 echo 'E 0' > $dev
 
-./cal-freq-file $dev $SERIAL
+CALFILE=cal-$SERIAL.txt
+
+../ao-tools/ao-cal-freq/ao-cal-freq --verbose --nosave --output=$CALFILE --tty=$dev
 
 case $? in
     0)
@@ -69,7 +84,7 @@ case $? in
        ;;
 esac
 
-CAL_VALUE=`grep "^$SERIAL," cal_values | tail -1 | sed 's/^[^,]*,//'`
+CAL_VALUE=`cat $CALFILE`
 
 case "$CAL_VALUE" in
     [1-9]*)
@@ -80,6 +95,8 @@ case "$CAL_VALUE" in
        ;;
 esac
 
+echo $SERIAL","$CAL_VALUE >> cal_values
+
 echo "Reflashing with calibration: $CAL_VALUE"
 
 $USBLOAD --cal=$CAL_VALUE --tty=$dev $ALTOS || exit 1