diff --git a/asc2log.c b/asc2log.c index 51d174e..483cc91 100644 --- a/asc2log.c +++ b/asc2log.c @@ -72,6 +72,8 @@ void print_usage(char *prg) void prframe(FILE *file, struct timeval *tv, int dev, struct canfd_frame *cf, unsigned int max_dlen, char *msgdir) { + char buf[CL_CFSZ]; /* max length */ + fprintf(file, "(%ld.%06ld) ", tv->tv_sec, tv->tv_usec); if (dev > 0) @@ -79,9 +81,11 @@ void prframe(FILE *file, struct timeval *tv, int dev, struct canfd_frame *cf, un else fprintf(file, "canX "); - fprintf(file, "%s ", msgdir); + sprint_canframe(buf, cf, 0, max_dlen); + fprintf(file, "%-25s ", buf); + + fprintf(file, "%s \n", msgdir); - fprint_canframe(file, cf, "\n", 0, max_dlen); } void get_can_id(struct canfd_frame *cf, char *idstring, int base) { diff --git a/candump.c b/candump.c index fb0e75d..08c73c1 100644 --- a/candump.c +++ b/candump.c @@ -706,9 +706,9 @@ int main(int argc, char **argv) /* log CAN frame with absolute timestamp & device */ sprint_canframe(buf, &frame, 0, maxdlen); - fprintf(logfile, "(%010ld.%06ld) %*s %s %s\n", + fprintf(logfile, "(%010ld.%06ld) %*s %-25s %s\n", tv.tv_sec, tv.tv_usec, - max_devname_len, devname[idx], (msg.msg_flags & MSG_DONTROUTE)?"Tx":"Rx", buf); + max_devname_len, devname[idx], buf, (msg.msg_flags & MSG_DONTROUTE)?"Tx":"Rx"); } if ((logfrmt) && (silent == SILENT_OFF)){ diff --git a/log2asc.c b/log2asc.c index 4307f1d..f909c14 100644 --- a/log2asc.c +++ b/log2asc.c @@ -227,10 +227,14 @@ int main(int argc, char **argv) continue; if (sscanf(buf, "(%ld.%ld) %s %s %s", &tv.tv_sec, &tv.tv_usec, - device, msgdir, ascframe) != 5) { + device, ascframe,msgdir) != 5) { + sscanf("Rx", "%s", msgdir); /* To support candump log file without Rx/Tx info */ + if (sscanf(buf, "(%ld.%ld) %s %s", &tv.tv_sec, &tv.tv_usec, + device, ascframe) != 4) { fprintf(stderr, "incorrect line format in logfile\n"); return 1; } + } if (!start_tv.tv_sec) { /* print banner */ start_tv = tv;