gpsdate: log the actual time that was set to the RTC.

This commit is contained in:
Harald Welte 2013-04-10 12:23:16 +02:00
parent f56f16539b
commit 3b870221a9
1 changed files with 5 additions and 1 deletions

View File

@ -46,6 +46,7 @@ static struct gps_data_t gpsdata;
static void callback(struct gps_data_t *gpsdata) static void callback(struct gps_data_t *gpsdata)
{ {
struct timeval tv; struct timeval tv;
time_t time;
int rc; int rc;
if (!(gpsdata->set & TIME_SET)) if (!(gpsdata->set & TIME_SET))
@ -55,10 +56,13 @@ static void callback(struct gps_data_t *gpsdata)
/* FIXME: use the fractional part for microseconds */ /* FIXME: use the fractional part for microseconds */
tv.tv_usec = 0; tv.tv_usec = 0;
time = tv.tv_sec;
rc = settimeofday(&tv, NULL); rc = settimeofday(&tv, NULL);
gps_close(gpsdata); gps_close(gpsdata);
if (rc == 0) { if (rc == 0) {
syslog(LOG_NOTICE, "Successfully set RTC time to GPSD time\n"); syslog(LOG_NOTICE, "Successfully set RTC time to GPSD time:"
" %s", ctime(&time));
closelog(); closelog();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else { } else {