Commit Graph

948 Commits (dc04751cb3532fbbe700e39c9fe23c4fc47ee296)

Author SHA1 Message Date
Marc Kleine-Budde f8a2cf01fa
Merge pull request #293 from marckleinebudde/misc-cleanups
Misc cleanups
2021-05-06 15:59:52 +02:00
Marc Kleine-Budde b88a64e9fc slcan_attach: add bit rate table for -s parameter
Reported-by: Chris Fiege <chris.fiege.pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-05-06 15:56:07 +02:00
Marc Kleine-Budde 70eda640d5 slcan_attach: remove trailing whitespace
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-05-06 15:54:39 +02:00
Marc Kleine-Budde fd6829eb4f canfdtest: main(): sort switch/case in cmd line parser alphabetically
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-05-04 12:00:39 +02:00
Marc Kleine-Budde 4b94546cf9 canfdtest: print_usage(): sort options alphabetically
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-05-04 11:58:25 +02:00
Oliver Hartkopp aaa7fd215f canplayer: add interactive single-step frame processing mode
Wait for ENTER key to process next CAN frame from the log file.

As the new line is printed each time this approach doesn't win a
design price. But this feature is very uncommon and setting the
terminal into some raw mode to get the raw keyboard hits would
introduce a big code overhead to handle e.g. CTRL-C signals which
is a vital functionality for canplayer.

Link: https://github.com/linux-can/can-utils/issues/280
Suggested-by: https://github.com/nico0481
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-04-17 13:01:29 +02:00
Oliver Hartkopp 553f0d282b canplayer: fix usec overflow handling
Commit 9c2de072a0 ("asc2log: Correct usec overflow handling") fixed the
usec overflow handling which is contained in a similar code snippet in
canplayer too.

Cc: Simon Tegelid <simon.tegelid@niradynamics.se>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-04-16 16:18:40 +02:00
Simon Tegelid 9c2de072a0 asc2log: Correct usec overflow handling
This commit fixes these lines
(1614188635.1000000) can1 4A8##28001E9A318ACC0 R
to become this
(1614188636.000000) can1 4A8##28001E9A318ACC0 R
2021-04-16 14:30:50 +02:00
Marc Kleine-Budde 5116452e6d
Merge pull request #285 from kurnev/kurnev-patch-1
Update description for candump
2021-04-14 18:14:23 +02:00
Egor Kurnev bdf3e96ef9
Update candump.c 2021-04-14 18:49:49 +03:00
Oliver Hartkopp 02b330a87d cangen: fix help text for burst send option
The option '-c' requires a value. Add this hint to the help text.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-04-07 13:42:28 +02:00
Marc Kleine-Budde d2f5b3dbe0
Merge pull request #283 from Lauszus/master
Clarify that the mcp251x uses half of the external OSC clock as the base clock
2021-03-23 08:11:47 +01:00
Kristian Sloth Lauszus f11949b7d8 Use the name member to clarify the OSC clock connected to the mcp251x 2021-03-23 00:35:38 +01:00
Kristian Sloth Lauszus b1312a03f0 Added OSC with a clock of 8 MHz to the mcp251x reference clocks 2021-03-23 00:20:19 +01:00
Kristian Sloth Lauszus 890dcc4735 Added comment to clarify that the mcp251x uses half of the external OSC clock as the base clock 2021-03-23 00:19:56 +01:00
Marc Kleine-Budde cafc4bf748
Merge pull request #278 from marckleinebudde/mcp251xfd-dump
mcp251xfd-dump: add tool to decode chip and driver state of mcp251xfd
2021-02-13 23:45:57 +01:00
Marc Kleine-Budde 1792aebd8b mcp251xfd: add sample dev-coredump udev rule
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-02-13 23:36:43 +01:00
Marc Kleine-Budde 66de96d337 mcp251xfd-dump: add tool to decode chip and driver state of mcp251xfd
It works on dev coredump data generated by the mcp251xfd driver in
case of failures, as well as on regmap based register dumps.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-02-13 23:36:43 +01:00
Marc Kleine-Budde e8c90ddff9
Merge pull request #277 from marckleinebudde/can-calc-bitming
can-calc-bitming: cleanups, add mcp251xfd and add decoding of low level bit timing parameters into bitrate
2021-02-10 22:15:17 +01:00
Thomas Kopp fe07dc5837 cangen: add possibility to generate random ID odd/even
Use this for stress testing, when sending with two CAN controllers on
the same CAN bus to avoid broken CAN frames due sending the same
CAN-id.
2021-02-10 21:16:29 +01:00
Marc Kleine-Budde 913311fc15 can-calc-bit-timing: add support to decode user supplied bit timing parameters
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-02-10 17:25:08 +01:00
Marc Kleine-Budde ef8cea79f0 can-calc-bit-timing: move bit rate calculation and print loop into separate function
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-02-10 17:25:08 +01:00
Marc Kleine-Budde d72438243a can-calc-bit-timing: add support for mcp251xfd
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-02-10 17:25:08 +01:00
Marc Kleine-Budde 3fc6c05ce2 can-calc-bit-timing: mcp251x: replace 16MHz refclock by 10MHz
The mcp251x uses half of the external OSC rate as CAN clock. In real world
applications external OSC with a clock of 16MHz or 20MHz are used. Adjust the
example ref clocks accordingly.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-02-10 17:25:08 +01:00
Marc Kleine-Budde dd315316d8 can-calc-bit-timing: mscan: remove printf_btr_sja1000
It makes no sense to print the mscan bit timing register values using the
sja1000 printf function.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-02-10 17:25:08 +01:00
Marc Kleine-Budde 84bc52d6ff can-calc-bit-timing: make btc->printf_btr callback optional
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-02-10 17:25:08 +01:00
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