log2asc: support CANFD asc file generation
The CANFD asc format adds information about the CAN controllers bitrate settings, CRCs and message length (in bits) and its duration. The plan is to provide static values for these attributes that we can not get from the log file anyway and stay on the 'old style' format for classic CAN frames - which has been successfully tested on the latest tools. The remaining drawback is that the 'old style' format is not able to provide a DLC information for RTR frames. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>pull/203/head
parent
ed9c646608
commit
9a079942cd
34
log2asc.c
34
log2asc.c
|
|
@ -97,6 +97,36 @@ void can_asc(struct canfd_frame *cf, int devno, FILE *outfile)
|
|||
|
||||
void canfd_asc(struct canfd_frame *cf, int devno, FILE *outfile)
|
||||
{
|
||||
int i;
|
||||
char id[10];
|
||||
unsigned int flags;
|
||||
|
||||
fprintf(outfile, "CANFD %3d Rx ", devno); /* 3 column channel number right aligned */
|
||||
|
||||
sprintf(id, "%X%c", cf->can_id & CAN_EFF_MASK,
|
||||
(cf->can_id & CAN_EFF_FLAG)?'x':' ');
|
||||
fprintf(outfile, "%11s ", id);
|
||||
fprintf(outfile, "%c ", (cf->flags & CANFD_BRS)?'1':'0');
|
||||
fprintf(outfile, "%c ", (cf->flags & CANFD_ESI)?'1':'0');
|
||||
fprintf(outfile, "%x ", can_len2dlc(cf->len));
|
||||
fprintf(outfile, "%2d", cf->len);
|
||||
|
||||
for (i = 0; i < cf->len; i++) {
|
||||
fprintf(outfile, " %02X", cf->data[i]);
|
||||
}
|
||||
|
||||
/* relevant flags in Flags field */
|
||||
#define ASC_F_FDF 0x00001000
|
||||
#define ASC_F_BRS 0x00002000
|
||||
#define ASC_F_ESI 0x00004000
|
||||
|
||||
flags = ASC_F_FDF;
|
||||
if (cf->flags & CANFD_BRS)
|
||||
flags |= ASC_F_BRS;
|
||||
if (cf->flags & CANFD_ESI)
|
||||
flags |= ASC_F_ESI;
|
||||
|
||||
fprintf(outfile, " %8d %4d %8X 0 0 0 0 0", 130000, 130, flags);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
@ -196,6 +226,10 @@ int main(int argc, char **argv)
|
|||
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))
|
||||
continue;
|
||||
|
||||
tv.tv_sec = tv.tv_sec - start_tv.tv_sec;
|
||||
tv.tv_usec = tv.tv_usec - start_tv.tv_usec;
|
||||
if (tv.tv_usec < 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue