asc2log: prepare helper functions for CAN XL frame handling
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>pull/573/head
parent
cb5ab07f34
commit
df8e08fa70
24
asc2log.c
24
asc2log.c
|
|
@ -72,7 +72,7 @@ static void print_usage(char *prg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prframe(FILE *file, struct timeval *tv, int dev,
|
static void prframe(FILE *file, struct timeval *tv, int dev,
|
||||||
struct canfd_frame *cf, char *extra_info)
|
cu_t *cf, char *extra_info)
|
||||||
{
|
{
|
||||||
static char abuf[BUFLEN];
|
static char abuf[BUFLEN];
|
||||||
|
|
||||||
|
|
@ -83,19 +83,19 @@ static void prframe(FILE *file, struct timeval *tv, int dev,
|
||||||
else
|
else
|
||||||
fprintf(file, "canX ");
|
fprintf(file, "canX ");
|
||||||
|
|
||||||
snprintf_canframe(abuf, sizeof(abuf), (cu_t *)cf, 0);
|
snprintf_canframe(abuf, sizeof(abuf), cf, 0);
|
||||||
fprintf(file, "%s%s", abuf, extra_info);
|
fprintf(file, "%s%s", abuf, extra_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_can_id(struct canfd_frame *cf, char *idstring, int base)
|
static void get_can_id(canid_t *can_id, char *idstring, int base)
|
||||||
{
|
{
|
||||||
if (idstring[strlen(idstring)-1] == 'x') {
|
if (idstring[strlen(idstring)-1] == 'x') {
|
||||||
cf->can_id = CAN_EFF_FLAG;
|
*can_id = CAN_EFF_FLAG;
|
||||||
idstring[strlen(idstring)-1] = 0;
|
idstring[strlen(idstring)-1] = 0;
|
||||||
} else
|
} else
|
||||||
cf->can_id = 0;
|
*can_id = 0;
|
||||||
|
|
||||||
cf->can_id |= strtoul(idstring, NULL, base);
|
*can_id |= strtoul(idstring, NULL, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calc_tv(struct timeval *tv, struct timeval *read_tv,
|
static void calc_tv(struct timeval *tv, struct timeval *read_tv,
|
||||||
|
|
@ -162,7 +162,7 @@ static void eval_can(char* buf, struct timeval *date_tvp, char timestamps,
|
||||||
cf.len = CAN_ERR_DLC;
|
cf.len = CAN_ERR_DLC;
|
||||||
|
|
||||||
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
|
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
|
||||||
prframe(outfile, &tv, interface, &cf, "\n");
|
prframe(outfile, &tv, interface, (cu_t *)&cf, "\n");
|
||||||
fflush(outfile);
|
fflush(outfile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -205,9 +205,9 @@ static void eval_can(char* buf, struct timeval *date_tvp, char timestamps,
|
||||||
|
|
||||||
/* check for CAN ID with (hexa)decimal value */
|
/* check for CAN ID with (hexa)decimal value */
|
||||||
if (base == 'h')
|
if (base == 'h')
|
||||||
get_can_id(&cf, tmp1, 16);
|
get_can_id(&cf.can_id, tmp1, 16);
|
||||||
else
|
else
|
||||||
get_can_id(&cf, tmp1, 10);
|
get_can_id(&cf.can_id, tmp1, 10);
|
||||||
|
|
||||||
/* dlc > 8 => len == CAN_MAX_DLEN => fill len8_dlc value */
|
/* dlc > 8 => len == CAN_MAX_DLEN => fill len8_dlc value */
|
||||||
if (dlc > CAN_MAX_DLC)
|
if (dlc > CAN_MAX_DLC)
|
||||||
|
|
@ -236,7 +236,7 @@ static void eval_can(char* buf, struct timeval *date_tvp, char timestamps,
|
||||||
cf.data[i] = data[i] & 0xFFU;
|
cf.data[i] = data[i] & 0xFFU;
|
||||||
|
|
||||||
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
|
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
|
||||||
prframe(outfile, &tv, interface, &cf, extra_info);
|
prframe(outfile, &tv, interface, (cu_t *)&cf, extra_info);
|
||||||
fflush(outfile);
|
fflush(outfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -311,7 +311,7 @@ static void eval_canfd(char* buf, struct timeval *date_tvp, char timestamps,
|
||||||
if (dlen != can_fd_dlc2len(can_fd_len2dlc(dlen)))
|
if (dlen != can_fd_dlc2len(can_fd_len2dlc(dlen)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
get_can_id(&cf, tmp1, 16);
|
get_can_id(&cf.can_id, tmp1, 16);
|
||||||
|
|
||||||
/* now search for the beginning of the data[] content */
|
/* now search for the beginning of the data[] content */
|
||||||
sprintf(tmp1, " %x %x %x %2d ", brs, esi, dlc, dlen);
|
sprintf(tmp1, " %x %x %x %2d ", brs, esi, dlc, dlen);
|
||||||
|
|
@ -377,7 +377,7 @@ static void eval_canfd(char* buf, struct timeval *date_tvp, char timestamps,
|
||||||
}
|
}
|
||||||
|
|
||||||
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
|
calc_tv(&tv, &read_tv, date_tvp, timestamps, dplace);
|
||||||
prframe(outfile, &tv, interface, &cf, extra_info);
|
prframe(outfile, &tv, interface, (cu_t *)&cf, extra_info);
|
||||||
fflush(outfile);
|
fflush(outfile);
|
||||||
|
|
||||||
/* No support for really strange CANFD ErrorFrames format m( */
|
/* No support for really strange CANFD ErrorFrames format m( */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue