altos: Add 'g' command to ublox GPS code.
authorKeith Packard <keithp@keithp.com>
Tue, 14 May 2013 16:12:29 +0000 (09:12 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 16 May 2013 05:11:21 +0000 (22:11 -0700)
Take the gps_dump function from ao_gps_skytraq.c and move it to a new
file so it can be shared with the u-blox driver. That affects every
skytraq and u-blox user as they need to include the new file.

Signed-off-by: Keith Packard <keithp@keithp.com>
15 files changed:
src/core/ao.h
src/core/ao_gps_show.c [new file with mode: 0644]
src/drivers/ao_gps_skytraq.c
src/drivers/ao_gps_ublox.c
src/telegps-v0.1/Makefile
src/telemega-v0.1/Makefile
src/telemega-v0.3/Makefile
src/telemetrum-v0.1-sky/Makefile
src/telemetrum-v1.0/Makefile
src/telemetrum-v1.1/Makefile
src/telemetrum-v1.2/Makefile
src/teleterra-v0.2/Makefile
src/test/Makefile
src/test/ao_gps_test_skytraq.c
src/test/ao_gps_test_ublox.c

index 0ad3e4aa6504b68774fdbd7b487a59385ff9a4f2..71bfb6a1f880d36988788b8e4a99e36fcf8c1ed6 100644 (file)
@@ -379,6 +379,9 @@ ao_gps_print(__xdata struct ao_gps_orig *gps_data);
 void
 ao_gps_tracking_print(__xdata struct ao_gps_tracking_orig *gps_tracking_data);
 
+void
+ao_gps_show(void) __reentrant;
+
 void
 ao_gps_init(void);
 
diff --git a/src/core/ao_gps_show.c b/src/core/ao_gps_show.c
new file mode 100644 (file)
index 0000000..3a05e35
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2013 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef AO_GPS_TEST
+#include <ao.h>
+#endif
+
+void
+ao_gps_show(void) __reentrant
+{
+       uint8_t i;
+       ao_mutex_get(&ao_gps_mutex);
+       printf ("Date: %02d/%02d/%02d\n", ao_gps_data.year, ao_gps_data.month, ao_gps_data.day);
+       printf ("Time: %02d:%02d:%02d\n", ao_gps_data.hour, ao_gps_data.minute, ao_gps_data.second);
+       printf ("Lat/Lon: %ld %ld\n", (long) ao_gps_data.latitude, (long) ao_gps_data.longitude);
+       printf ("Alt: %d\n", ao_gps_data.altitude);
+       printf ("Flags: 0x%x\n", ao_gps_data.flags);
+       printf ("Sats: %d", ao_gps_tracking_data.channels);
+       for (i = 0; i < ao_gps_tracking_data.channels; i++)
+               printf (" %d %d",
+                       ao_gps_tracking_data.sats[i].svid,
+                       ao_gps_tracking_data.sats[i].c_n_1);
+       printf ("\ndone\n");
+       ao_mutex_put(&ao_gps_mutex);
+}
index d2f67e6b6947b1f9cd4c8e1c87fc13a018eb23b7..9a9dff75725f8dc315400fddded7b3aa26c1095b 100644 (file)
@@ -483,25 +483,6 @@ ao_gps(void) __reentrant
 
 __xdata struct ao_task ao_gps_task;
 
-static void
-gps_dump(void) __reentrant
-{
-       uint8_t i;
-       ao_mutex_get(&ao_gps_mutex);
-       printf ("Date: %02d/%02d/%02d\n", ao_gps_data.year, ao_gps_data.month, ao_gps_data.day);
-       printf ("Time: %02d:%02d:%02d\n", ao_gps_data.hour, ao_gps_data.minute, ao_gps_data.second);
-       printf ("Lat/Lon: %ld %ld\n", (long) ao_gps_data.latitude, (long) ao_gps_data.longitude);
-       printf ("Alt: %d\n", ao_gps_data.altitude);
-       printf ("Flags: 0x%x\n", ao_gps_data.flags);
-       printf ("Sats: %d", ao_gps_tracking_data.channels);
-       for (i = 0; i < ao_gps_tracking_data.channels; i++)
-               printf (" %d %d",
-                       ao_gps_tracking_data.sats[i].svid,
-                       ao_gps_tracking_data.sats[i].c_n_1);
-       printf ("\ndone\n");
-       ao_mutex_put(&ao_gps_mutex);
-}
-
 static __code uint8_t ao_gps_115200[] = {
        SKYTRAQ_MSG_3(5,0,5,0)  /* Set to 115200 baud */
 };
@@ -532,7 +513,7 @@ gps_update(void) __reentrant
 }
 
 __code struct ao_cmds ao_gps_cmds[] = {
-       { gps_dump,     "g\0Display GPS" },
+       { ao_gps_show,  "g\0Display GPS" },
        { gps_update,   "U\0Update GPS firmware" },
        { 0, NULL },
 };
