- while (fgets(buf, 99, infile)) {
-
- if (!dplace) { /* the representation of a valid CAN frame not known */
-
- /* check for base and timestamp entries in the header */
- if ((!base) &&
- (sscanf(buf, "base %s timestamps %s", tmp1, tmp2) == 2)) {
- base = tmp1[0];
- timestamps = tmp2[0];
- if (verbose)
- printf("base %c timestamps %c\n", base, timestamps);
- if ((base != 'h') && (base != 'd')) {
- printf("invalid base %s (must be 'hex' or 'dez')!\n",
- tmp1);
- return 1;
- }
- if ((timestamps != 'a') && (timestamps != 'r')) {
- printf("invalid timestamps %s (must be 'absolute'"
- " or 'relative')!\n", tmp2);
- return 1;
- }
- continue;
- }
-
- /* check for the original logging date in the header */
- if ((!date_tv.tv_sec) &&
- (!strncmp(buf, "date", 4))) {
-
- if (get_date(&date_tv, &buf[9])) { /* skip 'date day ' */
- fprintf(stderr, "Not able to determine original log "
- "file date. Using current time.\n");
- /* use current date as default */
- gettimeofday(&date_tv, NULL);
- }
- if (verbose)
- printf("date %ld => %s", date_tv.tv_sec, ctime(&date_tv.tv_sec));
- continue;
- }
-
- /* check for decimal places length in valid CAN frames */
- if (sscanf(buf, "%ld.%s %d ", &tv.tv_sec, tmp2, &i) == 3){
- dplace = strlen(tmp2);
- if (verbose)
- printf("decimal place %d, e.g. '%s'\n", dplace, tmp2);
- if ((dplace != 4) && (dplace != 6)) {
- printf("invalid dplace %d (must be 4 or 6)!\n", dplace);
- return 1;
+ while (fgets(buf, 99, infile)) {
+
+ if (!dplace) { /* the representation of a valid CAN frame not known */
+
+ /* check for base and timestamp entries in the header */
+ if ((!base) &&
+ (sscanf(buf, "base %s timestamps %s", tmp1, tmp2) == 2)) {
+ base = tmp1[0];
+ timestamps = tmp2[0];
+ if (verbose)
+ printf("base %c timestamps %c\n", base, timestamps);
+ if ((base != 'h') && (base != 'd')) {
+ printf("invalid base %s (must be 'hex' or 'dez')!\n",
+ tmp1);
+ return 1;
+ }
+ if ((timestamps != 'a') && (timestamps != 'r')) {
+ printf("invalid timestamps %s (must be 'absolute'"
+ " or 'relative')!\n", tmp2);
+ return 1;
+ }
+ continue;
+ }
+
+ /* check for the original logging date in the header */
+ if ((!date_tv.tv_sec) &&
+ (!strncmp(buf, "date", 4))) {
+
+ if (get_date(&date_tv, &buf[9])) { /* skip 'date day ' */
+ fprintf(stderr, "Not able to determine original log "
+ "file date. Using current time.\n");
+ /* use current date as default */
+ gettimeofday(&date_tv, NULL);
+ }
+ if (verbose)
+ printf("date %ld => %s", date_tv.tv_sec, ctime(&date_tv.tv_sec));
+ continue;
+ }
+
+ /* check for decimal places length in valid CAN frames */
+ if (sscanf(buf, "%ld.%s %d ", &tv.tv_sec, tmp2, &i) == 3){
+ dplace = strlen(tmp2);
+ if (verbose)
+ printf("decimal place %d, e.g. '%s'\n", dplace, tmp2);
+ if (dplace < 4 || dplace > 6) {
+ printf("invalid dplace %d (must be 4, 5 or 6)!\n", dplace);
+ return 1;
+ }
+ } else
+ continue; /* dplace remains zero until first found CAN frame */
+ }
+
+ /* the representation of a valid CAN frame is known here */
+ /* so try to get CAN frames and ErrorFrames and convert them */
+
+ /* 0.002367 1 390x Rx d 8 17 00 14 00 C0 00 08 00 */
+
+ found = 0; /* found valid CAN frame ? */
+
+ if (base == 'h') { /* check for CAN frames with hexadecimal values */
+
+ if (sscanf(buf, "%ld.%ld %d %s %*s %c %d %x %x %x %x %x %x %x %x",
+ &read_tv.tv_sec, &read_tv.tv_usec, &interface,
+ tmp1, &rtr, &dlc,
+ &data[0], &data[1], &data[2], &data[3],
+ &data[4], &data[5], &data[6], &data[7]
+ ) == dlc + 6 ) {
+
+ found = 1;
+ get_can_id(&cf, tmp1, 16);
+ }
+
+ } else { /* check for CAN frames with decimal values */
+
+ if (sscanf(buf, "%ld.%ld %d %s %*s %c %d %d %d %d %d %d %d %d %d",
+ &read_tv.tv_sec, &read_tv.tv_usec, &interface,
+ tmp1, &rtr, &dlc,
+ &data[0], &data[1], &data[2], &data[3],
+ &data[4], &data[5], &data[6], &data[7]
+ ) == dlc + 6 ) {
+
+ found = 1;
+ get_can_id(&cf, tmp1, 10);
+ }