diff options
| author | Bdale Garbee <bdale@gag.com> | 2013-12-19 01:38:40 -0700 |
|---|---|---|
| committer | Bdale Garbee <bdale@gag.com> | 2013-12-19 01:38:40 -0700 |
| commit | 575bbaf976c5840fd0e308549c45a466fdec1352 (patch) | |
| tree | 11bfb498348bf7687bffc24699c4b1a998988ee4 /ao-bringup | |
| parent | b825116df173b77e2cab217a7b76112c742f9279 (diff) | |
| parent | bc3610d8cecbfed40c62d4dcb93fc9a4d2a7c9e3 (diff) | |
Merge branch 'branch-1.3' into debian
Conflicts:
ChangeLog
altoslib/AltosRecordMM.java
altosui/Makefile.am
altosui/altos-windows.nsi.in
configure.ac
debian/changelog
debian/control
doc/Makefile
doc/altusmetrum.xsl
doc/release-notes-1.2.1.xsl
doc/release-notes-1.2.xsl
Diffstat (limited to 'ao-bringup')
| -rwxr-xr-x | ao-bringup/cal-accel | 120 | ||||
| -rwxr-xr-x | ao-bringup/cal-freq | 46 | ||||
| -rwxr-xr-x | ao-bringup/get-radio-cal | 66 | ||||
| -rwxr-xr-x | ao-bringup/turnon_telebt | 17 | ||||
| -rwxr-xr-x | ao-bringup/turnon_telemega | 61 | ||||
| -rwxr-xr-x | ao-bringup/turnon_teleminiv2 | 53 |
6 files changed, 356 insertions, 7 deletions
diff --git a/ao-bringup/cal-accel b/ao-bringup/cal-accel new file mode 100755 index 00000000..96e51e62 --- /dev/null +++ b/ao-bringup/cal-accel @@ -0,0 +1,120 @@ +#!/usr/bin/nickle + +import File; + +string timed_read(file f, int timeout) { + thread reader = fork func() { + try { + return fgets(f); + } catch Thread::signal(int i) { + return ""; + } + }(); + + thread killer = fork func() { + try { + sleep (timeout); + Thread::send_signal(reader, 1); + } catch Thread::signal(int i) { + return; + } + }(); + + poly v = Thread::join(reader); + Thread::send_signal(killer, 1); + Thread::join(killer); + if (is_string(v)) + return v; + return ""; +} + +void flush_input(file f) { + for (;;) { + string s = timed_read(f, 200); + if (s == "") + break; + } +} + +string[*] settings(file f) { + string[...] x = {}; + + flush_input(f); + fprintf (f, "c s\nv\n"); + flush(f); + for (;;) { + string l = File::fgets(f); + x[dim(x)] = l; + if (String::index(l, "software-version") == 0) + break; + } + return x; +} + +string[*] find_setting(string[*] s, string match) { + for (int i = 0; i < dim(s); i++) + if (String::index(s[i], match) == 0) + return String::split(s[i], " "); + return (string[*]) {}; +} + +bool +do_cal(file f) { + flush_input(f); + fprintf(f, "E 1\nc a 0\n"); + flush(f); + string s = ""; + bool worked = true; + bool running = false; + + thread put = fork func() { + try { + for (;;) { + putc(getchar(), f); + flush(f); + } + } catch Thread::signal(int i) { + return; + } + }(); + + for (;;) { + int c = getc(f); + if (c == '\n') + s = ""; + else + s = s + String::new(c); + putchar(c); flush(stdout); + if (String::index(s, "press a key...") >= 0) + running = true; + if (String::index(s, "Invalid") >= 0) + worked = false; + if (running && String::index(s, ">") >= 0) + break; + } + fprintf (f, "E 0\n"); + if (worked) + fprintf (f, "c w\n"); + sleep(200); + Thread::send_signal(put, 1); + Thread::join(put); + + return worked; +} + +void main () { + string name = argv[1]; + file f = open(name, "r+"); + + if (do_cal(f)) { + string[*] s = settings(f); + string[*] ac = find_setting(s, "Accel cal"); + printf ("Calibration value +1g %s -1g %s saved\n", ac[3], ac[5]); + exit (0); + } else { + printf ("Calibration failed\n"); + exit (1); + } +} + +main(); diff --git a/ao-bringup/cal-freq b/ao-bringup/cal-freq new file mode 100755 index 00000000..dc2f2212 --- /dev/null +++ b/ao-bringup/cal-freq @@ -0,0 +1,46 @@ +#!/bin/sh + +case $# in +1) + dev="$1" + ;; +*) + echo "Usage: $0 <device>" + exit 1; + ;; +esac + +while true; do + echo 'C 1' > $dev + + echo -n "Generating RF carrier. Please enter measured frequency [enter for done]: " + + read FREQ + + echo 'C 0' > $dev + + case "$FREQ" in + "") + exit 0 + ;; + *) + calline=`./get-radio-cal $dev` + CURRENT_CAL=`echo $calline | awk '{print $2}'` + CURRENT_FREQ=`echo $calline | awk '{print $4}'` + + echo "Current radio calibration "$CURRENT_CAL + echo "Current radio frequency "$CURRENT_FREQ + + CAL_VALUE=`nickle -e "floor($CURRENT_FREQ / $FREQ * $CURRENT_CAL + 0.5)"` + + echo "Programming flash with cal value " $CAL_VALUE + + cat << EOF > $dev +c f $CAL_VALUE +c w +EOF + + echo "Serial number "$SERIAL" programmed with RF cal value "$CAL_VALUE + ;; + esac +done diff --git a/ao-bringup/get-radio-cal b/ao-bringup/get-radio-cal new file mode 100755 index 00000000..8f975fe3 --- /dev/null +++ b/ao-bringup/get-radio-cal @@ -0,0 +1,66 @@ +#!/usr/bin/nickle + +import File; + +string timed_read(file f, int timeout) { + thread reader = fork func() { try { return fgets(f); } catch Thread::signal(int i) { return ""; } }(); + thread killer = fork func() { sleep (timeout); Thread::send_signal(reader, 1); }(); + poly v = Thread::join(reader); + if (is_string(v)) + return v; + return ""; +} + +void flush_input(file f) { + for (;;) { + string s = timed_read(f, 100); + if (s == "") + break; + } +} + +string[*] settings(file f) { + string[...] x = {}; + + flush_input(f); + fprintf (f, "c s\nv\n"); + flush(f); + for (;;) { + string l = File::fgets(f); + x[dim(x)] = l; + if (String::index(l, "software-version") == 0) + break; + } + return x; +} + +string[*] find_setting(string[*] s, string match) { + for (int i = 0; i < dim(s); i++) + if (String::index(s[i], match) == 0) + return String::split(s[i], " "); + return (string[*]) {}; +} + +int[*] +get_radio (file f) { + string[*] s = settings(f); + + string[*] cal = find_setting(s, "Radio cal:"); + string[*] freq = find_setting(s, "Frequency:"); + if (dim(cal) == 0 || dim(freq) == 0) + return (int[2]) { 0, 0 }; + + int cal_val = string_to_integer(cal[2]); + int freq_val = string_to_integer(freq[1]); + return (int[2]) { cal_val, freq_val }; +} + +void main () { + string name = argv[1]; + file f = open(name, "r+"); + + int[*] vals = get_radio(f); + printf ("cal %d freq %f\n", vals[0], vals[1] / 1000); +} + +main(); diff --git a/ao-bringup/turnon_telebt b/ao-bringup/turnon_telebt index 6c52721c..ef20e915 100755 --- a/ao-bringup/turnon_telebt +++ b/ao-bringup/turnon_telebt @@ -1,5 +1,8 @@ #!/bin/sh +# serial number of the TeleDongle being used as the flash programmer +DONGLE=612 + if [ -x ../ao-tools/ao-load/ao-load ]; then AOLOAD=../ao-tools/ao-load/ao-load elif [ -x /usr/bin/ao-load ]; then @@ -18,12 +21,12 @@ else exit 1 fi -echo "TeleBT v0.1 Turn-On and Calibration Program" -echo "Copyright 2011 by Bdale Garbee. Released under GPL v2" +echo "TeleBT v1.1 Turn-On and Calibration Program" +echo "Copyright 2013 by Bdale Garbee. Released under GPL v2" echo echo "Expectations:" -echo "\tTeleBT v0.1 powered from USB" -echo "\t\twith TeleDonle (on /dev/ttyACM0) cabled to debug header" +echo "\tTeleBT v1.1 powered from USB" +echo "\t\twith TeleDonlge (on /dev/ttyACM0) cabled to debug header" echo "\t\twith coax from SMA to frequency counter" echo echo -n "TeleBT serial number: " @@ -31,18 +34,18 @@ read SERIAL echo $RAWLOAD -$RAWLOAD -D 100 -r ao_led_blink.ihx +$RAWLOAD -D $DONGLE -r ao_led_blink.ihx echo "LEDs should be blinking" sleep 5 -$RAWLOAD -D 100 -r ao_radio_xmit.ihx +$RAWLOAD -D $DONGLE -r ao_radio_xmit.ihx echo -n "Generating RF carrier. Please enter measured frequency: " read FREQ CAL_VALUE=`nickle -e "floor(434.55 / $FREQ * 1186611 + 0.5)"` echo "Programming flash with cal value " $CAL_VALUE -$AOLOAD -D 100 --cal $CAL_VALUE /usr/share/altos/telebt-v0.1*.ihx $SERIAL +$AOLOAD -D $DONGLE --cal $CAL_VALUE /usr/share/altos/stable/telebt-v1.0*.ihx $SERIAL echo "Serial number "$SERIAL" programmed with RF cal value "$CAL_VALUE echo "Unplug debug cable, power cycle, cu to the board, confirm freq and record power" diff --git a/ao-bringup/turnon_telemega b/ao-bringup/turnon_telemega new file mode 100755 index 00000000..a8bf8697 --- /dev/null +++ b/ao-bringup/turnon_telemega @@ -0,0 +1,61 @@ +#!/bin/sh + +if [ -x ../ao-tools/ao-stmload/ao-stmload ]; then + STMLOAD=../ao-tools/ao-stmload/ao-stmload +elif [ -x /usr/bin/ao-stmload ]; then + STMLOAD=/usr/bin/ao-stmload +else + echo "Can't find ao-stmload! Aborting." + exit 1 +fi + +if [ -x ../ao-tools/ao-usbload/ao-usbload ]; then + USBLOAD=../ao-tools/ao-usbload/ao-usbload +elif [ -x /usr/bin/ao-usbload ]; then + USBLOAD=/usr/bin/ao-usbload +else + echo "Can't find ao-usbload! Aborting." + exit 1 +fi + +VERSION=1.0 +#VERSION=0.1 + +echo "TeleMega v$VERSION Turn-On and Calibration Program" +echo "Copyright 2010 by Bdale Garbee. Released under GPL v2" +echo +echo "Expectations:" +echo "\tTeleMega 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 "TeleMega-$VERSION serial number: " +read SERIAL + +echo $STMLOAD + +$STMLOAD --raw ../src/telemega-v$VERSION/flash-loader/*.elf || exit 1 + +sleep 2 + +$USBLOAD --serial=$SERIAL ../src/telemega-v$VERSION/*.ihx || exit 1 + +sleep 2 + +dev=`ao-list | awk '/TeleMega-v'"$VERSION"'/ { print $3; exit(0); }'` + +case "$dev" in +/dev/tty*) + echo "TeleMega found on $dev" + ;; +*) + echo 'No TeleMega-v'"$VERSION"' found' + exit 1 + ;; +esac + +echo 'E 0' > $dev + +SERIAL=$SERIAL ./cal-freq $dev + +./cal-accel $dev diff --git a/ao-bringup/turnon_teleminiv2 b/ao-bringup/turnon_teleminiv2 new file mode 100755 index 00000000..0ce73cbb --- /dev/null +++ b/ao-bringup/turnon_teleminiv2 @@ -0,0 +1,53 @@ +#!/bin/sh + +if [ -x ../ao-tools/ao-load/ao-load ]; then + AOLOAD=../ao-tools/ao-load/ao-load +elif [ -x /usr/bin/ao-load ]; then + AOLOAD=/usr/bin/ao-load +else + echo "Can't find ao-load! Aborting." + exit 1 +fi + +if [ -x ../ao-tools/ao-rawload/ao-rawload ]; then + RAWLOAD=../ao-tools/ao-rawload/ao-rawload +elif [ -x /usr/bin/ao-rawload ]; then + RAWLOAD=/usr/bin/ao-rawload +else + echo "Can't find ao-rawload! Aborting." + exit 1 +fi + +echo "TeleMini v2.0 Turn-On and Calibration Program" +echo "Copyright 2011 by Bdale Garbee. Released under GPL v2" +echo "Copyright 2013 by Keith Packard. Released under GPL v2" +echo +echo "Expectations:" +echo "\tTeleMini v2.0 powered from LiPo" +echo "\t\twith TeleDongle (on /dev/ttyACM0) cabled to debug header" +echo "\t\twith frequency counter able to sample RF output" +echo +echo -n "TeleMini serial number: " +read SERIAL + +echo $RAWLOAD + +#TTY=/dev/ttyACM0 +PROGRAMMER="-D 186" +BIN=../src/telemini-v2.0*.ihx + +$RAWLOAD $PROGRAMMER -r ao_led_blink.ihx +echo "LEDs should be blinking" +sleep 5 + +$RAWLOAD $PROGRAMMER -r ao_radio_xmit.ihx +echo -n "Generating RF carrier. Please enter measured frequency: " +read FREQ + +CAL_VALUE=`nickle -e "floor(434.55 / $FREQ * 1186611 + 0.5)"` + +echo "Programming flash with cal value " $CAL_VALUE +$AOLOAD $PROGRAMMER --cal=$CAL_VALUE $BIN $SERIAL + +echo "Serial number "$SERIAL" programmed with RF cal value "$CAL_VALUE +echo "Unplug and replug USB, cu to the board, confirm freq and record power" |
