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; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 static uint8_t log_year, log_month, log_day;
24 static uint8_t log_open;
26 static uint8_t log_mutex;
34 sprintf(name,"%04d%02d%02dLOG", 2000 + log_year, log_month, log_day);
35 status = ao_fat_open(name, AO_FAT_OPEN_WRITE);
38 ao_fat_seek(log_fd, 0, AO_FAT_SEEK_END);
40 } else if (status == -AO_FAT_ENOENT) {
41 status = ao_fat_creat(name);
66 ao_log_mega(struct ao_log_mega *log)
69 ao_mutex_get(&log_mutex);
70 if (log->type == AO_LOG_GPS_TIME) {
72 (log_year != log->u.gps.year ||
73 log_month != log->u.gps.month ||
74 log_day != log->u.gps.day)) {
78 log_year = log->u.gps.year;
79 log_month = log->u.gps.month;
80 log_day = log->u.gps.day;
85 wrote = ao_fat_write(log_fd, log, sizeof (*log)) == AO_FAT_SUCCESS;
88 ao_mutex_put(&log_mutex);