Commit Graph

33 Commits (d294cd928c363965e989863be99d30b50bb07d9f)

Author SHA1 Message Date
Oliver Hartkopp dd16f2603b can-utils: make local functions static
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-12 20:10:00 +01:00
Oliver Hartkopp 8535b1d217 log2asc: print error message if no valid CAN CC/FD frame is received
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-12 19:38:04 +01:00
Oliver Hartkopp 29290505f7 log: finalize unified buffer handling
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-29 08:41:21 +01:00
Oliver Hartkopp 1da219922d unify buffer size for ASCII CAN frame string representations
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-29 07:10:34 +01:00
Oliver Hartkopp 34a1cfad29 lib: make parse_canframe CAN XL aware
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-28 22:00:19 +01:00
TyK ceda93bd5c timestamp formatting: always use 64-bit for timesstamp formatting.
Using C99 `unsigned long long` to format `struct timeval`'s `tv_sec`
and `tv_usec`, fix incorrect print under some 32bit platform which
 using time64.
2023-11-28 08:30:27 +08:00
Oliver Hartkopp 58083ad34a log2asc: fix logfiles where the timestamp starts with zero
The ASC file banner, e.g.

    date Thu Jan  1 01:00:00 1970
    base hex  timestamps absolute
    no internal events logged

should be printed when the first timestamp from the logfile has been
processed. But for logfiles starting with zero (e.g. candump -tz option)
this banner is printed every time the timestamps seconds equals zero.

As it was obviously not a good idea to stick the condition for printing
the banner based on some assumption about the timestamp a new variable
'print_banner' has been introduced.