index 22300df3100f636753aa90d4de39519bb0474f21..24e70ee3a8ec34f711bb7115584a16fe1efa7749 100644 (file)
@@ -695,10 +695,16 @@ ao_gps(void) __reentrant
        }
 }
 
+__code struct ao_cmds ao_gps_cmds[] = {
+       { ao_gps_show,  "g\0Display GPS" },
+       { 0, NULL },
+};
+
 __xdata struct ao_task ao_gps_task;
 
 void
 ao_gps_init(void)
 {
+       ao_cmd_register(&ao_gps_cmds[0]);
        ao_add_task(&ao_gps_task, ao_gps, "gps");
 }
index 2c41235bc1e049538798365f4f0d037438fa6051..64deddc621bbc56c978fbfd6423618133a6e3cf9 100644 (file)
@@ -52,6 +52,7 @@ ALTOS_SRC = \
        ao_exti_stm.c \
        ao_serial_stm.c \
        ao_gps_skytraq.c \
+       ao_gps_show.c \
        ao_cc115l.c \
        ao_fec_tx.c \
        ao_rfpa0133.c \
index a72d08f213a16da7577c5ce1a2f3688990570ad4..bf756e9637e5eacfd758c0dbd1c42d85783589ce 100644 (file)
@@ -59,6 +59,7 @@ ALTOS_SRC = \
        ao_mutex.c \
        ao_serial_stm.c \
        ao_gps_skytraq.c \
+       ao_gps_show.c \
        ao_gps_report_mega.c \
        ao_ignite.c \
        ao_freq.c \
index 398c7dab4d03ab7783ff8b37b2052409a0274e3c..f2c0625fd4d70e819f736b1033affab0953c44b2 100644 (file)
@@ -59,6 +59,7 @@ ALTOS_SRC = \
        ao_mutex.c \
        ao_serial_stm.c \
        ao_gps_ublox.c \
+       ao_gps_show.c \
        ao_gps_report_mega.c \
        ao_ignite.c \
        ao_freq.c \
index 69cd3461faf8dbcd282836ff386f35c0bf2dcdaa..a6634c2957cca259f44990d1b2382f75a82c1677 100644 (file)
@@ -11,6 +11,7 @@ TM_INC = \
 
 TM_SRC = \
        ao_gps_skytraq.c \
+       ao_gps_show.c \
        ao_25lc1024.c
 
 include ../product/Makefile.telemetrum
index 4aae84c8e0749ce901197d4f17894072c63957fd..476a3b0aef64abe369fb740dca84f45d9eca02d3 100644 (file)
@@ -11,6 +11,7 @@ TM_INC = \
 TM_SRC = \
        ao_companion.c \
        ao_gps_skytraq.c \
+       ao_gps_show.c \
        ao_at45db161d.c
 
 include ../product/Makefile.telemetrum
index 4bea03db3243ce92396623081ba65f74f1798b2c..e44be7f9ae5c9bfde8b180a857a28fd42ecaabf4 100644 (file)
@@ -11,6 +11,7 @@ TM_INC =
 TM_SRC = \
        ao_companion.c \
        ao_gps_skytraq.c \
+       ao_gps_show.c \
        ao_m25.c
 
 include ../product/Makefile.telemetrum
index 4b650adf1fbd29539dd8b6dd79381d85bd6e956c..f2285fbed52b0c3c5f21f39fd9e13133715dd3da 100644 (file)
@@ -11,6 +11,7 @@ TM_INC =
 TM_SRC = \
        ao_companion.c \
        ao_gps_skytraq.c \
+       ao_gps_show.c \
        ao_m25.c
 
 include ../product/Makefile.telemetrum
