2 * Copyright © 2012 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25 /* We record flight numbers in the first record of
26 * the log. Tasks may wait for this to be initialized
27 * by sleeping on this variable.
29 extern __xdata uint16_t ao_flight_number;
31 extern __pdata uint32_t ao_log_current_pos;
32 extern __pdata uint32_t ao_log_end_pos;
33 extern __pdata uint32_t ao_log_start_pos;
34 extern __xdata uint8_t ao_log_running;
35 extern __pdata enum flight_state ao_log_state;
37 /* required functions from the underlying log system */
39 #define AO_LOG_FORMAT_UNKNOWN 0 /* unknown; altosui will have to guess */
40 #define AO_LOG_FORMAT_FULL 1 /* 8 byte typed log records */
41 #define AO_LOG_FORMAT_TINY 2 /* two byte state/baro records */
42 #define AO_LOG_FORMAT_TELEMETRY 3 /* 32 byte ao_telemetry records */
43 #define AO_LOG_FORMAT_TELESCIENCE 4 /* 32 byte typed telescience records */
44 #define AO_LOG_FORMAT_NONE 127 /* No log at all */
46 extern __code uint8_t ao_log_format;
48 /* Return the flight number from the given log slot, 0 if none */
50 ao_log_flight(uint8_t slot);
56 /* Logging thread main routine */
60 /* functions provided in ao_log.c */
62 /* Figure out the current flight number */
64 ao_log_scan(void) __reentrant;
66 /* Return the position of the start of the given log slot */
68 ao_log_pos(uint8_t slot);
70 /* Start logging to eeprom */
78 /* Initialize the logging system */
82 /* Write out the current flight number to the erase log */
84 ao_log_write_erase(uint8_t pos);
86 /* Returns true if there are any logs stored in eeprom */
90 /* Returns true if there is no more storage space available */
99 * The data log is recorded in the eeprom as a sequence
102 * Each packet starts with a 4-byte header that has the
103 * packet type, the packet checksum and the tick count. Then
104 * they all contain 2 16 bit values which hold packet-specific
107 * For each flight, the first packet
108 * is FLIGHT packet, indicating the serial number of the
109 * device and a unique number marking the number of flights
110 * recorded by this device.
112 * During flight, data from the accelerometer and barometer
113 * are recorded in SENSOR packets, using the raw 16-bit values
114 * read from the A/D converter.
116 * Also during flight, but at a lower rate, the deployment
117 * sensors are recorded in DEPLOY packets. The goal here is to
118 * detect failure in the deployment circuits.
120 * STATE packets hold state transitions as the flight computer
121 * transitions through different stages of the flight.
123 #define AO_LOG_FLIGHT 'F'
124 #define AO_LOG_SENSOR 'A'
125 #define AO_LOG_TEMP_VOLT 'T'
126 #define AO_LOG_DEPLOY 'D'
127 #define AO_LOG_STATE 'S'
128 #define AO_LOG_GPS_TIME 'G'
129 #define AO_LOG_GPS_LAT 'N'
130 #define AO_LOG_GPS_LON 'W'
131 #define AO_LOG_GPS_ALT 'H'
132 #define AO_LOG_GPS_SAT 'V'
133 #define AO_LOG_GPS_DATE 'Y'
135 #define AO_LOG_POS_NONE (~0UL)
137 struct ao_log_record {
143 int16_t ground_accel;
168 int32_t gps_latitude;
169 int32_t gps_longitude;
192 /* Write a record to the eeprom log */
194 ao_log_data(__xdata struct ao_log_record *log) __reentrant;
196 #endif /* _AO_LOG_H_ */