Reported-by: https://github.com/CaSchmidt
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-06-12 10:16:08 +02:00
Oliver Hartkopp 81e76a7a0d log asc converter: support len8_dlc for Classical CAN frames part 2
In commit 6799180bd0 ("log asc converter: support len8_dlc for Classical
CAN frames") the len8_dlc support was accidentally only implemented for
the new CANFD asc format. This patch adds len8_dlc support for the 'old'
Classical CAN asc format which in fact always supported len8_dlc.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-05-01 13:47:57 +02:00
Oliver Hartkopp 972054446a can: rename CAN FD related can_len2dlc and can_dlc2len helpers
The helper functions can_len2dlc and can_dlc2len are only relevant for
CAN FD data length code (DLC) conversion.

Update to latest in-kernel naming scheme:

can_dlc2len -> can_fd_dlc2len to get the payload length from the DLC
can_len2dlc -> can_fd_len2dlc to get the DLC from the payload length

Suggested-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 19:54:58 +01:00
Oliver Hartkopp 6799180bd0 log asc converter: support len8_dlc for Classical CAN frames
The CANFD format in asc logfiles can be used to describe Classical CAN
frame content too. As this CANFD format has two different elements to
transport the payload length and the 'raw data length code' the new
len8_dlc option now allows to support the full qualified conversion.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 19:47:24 +01:00
Marc Kleine-Budde 4573e852f9 log2asc: fix spelling
Fixes: 61dbb56ef6 ("log2asc: support DLC values in Classic CAN RTR frames")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-19 20:52:05 +02:00
Rosen Penev b153fe3f35
clang-tidy: sort includes alphabetically
Found with llvm-include-order

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-10-12 23:28:58 -07:00
Oliver Hartkopp 7cb3e760fe logfile: add new extra info field
This patch adds a fourth string field in the can logfile format.
This new field contains the rx/tx direction information R/T as the
first entry (only one character separated from the CAN frame by space).

To generate the logfile format with this extra field candump has to be
called with the '-x' option for extra message infos,
e.g. 'candump -x -l can0' or 'candump -x -L can0'

log2asc and asc2log are extended to support the direction information
but still support the previous format without direction information.

The format extension does not affect legacy tools, e.g. the existing
canplayer ignores this extra information and does not need to be changed.

Therefore the existing logfiles remain valid and usable.

The extra message infos will be colon separated when there's need for
additional content beyond the rx/tx direction information, e.g. R:xx:yyy

Suggested-by: Pallavi Revanna https://github.com/brpallu
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-08-18 13:29:36 +02:00
Oliver Hartkopp a4905ed7c8 fix timeval to ASCII unsigned value conversion
As reported by Oleksij Rempel here
https://github.com/linux-can/can-utils/issues/233#issuecomment-674818935
the representation of timeval timestamps are signed values which leads to
negative values on 32 bit machines addressing the year 2038 unix sec counter
overflow.

Fix the issue on 32 bit systems by converting the timeval values to unsigned
ASCII value representations.

Fixes: https://github.com/linux-can/can-utils/issues/234
Reported-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-08-18 12:51:35 +02:00
Gary Bisson 46895a41c5 Fix comparison type mismatch warnings
Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
2020-05-28 20:54:37 +02:00
Oliver Hartkopp 61dbb56ef6 log2asc: support DLC values in Classic CAN RTR frames
RTR frames contain a valid DLC value which has not been exposed in the
ASC file format since v8.5 of the tools.

So log2asc will expose this DLC value by default which can be changed
by applying the '-r' option to create the former format.

It can be assumed that the tools pre v8.5 will ignore the value but
if not this switch will make sure to create the old format.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-10 11:45:03 +02:00
Oliver Hartkopp 3014d390b4 log2asc: support CANFD format also for Classic CAN
The CANFD tagged format also supports the encapsulation of Classic CAN
frames which is selected when logging on CAN FD capable CAN interfaces.

With a new option '-f' this CANFD format is selected.

Although this representation is even more inefficient it is seems to be
the common way and increases the readability for mixed CAN/CANFD logs.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-10 11:22:05 +02:00
Oliver Hartkopp 9a079942cd 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>
2020-05-09 22:08:19 +02:00
Oliver Hartkopp ed9c646608 log2asc: reorder code to prepare CAN FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-09 19:04:53 +02:00
Alexander Gerasiov 8e6c11128d log2asc.c: Reformat help/usage output to be compatible with help2man.
Signed-off-by: Alexander Gerasiov <gq@debian.org>

Gbp-Pq: Name 0022-log2asc.c-Reformat-help-usage-output-to-be-compatibl.patch
2020-04-27 08:20:09 +03:00
Yegor Yefremov 7b7331976a Add SPDX identifiers
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-06-19 12:24:24 +02:00
Yegor Yefremov 48a0fdb941 log2asc: include sys/time.h
Without this patch compilation against musl C library
breaks, because struct timeval cannot be found.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2015-07-22 21:12:44 +02:00
Robert Schwebel b9f211319d janitorial: log2asc: properly close infile and outfile
Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2015-03-06 10:02:35 +01:00
Oliver Hartkopp 836d3cc012 remove obsolete SVN ID tags
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 20:57:16 +01:00
Oliver Hartkopp e7631bd7f9 canfd: upgrade tools to support CAN FD for Linux 3.6
This is a major upgrade of the basic tools to handle CAN FD frames.
The library to parse and print CAN frames and logfiles has been extended.

In detail:

 asc2log.c      |    5 +
 candump.c      |   24 ++++---
 cangen.c       |  172 +++++++++++++++++++++++++++++++++------------------
 canlogserver.c |   28 +++++---
 canplayer.c    |   25 ++++---
 cansend.c      |   55 ++++++++++++----
 lib.c          |  189 ++++++++++++++++++++++++++++++++++++++-------------------
 lib.h          |  109 ++++++++++++++++++++++++--------
 log2asc.c      |    8 +-
 log2long.c     |   26 ++++++-
 10 files changed, 440 insertions(+), 201 deletions(-)

asc2log.c / log2asc.c
- updates for new lib functions
- still can only handle CAN2.0 frames (no new info about ASC file layout)

log2long.c / canlogserver.c / canplayer.c
- updates for new lib functions to handle CAN FD

lib.h / lib.c
- reworked lib functions to handle CAN FD
- parse_canframe() now returns CAN_MTU and CANFD_MTU on success, 0 at failure
- added can_dlc2len() and can_len2dlc() helpers
- moved hexstring2candata to hexstring2data to support simple byte buffers
- in the long CAN frame representation use %03X/%08X instead of %3X/%8X
- introduced unified buffer size definitions for ASCII CAN frames
- updated documentation

cangen.c
- support CAN FD frames (added -f option to create CAN FD frames)
- added -m option ('mix') to create random extended / RTR / CAN FD frames
- fixed the 'fixed data' option which was zero'ing the payload by the time
- updated help text

candump.c
- support CAN FD frames (print, bridge, log)
- distinguish frame types by length info: [0] = CAN2.0 [00] = CAN FD frame

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 19:47:21 +01:00
Marc Kleine-Budde 722a09116d treewide: replace berlios contact email by linux-can@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-01-11 12:14:15 +01:00
Oliver Hartkopp 4369ac1c55 Consistencely allow '-?' to get a help text. 2009-01-13 09:32:45 +00:00
Oliver Hartkopp 4455308aa0 Added support for comments in logfiles.
Added some sanity checks and error messages.
2008-09-09 12:56:05 +00:00
Oliver Hartkopp adbe6f9bee Whitespace fixes. Indented the code following Linux styleguide to fix
the mess between tabs and spaces.
2008-06-03 08:46:57 +00:00
Oliver Hartkopp d0b24ffc10 Fixed contradiction in Sourcecode discalimer.
See details at
http://marc.info/?l=linux-netdev&m=119074747913703&w=2
2007-09-27 12:29:32 +00:00
Oliver Hartkopp 3d26e6f710 Fixed typo in log2asc.c
Added asc2log.c to convert existing CANoe/CANalyser logfiles into socketcan
logfiles (with absolute and full qualified timestamps).
The date and the other settings (dec/hex absolute/relative) are taken from
the head of the ASC files.
2007-01-10 17:18:01 +00:00
Oliver Hartkopp c2424910ac Some new ASC files support 6 digits in decimal place.
Added new option '-4' to generate 'old-style' ASC files.
2007-01-09 16:01:46 +00:00
Oliver Hartkopp f95fc47ec8 - added error frame support in lib.c
- added sprint_* functions for CAN-frame output in lib.c / lib.h
- added comments / cosmetics

candump.c:
- removed support for the output in ASC representation (moved to log2asc.c)
- added option '-l' for logfile creation e.g. 'candump-2007-01-01_164123.log'
- added funtionality to terminate candump by pressing [ENTER] (not only ^C)
- added error frame support
- added color support even when reading from 'any'
- three different color levels (e.g. -c -c -c)
- making use if lib.c

cangen.c:
-  CAN frames generator for testing purposes (e.g. on vcanx)
(nice when you're on vacancy at the baltic sea and have no real CAN source :)

log2long.c:
- convert compact CAN frame representation into user readable representation

log2asc.c:
- convert compact CAN frame logfile to ASC logfile for 3rd party CAN tools

Next step: Create a tool to replay candump logfiles.
2007-01-01 18:29:52 +00:00