Commit Graph

57 Commits (c5fd57df344710cbe7363079504de5d6f6a2e79d)

Author SHA1 Message Date
Oliver Hartkopp 33640c8643 candump: make hardware timestamps Linux version agnostic
Hardware timestamps have been introduced in Linux 2.6.30. Check for the
availability of SO_TIMESTAMPING and print an appropriate error message if
missing. Additionally fix some style issues and define the proper length
of ctrlmsg[].

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-12-06 10:16:09 +01:00
Fabián Inostroza eeb0dc2390 Fix style and add reference to timestamps struct offset. 2017-12-02 16:43:52 -03:00
Fabián Inostroza 3195717961 Remove deprecated flag. See timestamping.txt 2017-12-02 16:07:04 -03:00
Fabián Inostroza fbebc61881 Add option to read hardware timestamps. 2017-12-02 03:33:43 -03:00
Oliver Hartkopp 4c8fb05cb4 can-utils: remove strict-aliasing compiler warning
GitHub user 'crossband' raised an issue regarding the strict-aliasing compiler
warning in his specific setup: https://github.com/linux-can/can-utils/issues/42

In fact memcpy() and memset() are a better solution than the former pointer
magics, so remove the issues and the compiler warning flag too.

Reported-by: crossband (https://github.com/crossband)
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-07-01 19:01:01 +02:00
Oliver Hartkopp cddb2612b1 candump: print correct interface names on stderr
The cmdlinename[i] output contains the filter definitions e.g.
'can0,300:700' but you want to see only 'can0' when printing on stderr.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2016-08-31 19:14:07 +02:00
ajneu 7a9e10173a don't exit when device goes down 2016-08-30 20:04:39 +02:00
Oliver Hartkopp 47fbe8fec2 candump: check for joined filter support at runtime
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-04-01 12:58:27 +02:00
Oliver Hartkopp 1a2467ed29 candump: support new raw socket option to join the given CAN filters
The CAN_RAW socket can set multiple CAN identifier specific filters that lead
to multiple filters in the af_can.c filter processing. These filters are
indenpendent from each other which leads to logical OR'ed filters when applied.

This socket option joines the given CAN filters in the way that only CAN frames
are passed to user space that matched *all* given CAN filters. The semantic for
the applied filters is therefore changed to a logical AND.

This is useful especially when the filterset is a combination of filters where
the CAN_INV_FILTER flag is set in order to notch single CAN IDs or CAN ID
ranges from the incoming traffic.

Example:
	candump can0,100~7FF,200~7FF,400~7FF	(logical OR'ed filters)
	candump can0,100~7FF,200~7FF,400~7FF,J	(logical AND'ed filters)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-03-17 20:30:54 +01:00
Urs Thuermann 0c61f2ac4c candump: fix off-by-one error in dropcount calculation
Calculations using unsigned integer types are done modulo U*INT_MAX+1,
so you get the correct difference of two values by simply subtracting.
No special handling for overflow is neccessary.

Signed-off-by: Urs Thuermann <urs@isnogud.escape.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-10-23 19:27:09 +02:00
Oliver Hartkopp 53779e43eb candump: use UINT32_MAX define from stdint.h
Use the UINT32_MAX define from stdint.h instead of writing it into a comment.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-05-24 21:44:51 +02:00
Oliver Hartkopp 31ccf45dc4 candump: reduce printf calls for logfile format
The creation of the logfile format was using fprint_canframe() and two other
fprintf() calls to produce a single logfile format line. Instead of using
fprint_canframe() use sprint_canframe() directly and reduce the printf() calls
from three to one.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-05-05 21:29:56 +02:00
Uwe Kleine-König 03c1bacfde can-utils: trivial: fix typos concerning "separation" and "useful"
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-08-15 21:09:27 +02:00
Alexander Stein e5c81aa221 candump: Add timeout option if no message has been received
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-02-12 17:56:35 +01:00
Oliver Hartkopp d547068185 candump: unify displayed timestamp length to 10 digits
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-24 21:31:01 +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 d166ecc8a3 candump: new option to print extra message information
Added -x option to print extra message infos per frame:

  RX/TX : Indicates whether the frame was sent or received from the local host
  BRS   : bit rate setting enabled (CAN FD only)
  ESI   : error state indicator (CAN FD only)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 20:06:50 +01:00
Oliver Hartkopp fcbdf71f1a Add new format option when mixing EFF/SFF frame output
Added new view CANLIB_VIEW_INDENT_SFF flags to fix the sloppy output of
fprint_long_canframe() when mixing EFF & SFF CAN identifiers.

candump: Once an EFF frame is detected the indention is enabled.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 19:59:18 +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
Yegor Yefremov 5d2964c5ff Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-04-19 17:39:53 +02: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
Wolfgang Grandegger 796475677a candump: add option -e to dump error messages in human readable format
If "candump" is called with the option "-e", the error messages are
dumped in human readable format:

  # candump -e any,0:0,#FFFFFFFF
  ...
  can0  20000088  [8] 00 00 80 19 00 00 00 00   ERRORFRAME
        protocol-violation{{error-on-tx}{acknowledge-slot}}
        bus-error
        error-counter{tx{128}rx{97}}
  ...
  can0  2000008C  [8] 00 08 80 19 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-warning}
        protocol-violation{{error-on-tx}{acknowledge-slot}}
        bus-error
        error-counter{tx{128}rx{97}}

"candump" actually calles a library function snprintf_can_error_frame()
to do the formatting. It could be used for other purposes as well.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Acked-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
2011-02-14 15:49:27 +00:00
Oliver Hartkopp c9e79e55c3 candump: Avoid ragged output of timestamp values when printing differential
timestamps (commandline option -td).
Idea & original patch by Uwe Bonnes.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2011-01-19 17:43:07 +00:00
Oliver Hartkopp 3a9baeda05 candump: Added '-u <usecs>' commandline option to delay bridged CAN frames by
usecs microseconds.
2010-11-29 19:11:11 +00:00
Oliver Hartkopp d3468d907f Fix datatype issue in sscanf() on 64bit systems.
On 64bit systems a 'long' is a 64bit value but the target values of scanf()
are always 32bit in the affected code - which means just an 'unsigned int'.
Unsigned int is fine on 32 and 64 bit systems.

Thanks to Andre Naujoks for reporting this issue.
2010-09-25 10:24:37 +00:00
Oliver Hartkopp 9327499121 Try to ignore the usual value restrictions of sockopt SO_RCVBUF when running
as root (with CAP_NET_ADMIN) by using SO_RCVBUFFORCE if possible.
2010-01-15 19:15:08 +00:00
Oliver Hartkopp 3c019ea611 Added '-d' option to support the receive packet drop counting introduced in
http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=3b885787ea4112eaa80945999ea0901bf742707f

This is done by using recvmsg() instead of recvfrom() to allow the timestamp
and the dropcounter to be received within one syscall.

When the application (here 'candump') ist not fast enough to process the
incomming CAN frames the frames are dropped in the socket receive queue.
When this happens and '-d' is set, we get this info now:
DROPCOUNT: dropped 1 CAN frame on 'xxx' socket (total drops 1)
2010-01-15 18:35:37 +00:00
Oliver Hartkopp e765683c9b Added commandline option '-r' to set the per-socket receive buffer size. 2009-04-16 08:05:42 +00:00
Oliver Hartkopp bc9fb643a3 Removed the limitation for the number of CAN filters for each interface.
Updated Copyright notice.
And finally: Yeah! I did something with malloc :-)
2009-04-06 11:15:27 +00:00
Oliver Hartkopp 3e65a4e564 Add functionality to
terminate after receiption of <count> CAN frames.
2009-04-06 08:41:17 +00:00
Oliver Hartkopp 278ba6377d disable default receive filter on the write-only bridge socket. 2009-01-06 09:04:34 +00:00
Oliver Hartkopp 6104197c6a Fix sloppy CAN_(EFF|RTR)_FLAG handling in can_filter.can_mask .
Due to a wrong safety check in af_can.c it was not possible to filter 
for SFF frames with a specific CAN identifier without getting the 
same selected CAN identifier from a received EFF frame also.

This fix has a minimum impact on the CAN filter API as the 'sloppy' 
handling is still a correct (and possibly wanted?) use-case.

Please update the can-utils (especially candump) whose filter definition 
on the commandline made assumptions to correct the user input that are 
probably unwanted now.

Thanks to Kurt van Dijck for pointing at this issue!

Signed-Off-by: Oliver Hartkopp <oliver@hartkopp.net>
2008-12-01 07:24:18 +00:00
Oliver Hartkopp 265021e323 Print non-data stuff (errors, warnings, hints) on stderr. 2008-10-29 09:41:40 +00:00
Oliver Hartkopp 1be68bcc64 Added support for swapped byte order representation. 2008-10-29 09:23:48 +00:00
Oliver Hartkopp b5bc6349a9 Start candump in silent mode, when logging into a file. 2008-10-02 13:47:43 +00:00
Oliver Hartkopp af472581eb Do not allow to create error frame filters via standard filter sets. 2008-07-02 04:19:07 +00:00
Oliver Hartkopp f1c095d801 Added automatic extended frame format recognition.
Most SocketCAN userspace tools (like cansend) recognize the EFF by the 
stringlength of the given CAN-ID: 3 -> SFF , 8 -> EFF.
This was missing in the candump filter definition and therefore the 
values had to be specified with the CAN_EFF_FLAG set in the value, e.g.
92345678 for the extended CAN-ID 12345678 - this was not really nice.

Now the filtersets for extended frames can be specified as expected:
12345678:1FFFFFFF to filter for only 12345678 extended CAN-ID
000000AA:1FFFFFFF to filter for only AA extended CAN-ID.
2008-07-02 04:05:11 +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 8a5c0365e6 Added binary output option to candump.c and sprint_long_canframe() in lib.c . 2008-06-02 20:06:37 +00:00
Oliver Hartkopp 5769d708e4 Updated new 'cangen' and 'candump' in the trunk. 2008-05-05 12:20:34 +00:00
Oliver Hartkopp 770eeeaf23 Allow commandline option '-?' to print the help text. 2008-03-13 21:52:20 +00:00
Oliver Hartkopp 8891e44d28 Updated help text for commandline options. 2008-03-13 21:44:20 +00:00
Oliver Hartkopp e47a1b4b26 Changed color order at colorized output.
Remove index cache zombies when unloading CAN drivers.
Modified index cache failure message.
2007-11-20 18:37:30 +00:00
Oliver Hartkopp d72681c442 Reverted most of the changes since r500 except the changes in
drivers/net/can/* after discussion with Urs.
TODO: Documentation & new Version.
2007-10-01 05:48:50 +00:00
Oliver Hartkopp 6689e9600d Changed loopback to echo in CAN RAW sockets. The binary interface does
not change through this renaming of CAN_RAW_LOOPBACK to CAN_RAW_ECHO.
2007-09-30 13:00:42 +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 44fb4089c3 Update outdated comment. 2007-09-21 07:21:24 +00:00
Oliver Hartkopp 5723c5ce86 Added new commandline option '-B' which acts like the bridging option '-b' but
disables the local loopback functionality (for ECU analysis and MITM-attacks :)
Fixed missing fflush().
2007-05-30 07:20:18 +00:00
Oliver Hartkopp 33e6337cde Added missing initialisation to prevent a gcc warning. 2007-05-09 07:33:34 +00:00
Oliver Hartkopp 892c0d9e7d Removed possibility to terminate candump with an input from stdin.
Therefore it can be used in scripts now, e.g. for CAN-frame bridging:
   candump can1 -mFFF -v123 -b can3 -s 2 &
Use CTRL-C to terminate candump.
2007-02-09 09:53:16 +00:00