]> git.gag.com Git - fw/altos/blob - ao-bringup/cal-freq-file
Revert "altos/lpc: Fix double-buffered USB changes"
[fw/altos] / ao-bringup / cal-freq-file
1 #!/bin/sh
2
3 case $# in
4 2)
5     dev="$1"
6     serial="$2"
7         ;;
8 *)
9         echo "Usage: $0 <device> <serial>"
10         exit 1;
11         ;;
12 esac
13
14 echo 'E 0' > $dev
15
16 while true; do
17
18         dd if=$dev iflag=nonblock of=/dev/null > /dev/null 2>&1
19
20         echo 'C 1' > $dev
21
22         echo -n "Generating RF carrier. Please enter measured frequency [enter for done]: "
23
24         read FREQ
25
26         echo 'C 0' > $dev
27
28         calline=`./get-radio-cal $dev`
29         CURRENT_CAL=`echo $calline | awk '{print $2}'`
30         CURRENT_FREQ=`echo $calline | awk '{print $4}'`
31         CAL_VALUE=$CURRENT_CAL
32
33         case "$FREQ" in
34         "")
35                 echo $serial","$CAL_VALUE >> cal_values
36                 exit 0
37                 ;;
38         *)
39                 echo "Current radio calibration "$CURRENT_CAL
40                 echo "Current radio frequency "$CURRENT_FREQ
41
42                 CAL_VALUE=`nickle -e "floor($CURRENT_FREQ / $FREQ * $CURRENT_CAL + 0.5)"`
43
44                 echo "Setting cal value" $CAL_VALUE
45
46                 dd if=$dev iflag=nonblock of=/dev/null > /dev/null 2>&1
47
48                 cat << EOF > $dev
49 c f $CAL_VALUE
50 EOF
51                 ;;
52         esac
53 done
54