Autodetect us or ns logfiles
parent
f69fccd528
commit
81dd2ff511
30
canplayer.c
30
canplayer.c
|
|
@ -452,14 +452,20 @@ int main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
log_tv.tv_sec = sec;
|
log_tv.tv_sec = sec;
|
||||||
log_tv.tv_usec = usec;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ensure the fractions of seconds are 6 decimal places long to catch
|
* ensure the fractions of seconds are 6 or 9 decimal places long to catch
|
||||||
* 3rd party or handcrafted logfiles that treat the timestamp as float
|
* 3rd party or handcrafted logfiles that treat the timestamp as float
|
||||||
*/
|
*/
|
||||||
if (strchr(buf, ')') - strchr(buf, '.') != 7) {
|
switch (strchr(buf, ')') - strchr(buf, '.')) {
|
||||||
fprintf(stderr, "timestamp format in logfile requires 6 decimal places\n");
|
case 7: //6
|
||||||
|
log_tv.tv_usec = usec;
|
||||||
|
break;
|
||||||
|
case 10: //9
|
||||||
|
log_tv.tv_usec = usec / 1000;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "timestamp format in logfile requires 6 or 9 decimal places\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -541,19 +547,25 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sscanf(buf, "(%llu.%llu) %s %s", &sec, &usec, device, afrbuf) != 4) {
|
if (sscanf(buf, "(%llu.%llu) %21s %6299s", &sec, &usec, device, afrbuf) != 4) {
|
||||||
fprintf(stderr, "incorrect line format in logfile\n");
|
fprintf(stderr, "incorrect line format in logfile\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
log_tv.tv_sec = sec;
|
log_tv.tv_sec = sec;
|
||||||
log_tv.tv_usec = usec;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ensure the fractions of seconds are 6 decimal places long to catch
|
* ensure the fractions of seconds are 6 or 9 decimal places long to catch
|
||||||
* 3rd party or handcrafted logfiles that treat the timestamp as float
|
* 3rd party or handcrafted logfiles that treat the timestamp as float
|
||||||
*/
|
*/
|
||||||
if (strchr(buf, ')') - strchr(buf, '.') != 7) {
|
switch (strchr(buf, ')') - strchr(buf, '.')) {
|
||||||
fprintf(stderr, "timestamp format in logfile requires 6 decimal places\n");
|
case 7: //6
|
||||||
|
log_tv.tv_usec = usec;
|
||||||
|
break;
|
||||||
|
case 10: //9
|
||||||
|
log_tv.tv_usec = usec / 1000;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "timestamp format in logfile requires 6 or 9 decimal places\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
17
log2asc.c
17
log2asc.c
|
|
@ -407,7 +407,22 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tv.tv_sec = sec;
|
tv.tv_sec = sec;
|
||||||
tv.tv_usec = usec;
|
|
||||||
|
/*
|
||||||
|
* ensure the fractions of seconds are 6 or 9 decimal places long to catch
|
||||||
|
* 3rd party or handcrafted logfiles that treat the timestamp as float
|
||||||
|
*/
|
||||||
|
switch (strchr(buf, ')') - strchr(buf, '.')) {
|
||||||
|
case 7: //6
|
||||||
|
tv.tv_usec = usec;
|
||||||
|
break;
|
||||||
|
case 10: //9
|
||||||
|
tv.tv_usec = usec / 1000;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "timestamp format in logfile requires 6 or 9 decimal places\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (print_banner) { /* print banner */
|
if (print_banner) { /* print banner */
|
||||||
print_banner = 0;
|
print_banner = 0;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
|
|
||||||
#define DEVSZ 22
|
#define DEVSZ 22
|
||||||
#define TIMESZ 22 /* sizeof("(1345212884.318850) ") */
|
#define TIMESZ 25 /* sizeof("(1345212884.318850123) ") */
|
||||||
#define BUFSZ (DEVSZ + AFRSZ + TIMESZ)
|
#define BUFSZ (DEVSZ + AFRSZ + TIMESZ)
|
||||||
|
|
||||||
/* adapt sscanf() functions below on error */
|
/* adapt sscanf() functions below on error */
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
#if (DEVSZ != 22)
|
#if (DEVSZ != 22)
|
||||||
#error "DEVSZ value does not fit sscanf restrictions!"
|
#error "DEVSZ value does not fit sscanf restrictions!"
|
||||||
#endif
|
#endif
|
||||||
#if (TIMESZ != 22)
|
#if (TIMESZ != 25)
|
||||||
#error "TIMESZ value does not fit sscanf restrictions!"
|
#error "TIMESZ value does not fit sscanf restrictions!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ int main(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sscanf(buf, "%21s %21s %6299s", timestamp, device, afrbuf) != 3)
|
if (sscanf(buf, "%24s %21s %6299s", timestamp, device, afrbuf) != 3)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
mtu = parse_canframe(afrbuf, &cu);
|
mtu = parse_canframe(afrbuf, &cu);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue