Commit Graph

722 Commits (eb66451df280f95a9a12e78b151b8d867e1b78ed)

Author SHA1 Message Date
Richard Young eb66451df2 candump: Enable zero relative timestamps to be used in log files
The logfile format which is generated with '-l' and '-L' consists of an
absolute epoch timestamp. In some use cases (e.g. for documentation) a
zero relative timestamp can be useful which was only configurable with
the '-tz' option for the classic output.

'-tz' and '-ta' are now valid options for the logfile format.

Signed-off-by: Richard Young <code@richyoung.ca>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-12-08 20:52:54 +01:00
Oliver Hartkopp 682e01a40a isotpsend: add SF_BROADCAST support for functional addressing
When CAN_ISOTP_SF_BROADCAST is set in the CAN_ISOTP_OPTS flags the
CAN_ISOTP socket is switched into functional addressing mode, where
only single frame (SF) protocol data units can be send on the specified
CAN interface and the given tp.tx_id after bind().

In opposite to normal and extended addressing this socket does not
register a CAN-ID for reception which would be needed for a 1-to-1
ISOTP connection with a segmented bi-directional data transfer.

The new option '-S' sets the CAN_ISOTP_SF_BROADCAST to test the option
with different length settings, e.g. link layer data lengths.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-12-06 14:41:48 +01:00
Oliver Hartkopp 280ea436d4 isotp: add define for SF_BROADCAST support
When CAN_ISOTP_SF_BROADCAST is set in the CAN_ISOTP_OPTS flags the
CAN_ISOTP socket is switched into functional addressing mode, where
only single frame (SF) protocol data units can be send on the specified
CAN interface and the given tp.tx_id after bind().

Add the CAN_ISOTP_SF_BROADCAST define from Linux UAPI includes.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-12-06 14:17:36 +01:00
Marc Kleine-Budde 33de12680a
Merge pull request #270 from marckleinebudde/candump-cleanups
Candump cleanups
2020-12-06 10:22:14 +01:00
Marc Kleine-Budde bfaa44fa91 candump: convert to kernel codeing style
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-12-06 10:09:36 +01:00
Marc Kleine-Budde 305b2e8b79 candump: fix indention
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-12-06 09:58:52 +01:00
Marc Kleine-Budde 15f3a2e385 candump: remove trailing whitespace
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-12-06 09:57:52 +01:00
Marc Kleine-Budde aa6411075f
Merge pull request #264 from IDC-Dragon/master
candump: epoll_wait() instead of select() runs faster and better keeps packet order
2020-12-06 09:54:33 +01:00
Marc Kleine-Budde 51d675368d
Merge pull request #269 from timgates42/bugfix_typo_caught
docs: fix simple typo, cought -> caught
2020-12-06 09:53:21 +01:00
Jörg Hohensohn 639498bc80 candump: use epoll_wait() instead of select()
Using epoll_wait() instead of select() gives higher
performance for listening on multiple interfaces.
Additionally, the read order has a higher chance
to resemble the true temporal order.
select() gives implicit priority to the lower index socket.

Signed-off-by: Jörg Hohensohn <joerg.hohensohn@gmx.de>
2020-12-06 08:32:36 +01:00
Tim Gates 333e631286
docs: fix simple typo, cought -> caught
There is a small typo in canlogserver.c.

Should read `caught` rather than `cought`.
2020-12-06 17:31:33 +11:00
Oliver Hartkopp 6a14256323 cansniffer: fix snifftab CAN-ID query
Due to a wrong test to check for existing CAN-IDs in the snifftab
it was not possible to have the CAN-ID '0' in the list and displayed.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-12-02 13:26:42 +01:00
Oliver Hartkopp c3d9cc2027 cangw: support len8_dlc for Classical CAN frames
The can_dlc value that is passed to the kernel is not sanitized in cangw
therefore we only update the help text and some comments in gw.h.

In the case that the CAN interface supports len8_dlc by setting
CAN_CTRLMODE_CC_LEN8_DLC the can-gw module can modify the full DLC value
range (0 .. 15) for Classic CAN frames.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 19:57:27 +01: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
Oliver Hartkopp 11edd1d05e candump: support len8_dlc for standard candump output
The display of Classical CAN raw DLC values is an expert feature which is
not enabled by default to not break toolchains that use the candump
standard output for further processing. (N.B. using the log file format and
the functions from lib.h/lib.c provide convenient CAN frame conversions)

After enabling the raw DLC for Classical CAN with the '-8' option the raw
DLC value is printed in 'unusual' curly braces {}.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 19:42:38 +01:00
Oliver Hartkopp a272fd2082 cansend: add support for Classic CAN raw DLC values
Update help text only as the new extended frame format is already
implemented in lib.h/lib.c

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 19:33:16 +01:00
Oliver Hartkopp 1ba0c576ae cangen: add support for Classic CAN raw DLC values
A new option '-8' has been added to generate Classical CAN frames with
DLC codes from 0 .. 15.

Fixed and random mode implemented by Oliver Hartkopp.
Incremental DLC mode 'cangen -8 -Li can0' implemented by Vincent Mailhol.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 19:13:21 +01:00
Oliver Hartkopp b70d8c050f lib: add support for Classic CAN raw DLC values
ISO 11898-1 Chapter 8.4.2.3 defines a 4 bit data length code (DLC) table which
maps the DLC to the payload length of the CAN frame in bytes:

    DLC      ->  payload length
    0 .. 8   ->  0 .. 8
    9 .. 15  ->  8

To access the raw DLC values 9 .. 15 the len8_dlc element is introduced, which
is only valid when the payload length 'len' is 8 and the DLC is greater than 8.

The extension for len8_dlc has been implemented for the Classic CAN frame
representation in the log file format and for the standard output for
candump where the raw DLC value is printed in 'unusual' curly braces {}.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 18:59:53 +01:00
Oliver Hartkopp c398e56afb can: add optional DLC element to Classical CAN frame structure
ISO 11898-1 Chapter 8.4.2.3 defines a 4 bit data length code (DLC) table which
maps the DLC to the payload length of the CAN frame in bytes:

    DLC      ->  payload length
    0 .. 8   ->  0 .. 8
    9 .. 15  ->  8

Although the DLC values 8 .. 15 in Classical CAN always result in a payload
length of 8 bytes these DLC values are transparently transmitted on the CAN
bus. As the struct can_frame only provides a 'len' element (formerly 'can_dlc')
which contains the plain payload length ( 0 .. 8 ) of the CAN frame, the raw
DLC is not visible to the application programmer, e.g. for testing use-cases.

To access the raw DLC values 9 .. 15 the len8_dlc element is introduced, which
is only valid when the payload length 'len' is 8 and the DLC is greater than 8.

The len8_dlc element is filled by the CAN interface driver and used for CAN
frame creation by the CAN driver when the CAN_CTRLMODE_CC_LEN8_DLC flag is
supported by the driver and enabled via netlink configuration interface.

Reported-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 18:41:38 +01:00
Marc Kleine-Budde d0ad168953
Merge pull request #261 from neheb/patch-1
add missing time.h include
2020-11-18 08:22:31 +01:00
Rosen Penev c3348ed51e
add missing time.h include
Needed for musl.
2020-11-17 22:14:09 -08:00
Marc Kleine-Budde 856d0a662a
Merge pull request #259 from marckleinebudde/cansequence
cansequence: do_send(): remove unneeded cast
2020-11-04 17:08:52 +01:00
Marc Kleine-Budde ccfa3c8b00 cansequence: do_send(): remove unneeded cast
This patch fixes the following warning:

cansequence.c:232:3: warning: expression result unused [-Wunused-value]
	(unsigned char)frame.data[0]++;
	^              ~~~~~~~~~~~~~~~

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-11-04 14:58:10 +01:00
Marc Kleine-Budde a6cac755b4
Merge pull request #258 from gibsson/master
Android.mk: remove duplicated cansequence definition
2020-11-04 14:57:44 +01:00
Gary Bisson 86bfa25f9d Android.mk: remove duplicated cansequence definition
Otherwise throwing the following error:
build/make/core/base_rules.mk:325: error: external/can-utils:
MODULE.TARGET.EXECUTABLES.cansequence already defined by
external/can-utils.

Fixes: a726c2a ("Merge branch 'cansequence' of
github.com:marckleinebudde/can-utils into master")

Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
2020-11-04 14:12:47 +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
Marc Kleine-Budde 09466c2f1d
Merge pull request #255 from marckleinebudde/ppc64le
travis: fix env for ppc64le
2020-10-19 15:00:41 +02:00
Marc Kleine-Budde eada3b4f53 travis: fix env for ppc64le
Fixes: b7ba7f32fc ("added script to run on power")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-19 14:37:30 +02:00
Marc Kleine-Budde cb5d2fd653
Merge pull request #254 from marckleinebudde/cansequence
can-utils: import PTX cansequence utility
2020-10-19 14:35:04 +02:00
Marc Kleine-Budde a726c2a57a Merge branch 'cansequence' of github.com:marckleinebudde/can-utils into master
The PTX flavour canutils have a useful utility for generating a sequence of CAN
frames with an incrementing payload and checking such a sequence for missed and
reordered frames.

Recently, it has helped finding a regression in the kernel pfifo_fast qdisc,
which led to reordered frames.

To bring the utility to a greater audience, import the current state, including
its history, into the linux-can set of utilities.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-19 13:44:16 +02:00
Marc Kleine-Budde a8131b7996 cansequence: add SPDX identifier for GPL-2.0-only and copyrights
Message-Id: 20201019111239.GM12463@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-19 13:26:43 +02:00
Marc Kleine-Budde 93ef09d9b0
Merge pull request #242 from marckleinebudde/travis-ppc64le
travis: add ppc64le support
2020-10-15 18:36:19 +02:00
Marc Kleine-Budde 677f9ec26f
Merge pull request #253 from marckleinebudde/fix-indention
Makefile: fix indention
2020-10-15 18:35:12 +02:00
Marc Kleine-Budde f3cf4cdf88 Makefile: fix indention
This patch fixes the indention, which was broken while renaming the j1939
tools.

Fixes: 8106214b55 ("Rename j* to j1939\1")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-15 18:08:49 +02:00
Marc Kleine-Budde 2afcbd2fee cansequence: print error frames in hex
Fixes: faad20983348 ("cansequence: receive snd show error frames")
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde 00134246c2 cansequence.c: add extended identifier flag to mask
Without this, the extended identifier flag was not important when
filtering on CAN frames. Add this to mask to only receive the frame type
we want to recieve.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde a1c20aeb45 cansequence: receive snd show error frames
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde d699135833 cansequence: show delta and obsolute overflows
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde de5b9607dc cansequence: add internal 32 bit sequence counter 2020-10-14 18:02:32 +02:00
Marc Kleine-Budde 36fc75bdb7 cansequence: use sigaction() instead of signal
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde 68d5f87889 cansequence: exit with failure in case of unknown option
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde 4d50109a69 cansequence: do_receive: move variables into loop
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde ac9124c776 cansequence: sort options more alphabetically
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde 0bcb5d9c2c cansequence: codingstyle cleanups
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde 1e0fb39e8b cansequence: add support for drop after a certain number of incidents
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:32 +02:00
Marc Kleine-Budde 9567230494 cansequence: print out dropped packages by socket counter
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:30 +02:00
Marc Kleine-Budde 985121aaad cansequence: cleanup perror() and exit()
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:24 +02:00
Marc Kleine-Budde 7975f9859c cansequence: make use of bool variables
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:24 +02:00
Marc Kleine-Budde c9bb22022d cansequence: move rx and tx loop into separate functions
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:24 +02:00