index 65db57ce5191a0e1167174f7dca904c4059ff7ba..68a8d1b6c6c664d64efebe175abcd95f272db3d5 100644 (file)
@@ -52,7 +52,8 @@ CC1111_SRC = \
 DRIVER_SRC = \
        ao_m25.c \
        ao_lcd.c \
-       ao_gps_skytraq.c
+       ao_gps_skytraq.c \
+       ao_gps_show.c
 
 PRODUCT_SRC = \
        ao_teleterra_0_2.c \
index 169c1dc6f68d54bd6703e674cf86ef204567b9d1..8032a1636536f7f5d2fa36822701b91b0022d8fd 100644 (file)
@@ -35,10 +35,10 @@ ao_flight_test_mm: ao_flight_test.c ao_host.h ao_flight.c ao_sample.c ao_kalman.
 ao_gps_test: ao_gps_test.c ao_gps_sirf.c ao_gps_print.c ao_host.h
        cc $(CFLAGS) -o $@ $<
 
-ao_gps_test_skytraq: ao_gps_test_skytraq.c ao_gps_skytraq.c ao_gps_print.c ao_host.h
+ao_gps_test_skytraq: ao_gps_test_skytraq.c ao_gps_skytraq.c ao_gps_print.c ao_gps_show.c ao_host.h
        cc $(CFLAGS) -o $@ $<
 
-ao_gps_test_ublox: ao_gps_test_ublox.c ao_gps_ublox.c ao_gps_print.c ao_host.h ao_gps_ublox.h
+ao_gps_test_ublox: ao_gps_test_ublox.c ao_gps_ublox.c ao_gps_print.c ao_gps_show.c ao_host.h ao_gps_ublox.h
        cc $(CFLAGS) -o $@ $<
 
 ao_convert_test: ao_convert_test.c ao_convert.c altitude.h
index 81008b39ebc282e6aa4682779691d6e2580528b2..89cbd7677beebe4e140dc1d26eddfb60ef71852d 100644 (file)
@@ -75,6 +75,11 @@ struct ao_gps_tracking_orig {
 #define ao_telemetry_satellite ao_gps_tracking_orig
 #define ao_telemetry_satellite_info ao_gps_sat_orig
 
+extern __xdata struct ao_telemetry_location    ao_gps_data;
+extern __xdata struct ao_telemetry_satellite   ao_gps_tracking_data;
+
+uint8_t ao_gps_mutex;
+
 void
 ao_mutex_get(uint8_t *mutex)
 {
@@ -432,17 +437,14 @@ uint8_t   ao_task_minimize_latency;
 #define ao_usb_getchar()       0
 
 #include "ao_gps_print.c"
+#include "ao_gps_show.c"
 #include "ao_gps_skytraq.c"
 
 void
 ao_dump_state(void *wchan)
 {
        if (wchan == &ao_gps_data)
-               ao_gps_print(&ao_gps_data);
-       else
-               ao_gps_tracking_print(&ao_gps_tracking_data);
-       putchar('\n');
-       return;
+               ao_gps_show();
 }
 
 int
index 806717354e301c9d2d79ddd7d8ee38893b0bb125..afd4dba414f45b14a3012db4adcfaa0744ad9bee 100644 (file)
@@ -77,6 +77,11 @@ struct ao_telemetry_satellite {
 #define ao_gps_tracking_orig ao_telemetry_satellite
 #define ao_gps_sat_orig ao_telemetry_satellite_info
 
+extern __xdata struct ao_telemetry_location    ao_gps_data;
+extern __xdata struct ao_telemetry_satellite   ao_gps_tracking_data;
+
+uint8_t ao_gps_mutex;
+
 void
 ao_mutex_get(uint8_t *mutex)
 {
@@ -224,6 +229,7 @@ uint8_t     ao_task_minimize_latency;
 #define ao_usb_getchar()       0
 
 #include "ao_gps_print.c"
+#include "ao_gps_show.c"
 #include "ao_gps_ublox.c"
 
 static void
@@ -342,10 +348,7 @@ void
 ao_dump_state(void *wchan)
 {
        if (wchan == &ao_gps_data)
-               ao_gps_print(&ao_gps_data);
-       else
-               ao_gps_tracking_print(&ao_gps_tracking_data);
-       putchar('\n');
+               ao_gps_show();
        return;
 }