mirror of
https://github.com/linux-can/can-utils.git
synced 2026-09-22 16:09:52 +02:00
lib: make parse_canframe CAN XL aware
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
@@ -183,9 +183,9 @@ void canfd_asc(struct canfd_frame *cf, int devno, int mtu, char *extra_info, FIL
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
static char buf[BUFSZ], device[BUFSZ], ascframe[BUFSZ], extra_info[BUFSZ];
|
||||
static char buf[BUFSZ], device[BUFSZ], ascframe[10000], extra_info[BUFSZ];
|
||||
|
||||
struct canfd_frame cf;
|
||||
static cu_t cu;
|
||||
static struct timeval tv, start_tv;
|
||||
FILE *infile = stdin;
|
||||
FILE *outfile = stdout;
|
||||
@@ -286,20 +286,23 @@ int main(int argc, char **argv)
|
||||
(crlf)?"\r\n":"\n");
|
||||
}
|
||||
|
||||
for (i=0, devno=0; i<maxdev; i++) {
|
||||
for (i = 0, devno = 0; i < maxdev; i++) {
|
||||
if (!strcmp(device, argv[optind+i])) {
|
||||
devno = i+1; /* start with channel '1' */
|
||||
devno = i + 1; /* start with channel '1' */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (devno) { /* only convert for selected CAN devices */
|
||||
mtu = parse_canframe(ascframe, &cf);
|
||||
|
||||
mtu = parse_canframe(ascframe, &cu);
|
||||
|
||||
/* convert only CAN CC and CAN FD frames */
|
||||
if ((mtu != CAN_MTU) && (mtu != CANFD_MTU))
|
||||
return 1;
|
||||
|
||||
/* we don't support error message frames in CAN FD */
|
||||
if ((mtu == CANFD_MTU) && (cf.can_id & CAN_ERR_FLAG))
|
||||
if ((mtu == CANFD_MTU) && (cu.cc.can_id & CAN_ERR_FLAG))
|
||||
continue;
|
||||
|
||||
tv.tv_sec = tv.tv_sec - start_tv.tv_sec;
|
||||
@@ -315,9 +318,9 @@ int main(int argc, char **argv)
|
||||
fprintf(outfile, "%4llu.%06llu ", (unsigned long long)tv.tv_sec, (unsigned long long)tv.tv_usec);
|
||||
|
||||
if ((mtu == CAN_MTU) && (fdfmt == 0))
|
||||
can_asc(&cf, devno, nortrdlc, extra_info, outfile);
|
||||
can_asc(&cu.fd, devno, nortrdlc, extra_info, outfile);
|
||||
else
|
||||
canfd_asc(&cf, devno, mtu, extra_info, outfile);
|
||||
canfd_asc(&cu.fd, devno, mtu, extra_info, outfile);
|
||||
|
||||
if (crlf)
|
||||
fprintf(outfile, "\r");
|
||||
|
||||
Reference in New Issue
Block a user