Commit Graph

707 Commits (76285153b9c5cfe06d3dbcc6272c6c50e5a3e35d)

Author SHA1 Message Date
Oliver Hartkopp 76285153b9 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-09 19:30:22 +01:00
Oliver Hartkopp f567b75c6c cangen: support fixed length values for len8_dlc
Allow raw DLC values up to 15 in combination with the '-8' option.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-03 19:48:58 +01:00
Oliver Hartkopp ff11fe7ad7 cangen: fix help text about the fixed length information
The fixed values are given in hexadecimal letters only for the CAN-ID (-I)
and for the data (-D). The length information (-L) is a decimal value.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-03 19:27:17 +01:00
Vincent Mailhol 1e2c96e494 cangen: allow DLC > 8 in increment generation mode if -8 option is given
Currently, the -8 option allows DLCs greater than 8 in mix mode only.

Add the option to also generate such DLCs in increment
mode. e.g.: 'cangen -8 -Li can0'

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
2020-11-03 18:42:18 +01:00
Oliver Hartkopp fcc9a89c6e candump/lib: 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-01 20:48:24 +01:00
Oliver Hartkopp a23eb24f95 cangen: remove local assignment of Classical CAN frame pointer
As we have introduced struct can_frame *ccf = (struct can_frame *)&frame;
on top level we can remove this local assignment inside the if statement.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-01 16:51:40 +01:00
Vincent Mailhol 0b6af299d1 cangen: flush the len8_dlc element at each iteration
The variable 'frame' is declared on the stack and is reused at each
iteration of the while loop.

If not flushed, garbage data from the previous iteration of the loop
could remain causing unexpected behavior. This is the case in DLC
random mode: the field frame.len8_dlc is not cleared when the dlc is
exactly 8 and the len8_dlc value of the previous iteration will be
sent again.

This can be observed by running 'cangen -8 can0'. Once a frame of DLC
in the range 9..15 is generated, no more frames of DLC 8 show out in
the log.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-01 16:42:27 +01:00
Oliver Hartkopp 45b9a4812a cangen: add option to generate DLCs greater than 8 for Classical CAN frames
Generating Classical CAN frames with raw DLC values greater than 8 is an
expert feature that should only be enabled on demand.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-31 19:49:31 +01:00
Oliver Hartkopp e1761f8583 log asc converter: support len8_dlc for Classical CAN frames
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-30 13:31:40 +01:00
Oliver Hartkopp 5960c19e6c can-utils: 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

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.

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 analogue for cansend.
cangen can now randomly generate Classic CAN DLC values from 0 .. 15.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-29 21:57:27 +01:00
Oliver Hartkopp 1845141208 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-10-29 15:25:30 +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
Marc Kleine-Budde 2f125e44ce cansequence: mark functions as static
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:24 +02:00
Marc Kleine-Budde 9841820ea0 [cansequence] add sequence wrap around counter
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:24 +02:00
Marc Kleine-Budde fb5903f226 [cansequece] added various improvements
- added poll support if sender
- add cmd line option for can_id
- setup canfilter to disable receiving in sender mode

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2020-10-14 18:02:24 +02:00
Marc Kleine-Budde 4aaad29082 * src/cansequence.c:
obay loop option


git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-3.0-trunk@104 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c
2020-10-14 18:02:24 +02:00
Marc Kleine-Budde a16f8ed471 git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-3.0-trunk@98 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c 2020-10-14 18:02:24 +02:00
Marc Kleine-Budde 6e3b123d5b git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-3.0-trunk@97 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c 2020-10-14 18:02:20 +02:00
Marc Kleine-Budde c93d3a63c5 * src/cansequence.c, src/cansend.c:
fix interface cmd line

git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-3.0-trunk@95 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c
2020-10-14 18:02:10 +02:00
Marc Kleine-Budde 5fa35cbe2a git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-3.0-trunk@92 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c 2020-10-14 18:02:01 +02:00
Marc Kleine-Budde f4cec293dc git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-3.0-trunk@91 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c 2020-10-14 18:01:50 +02:00
Marc Kleine-Budde bd3ea25fe1 * src/cansequence.c, src/cansend.c:
cleanups

git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-3.0-trunk@90 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c
2020-10-14 18:01:48 +02:00
Marc Kleine-Budde d8be4d8a4f * src/canecho.c, src/candump.c, src/cansequence.c, src/cansend.c:
include limits.h

git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-3.0-trunk@89 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c
2020-10-14 18:01:37 +02:00
Marc Kleine-Budde b3b501d922 git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-3.0-trunk@88 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c 2020-10-14 18:01:23 +02:00
Marc Kleine-Budde 0c888d7942 * src/cansequence.c:
fixed print of received frame number


git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-2.0-trunk@85 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c
2020-10-14 18:00:36 +02:00
Marc Kleine-Budde ac8ae17727 * src/cansequence.c:
fixed out of order expected and received value


git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-2.0-trunk@84 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c
2020-10-14 18:00:36 +02:00
Marc Kleine-Budde 3794644caa git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-2.0-trunk@71 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c 2020-10-14 18:00:33 +02:00