2 * Copyright © 2013 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.
22 static uint8_t log_year, log_month, log_day;
23 static uint8_t log_open;
25 static uint8_t log_mutex;
33 sprintf(name,"%04d%02d%02dLOG", 2000 + log_year, log_month, log_day);
34 status = ao_fat_open(name, AO_FAT_OPEN_WRITE);
37 ao_fat_seek(log_fd, 0, AO_FAT_SEEK_END);
39 } else if (status == -AO_FAT_ENOENT) {
40 status = ao_fat_creat(name);
65 ao_log_mega(struct ao_log_mega *log)
68 ao_mutex_get(&log_mutex);
69 if (log->type == AO_LOG_GPS_TIME) {
71 (log_year != log->u.gps.year ||
72 log_month != log->u.gps.month ||
73 log_day != log->u.gps.day)) {
77 log_year = log->u.gps.year;
78 log_month = log->u.gps.month;
79 log_day = log->u.gps.day;
84 wrote = ao_fat_write(log_fd, log, sizeof (*log)) == AO_FAT_SUCCESS;
87 ao_mutex_put(&log_mutex);