summaryrefslogtreecommitdiff
path: root/monitor_sirf.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-02-05 00:32:10 -0800
committerGary E. Miller <gem@rellim.com>2015-02-05 00:32:10 -0800
commit718db4342bb85570afba727886fff0b3311b2ff2 (patch)
tree4671d4cdac5ac66779c4fc24013541d73cecb3b3 /monitor_sirf.c
parenta3a9587f80da3daccf1e830fb24096c0badd30d5 (diff)
downloadgpsd-718db4342bb85570afba727886fff0b3311b2ff2.tar.gz
Add function timespec_str(), and use it.
Converting a timespec to a printable string is odd, so placed in a new function for ease of use.
Diffstat (limited to 'monitor_sirf.c')
-rw-r--r--monitor_sirf.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/monitor_sirf.c b/monitor_sirf.c
index 2b8e642f..16371d50 100644
--- a/monitor_sirf.c
+++ b/monitor_sirf.c
@@ -593,20 +593,15 @@ static void sirf_update(void)
if (pps_thread_lastpps(&session, &drift) > 0) {
/* NOTE: can not use double here due to precision requirements */
struct timespec timedelta;
- char sign = ' ';
+ char buf[22];
TS_SUB( &timedelta, &drift.clock, &drift.real);
if ( 86400 < (long)labs(timedelta.tv_sec) ) {
/* more than one day off, overflow */
/* need a bigger field to show it */
(void)mvwprintw(mid7win, 2, 39, "> 1 day");
} else {
- if ( (0 > timedelta.tv_nsec ) || ( 0 > timedelta.tv_sec ) ) {
- sign = '-';
- }
- (void)mvwprintw(mid7win, 4, 39, "%c%ld.%09ld",
- sign,
- (long)labs(timedelta.tv_sec),
- (long)labs(timedelta.tv_nsec));
+ (void)timespec_str( &timedelta, buf, sizeof(buf) );
+ (void)mvwprintw(mid7win, 4, 39, "%s", buf);
}
(void)wnoutrefresh(mid7win);
}