100 Commits
Author SHA1 Message Date
Oliver Hartkopp 392ccc970b canxl extension: use plain union instead of typedef
"In general, a pointer, or a struct that has elements that can reasonably
be directly accessed should never be a typedef."

https://www.kernel.org/doc/html/v5.0/process/coding-style.html#typedefs

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-12-18 18:23:38 +01:00
Oliver Hartkopp 7939678070 can-utils: unify indention
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-12-13 10:38:15 +01:00
Oliver Hartkopp 374fecde09 cangen: disable generation of unsupported CAN frame types in mixed mode
The mixed mode is able to automatically detect the potential supported
CAN frame types CAN CC/FD/XL by checking the CAN device MTU at startup.

Usually the MTU shows which CAN frame types can be sent but in the case of
CAN XL in CANXL-only mode CC and FD frames can not be sent on the CAN_RAW
socket.

Since this patch [1] the CAN_RAW socket rejects unsupported CAN frames and
returns -EINVAL as error code. With this change in cangen the CC and FD
frame generation can be disabled in mixed mode at runtime.

[1] https://lore.kernel.org/linux-can/20251125123859.3924-17-socketcan@hartkopp.net/T/#u

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-12-03 16:09:12 +01:00
Oliver Hartkopp bfbf0c851f cangen: auto enable FD/XL content in mixed mode
Automatically create FD/XL content in mixed mode when the CAN interface
is capable to deal with it.

Suggested-by: Vincent Mailhol <mailhol@kernel.org>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-12-03 16:09:12 +01:00
Oliver Hartkopp ed7822c9a2 candump: print CAN XL specific flags as extra message infos
The extra message infos BRS and ESI have been printed when enabled with
the '-x' option. Since CAN XL has similar flags (SEC and RRS) those flags
have been wrongly printed as CAN FD flags.

This patch introduces separate flags for the CAN XL frames and prints them
when a CAN XL frame is processed.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-11-26 19:04:50 +01:00
Oliver Hartkopp 8bf5f8873f Fix optional nanosecond timestamp
The extension of the timestamp size is missing in log2asc.c and canplayer.c

Fixes: 987bc8aac2 ("Optional nanosecond timestamp logging")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-09-03 12:55:26 +02:00
Oliver Hartkopp 6b46063eee cangen: add CAN XL RRS bit generation
Allow to generate Remote Request Substitution bit content.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-06-24 19:48:14 +02:00
Oliver Hartkopp c542c9ada7 gitignore: remove accidentally added Makefile item
Fixes: 4577316bd6 ("Update .gitignore")
Link: https://github.com/linux-can/can-utils/pull/577#issuecomment-2690362731
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-02-28 21:34:03 +01:00
Oliver Hartkopp 008f9f8e22 asc2log: add option to disable direction info
The ASC file provides an information whether the CAN frame is sent (Tx)
or received (Rx) on the local CAN node.

With the new '-d' option the generation of this information is disabled
for the log file generation to simplify the comparision of log files.

E.g. log1 -> asc -> log2 always created the T/R information in the log2
file which is then hard to compare to the log1 file which might not
have the T/R information at all.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 15:08:46 +01:00
Oliver Hartkopp 66e7c08beb log2asc: add CAN XL support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 15:04:43 +01:00
Oliver Hartkopp 4b66e8c56f asc2log: shrink string buffer for header analysis
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:59:57 +01:00
Oliver Hartkopp e6e3253972 asc2log: shrink string buffer for CAN identifier
Since using the %n feature the tmp1 buffer is only used for the handling
of the CAN identifier. So this buffer can be shrinked for that use case.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:56:16 +01:00
Oliver Hartkopp 6d69bef837 asc2log: add CAN CC and CAN FD support for CAN XL message events
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:51:52 +01:00
Oliver Hartkopp 4d8b247258 asc2log: make use of sscanf consumed characters feature
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:48:32 +01:00
Oliver Hartkopp 0e9c53f6d3 asc2log: add CAN XL support for CAN XL message events
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:33:59 +01:00
Oliver Hartkopp 99c5c14790 can.h: canxl: support Remote Request Substitution bit access
The Remote Request Substitution bit is a dominant bit ("0") in the CAN XL
frame. As some CAN XL controllers support to access this bit a new
CANXL_RRS value has been defined for the canxl_frame.flags element.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:22:21 +01:00
Oliver Hartkopp df8e08fa70 asc2log: prepare helper functions for CAN XL frame handling
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:22:21 +01:00
Oliver Hartkopp cb5ab07f34 asc2log: handle and skip TxRq messages
TxRq messages are internal measurement messages that document the time of
a transmission request (to the CAN driver) to be checked against the real
transmission time, when the CAN message has been sent.

There is no such feature in the SocketCAN log format, so we detect this
tag but skip TxRq messages in the ASC log files.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:22:21 +01:00
Oliver Hartkopp 0e692bf42e asc2log: unify multi-line comments
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:21:59 +01:00
Oliver HartkoppandGitHub 6526683a10 Merge pull request #556 from hartkopp/master
Fix and rework canbusload
2024-08-09 15:02:26 +02:00
Oliver Hartkopp dced0a6ec7 canbusload: fix and improve the bitrate output
With the introduction of CAN FD the bitrate has not been printed
correcty. Fix the CAN FD bitrate output and try to shrink the
bitrates by using kilo or Mega suffixes: 500000 -> 500k

Fixes: 6382765bf6 ("canbusload: count databitrate seperately")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-08-08 17:36:49 +02:00
Oliver Hartkopp be1fc77311 gitignore: add j1939-timedate-cli and j1939-timedate-srv
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-08-08 11:03:15 +02:00
Oliver Hartkopp fc2473424e canbusload: show RX/TX direction in bargraph
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-08-08 10:04:55 +02:00
Oliver Hartkopp 724e6f7c11 canbusload: use recvmsg() instead of recvfrom()
To access msg_flags for RX/TX direction detection.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-08-07 21:29:49 +02:00
Oliver Hartkopp 7665e1e236 canbusload: add auto detection of CAN interfaces
Rework to use a single CAN socket for the received CAN traffic.
This allows to shutdown and restart various CAN interfaces without
terminating the application.
Additionally an auto detection has been implemented with the 'any' CAN
interface. E.g. with any@500000,2000000 CAN interfaces that have not
been defined before are assigned with the given 'any' bitrates when a
CAN frame from this CAN interface has been received.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-08-07 19:57:08 +02:00
Oliver Hartkopp b592ec5b1f canbusload: fix string length check for CAN FD
The CAN interface description can now have two bitrates.
Extend the length check to handle the CAN FD data bitrate correctly.

Fixes: 6382765bf6 ("canbusload: count databitrate seperately")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-08-07 13:02:05 +02:00
Oliver Hartkopp 30b6b04053 isotpdump: add color support for functional addressing traffic
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-08-06 16:26:14 +02:00
Oliver Hartkopp 15dbb474c7 j1939_timedate_cli: fix sign-compare warning
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-06-07 09:09:26 +02:00
Oliver Hartkopp 4b86049167 Makefile: add j1939 datetime tools
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-06-07 09:09:26 +02:00
Oliver HartkoppandGitHub 8d7d7650d4 can-utils: fix sign-compare warnings (#513)
Fixing several build issues reported by Gary Bisson when he was building
can-utils with clang (AOSP14).

URL: https://github.com/linux-can/can-utils/pull/512
Reported-by: Gary Bisson (https://github.com/gibsson)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-04-24 20:02:02 +02:00
Oliver Hartkopp 001b230b10 cangen: initialize reserved struct CAN(FD) frame elements
With 'cansend' and other tools the reserved elements are set to zero.
Fix this missing initialization in 'cangen'.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-18 12:35:29 +01:00
Oliver HartkoppandGitHub 6d47f5c22b Merge pull request #504 from hartkopp/master
can-utils: support CAN XL

This patch set adds support for CAN XL including VCIDs (Linux v6.9+)

Tools that completely support CAN XL:

    candump
    cangen
    canlogserver
    canplayer
    cansend
    log2long

CC/FD-only tools that have been adapted to the lib.[ch] changes:

    log2asc
    asc2log

Main changes:

    lib/cangen: add documentation for CAN XL ASCII representation
    lib: remove separate maxdlen parameter as every needed info is part of the CAN frame now
    lib: remove fprint functions and only support sprint
    lib: rework for static single buffer to contain a complete ASCII CAN XL frame
    lib: introduce a CAN frame unit type to contain CAN CC/FD/XL frames in one union
    canplayer/log2asc/log2long: make sscanf() buffer length aware
    cangen: fix views for some features for long CAN frame output
    general cleanups and buffer overflow safety measures
2024-03-13 22:03:02 +01:00
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 27030b3e54 lib: make sprint_canframe the buffer size aware snprintf_canframe
Make sure the library functions to convert CAN frames into ASCII
represenation do not exceed the given buffer size. This also applies
to the long CAN frame output library function.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-12 19:11:58 +01:00
Oliver Hartkopp 8e131401c1 lib: remove obsolete brackets
From review feedback.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-06 12:10:32 +01:00
Oliver Hartkopp 7905b632ff canlogserver: unify curly brackets in if statements
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-06 12:01:39 +01:00
Oliver Hartkopp 6f7b146166 cangen: unify curly brackets and apply review feedback
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-06 11:57:54 +01:00
Oliver Hartkopp 09aa4d55bf asc2log: unify curly brackets at function definition
Move the curly brackets to the start of the next line to follow the
common coding style in can-utils.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-06 11:42:13 +01:00
Oliver Hartkopp 87a3058019 cangen: support generation features for CAN XL specific content
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-04 22:50:52 +01:00
Oliver Hartkopp 443312d6ce cangen: add initial CAN XL support
TODO:
- Test all features
- make CAN XL content variable

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-03 21:29:49 +01:00
Oliver Hartkopp 09b8a6431f cangen: add missing long CAN frame view for len8_dlc and eff
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-02 22:36:49 +01:00
Oliver Hartkopp 9a21de13f8 cangen: convert to CAN frame unit type
As preparation for CAN XL support.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-02 22:36:36 +01:00
Oliver Hartkopp 2af5e6aaaa canlogserver/log2long: make CAN XL ASCII buffer static
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-01 15:56:21 +01:00
Oliver Hartkopp 740c0ba156 lib/cansend: update documentation for CAN XL frame format
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-29 09:54:47 +01:00
Oliver Hartkopp 7761d8bcf8 canlogserver: add CAN XL support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-29 08:44:27 +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
Oliver Hartkopp 3644a54d5b candump/lib: make sprint_long_canframe CAN XL aware
The 'long' CAN frame representation does not really fit for CAN XL content.
Therefore just a cropped output is provided to be able to see the CAN XL
header information and up to 64 byte of data (without binary or swap
formating options). To get the full qualified CAN XL content use the log
file format.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-27 20:11:46 +01:00
Oliver Hartkopp 04312e5a10 candump/lib: make sprint_canframe CAN XL aware
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-27 18:23:29 +01:00
Oliver Hartkopp 57238d5f81 candump: add sprintf error handling in sprint_timestamp
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-27 11:33:01 +01:00
Oliver Hartkopp f491175d72 lib: remove obsolete fprint_(long_)canframe functions
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-27 11:17:49 +01:00
Oliver Hartkopp 3b36edf128 canlogserver: remove fprint_canframe usage
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-27 11:14:18 +01:00
Oliver Hartkopp 48e10c9c57 canplayer: remove fprint_long_canframe usage
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-27 11:04:42 +01:00
Oliver Hartkopp 9d900f913c cangen: remove fprint_(long_)canframe usage
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-27 10:57:55 +01:00
Oliver Hartkopp 8d8d17e25d asc2log: remove fprint_canframe usage
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-27 10:11:17 +01:00
Oliver Hartkopp c6cc7151b7 candump/lib: convert to single output buffer
Build the CAN frame ASCII output inside a single (big) buffer as
preparation for CAN XL support.

This unifies different output modes (fprintf/sprintf/printf) at
the time of the CAN frame text generation.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-27 09:29:49 +01:00
Oliver Hartkopp 2522ec127b lib: integrate CAN FD indicator into dual-use struct canfd_frame
Replace maxdlen parameter and use CANFD_FDF flags instead.

Since the CANFD_FDF flag has been introduced in can.h the struct canfd_frame
can be used for CAN CC and CAN FD frames as a dual-use data structure.

Remove the extra maxdlen parameter in library calls and only use the
CANFD_FDF flag to differentiate the two CAN CC/FD frames.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-24 11:28:35 +01:00
Oliver Hartkopp 830a84019d isotprecv: add option to enable dynamic flow control parameters
New feature in Linux 6.9+

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-14 21:18:58 +01:00
Oliver Hartkopp 2643d28a57 slcanpty: silence warning for signed index for the buf array
slcanpty.c: In function ‘pty2can’:
slcanpty.c:105:21: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  105 |         buf[nbytes] = 0;
      |         ~~~~~~~~~~~~^~~
slcanpty.c:58:21: note: at offset [-2147483647, -1] into destination object ‘buf’ of size 200
   58 |         static char buf[200];
      |                     ^~~

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-14 21:03:11 +01:00
Oliver Hartkopp a9260eab76 Makefile: fix isobusfs tools build
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-14 20:42:42 +01:00
Oliver Hartkopp 8ba360ea31 include: update includes to Linux v6.9 upstream
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-14 20:18:29 +01:00
Oliver Hartkopp 444e48596a isotpsniffer: simplify option for CAN FD link layer
As the tx_dl and flags struct elements are not relevant for listen-only
sockets, simplify the CAN FD command line option switch.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-12-08 17:29:04 +01:00
Oliver Hartkopp 689f103142 cansniffer: remove unnecessary parenthesis
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-12-08 17:14:49 +01:00
Oliver Hartkopp c31addfa9c cansniffer: unify setsockopt error handling
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-12-08 17:12:16 +01:00
Oliver Hartkopp 7affaf217e isotpsniffer: fix missing CAN FD support on second listen socket
When sniffing CAN FD isotp traffic both listen-only sockets have to be
switched to process CAN FD frames.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-12-08 17:10:20 +01:00
Oliver Hartkopp 79601bd1d4 canplayer: ensure 6 decimal places in timestamp for first frame
The check has only been applied after the first CAN frame has been read
and evaluated. This lead to an unintended sending of a single handcrafted
frame with a following (intended) failure at the second frame.

Apply the check also for the very first CAN frame that is processed.

Fixes: ee0233505b ("canplayer: ensure 6 decimal places in timestamp")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-08-10 10:31:26 +02: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 a3b60a70fe cangen: update CAN FD check to cope with CAN XL interfaces
The check for CAN FD capable interfaces only checked for CANFD_MTU to
enable the generation of CAN FD frame content. As CAN XL capable CAN
interfaces are able to handle CAN FD frames too the check has to be
extended for CANXL_MTU interfaces.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-05-09 14:30:16 +02:00
Oliver Hartkopp 5f764e73bf cansend: update CAN FD check to cope with CAN XL interfaces
The check for CAN FD capable interfaces only checked for CANFD_MTU to
enable the generation of CAN FD frame content. As CAN XL capable CAN
interfaces are able to handle CAN FD frames too the check has to be
extended for CANXL_MTU interfaces.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-05-09 14:21:46 +02:00
Oliver Hartkopp cfe41963f3 include: update includes to latest Linux v6.2 upstream
Update includes to support CAN XL and latest CAN netlink features.

Upstream commits:

(1a3e3034c049) "can: canxl: introduce CAN XL data structure"
(061834624c87) "can: set CANFD_FDF flag in all CAN FD frame structures"
(94dfc73e7cf4) "treewide: uapi: Replace zero-length arrays with flexible-array members"
(383f0993fc77) "can: netlink: report the CAN controller mode supported flags"
(d99755f71a80) "can: netlink: add interface for CAN-FD Transmitter Delay Compensation (TDC)"
(63dfe0709643) "can: bittiming: allow TDC{V,O} to be zero and add can_tdc_const::tdc{v,o,f}_min"
(626332696d75) "can: raw: add CAN XL support"

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-02-25 14:55:00 +01:00
Oliver Hartkopp 3b2248b48e Makefile: add missing defines for CLOCK_TAI, SO_TXTIME and SCM_TXTIME
The commit c6f2cf7c2f ("cangen: add support for SO_TXTIME") relies
on several toolchain features ("CLOCK_TAI", "SO_TXTIME", "SCM_TXTIME")
which are not present in old toolchain.

Add defines to fix compilation on older toolchains.

Reported-by: https://github.com/b-thomson
Link: https://github.com/linux-can/can-utils/issues/398
Fixes: c6f2cf7c2f ("cangen: add support for SO_TXTIME")

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-01-28 13:37:49 +01:00
Oliver Hartkopp 6e7f845a68 isotpsend: add support for transmission without flow control
Usually the ISO 15765-2 protocol is a point-to-point protocol to transfer
segmented PDUs to a dedicated receiver. This receiver sends a flow control
message to specify protocol options and timings (e.g. block size / STmin).

The so called functional addressing communication allows a 1:N
communication but is limited to a single frame length.

The new CAN_ISOTP_CF_BROADCAST flag introduced in Linux 5.19 allows an
unconfirmed 1:N communication with PDU lengths that would not fit into a
single frame. This feature is not covered by the ISO 15765-2 standard.

The isotpsend tool gets a new option '-C' to enable this unconfirmed 1:N
communication by setting the CAN_ISOTP_CF_BROADCAST flag.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-05-13 20:00:45 +02:00
Oliver Hartkopp d320a4a871 asc2log: reduce code duplication
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-05-01 13:57:25 +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 2bdb93924e asc2log: make sure we have read the dlc value with sscanf()
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-05-01 13:02:08 +02:00
Oliver Hartkopp afc6a324da asc2log: move check for error frames
We need to check for different sscanf() failures and the number of read
items in the data frames. So move the simple check to the beginning.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-05-01 12:55:49 +02:00
Oliver Hartkopp c70d0a8e61 candump: handle individual logfile name for stdout
Since commit ad250a68dc ("candump: add option to define individual
filename for logfile") the option "-f <fname>" allows to define an
individual filename for a logfile.

Usually the "-" is used as filename to represent stdout or stdin on
Linux/Posix systems to be able to concatenate several applications via
pipes. This patch handles this special case by detecting the filename
"-" to print the logfile format on stdout instead of creating a logfile
with the name "-".

Fixes: ad250a68dc ("candump: add option to define individual filename for logfile")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-03-25 15:15:57 +01:00
Oliver Hartkopp dfb607c807 remove obsolete char pointer casts
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-03-14 18:21:45 +01:00
Oliver Hartkopp 84d3294132 isotp: support Linux 5.18 features
- update isotp.h include file
- update maximum PDU (buffer) size to 64kByte buffer
- support setting of N_As (frame_txtime) to zero

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-03-12 18:09:48 +01:00
Oliver Hartkopp 5e0895981b candump: fix accidentally disabled traffic timeout feature
With the option '-T <msecs>' candump terminates after getting no CAN traffic
for a specific time. With the introduction of epoll_wait() this feature
has been accidentally disabled.

This patch adds an extra check to detect the timeout again.

Fixes: 639498bc80 ("candump: use epoll_wait() instead of select()")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-03-07 10:32:41 +01:00
Oliver Hartkopp ad250a68dc candump: add option to define individual filename for logfile
Link: https://github.com/linux-can/can-utils/pull/345
Suggested-by: https://github.com/xR3b0rn
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-02-16 11:46:46 +01:00
Oliver Hartkopp acec220189 isotpsend: add new options to generate PDU traffic load
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-02-09 18:34:09 +01:00
Oliver Hartkopp 8ffcc187e9 cansniffer: make ASCII output switchable in CAN FD mode
In CAN FD mode the length of the output line becomes very long.
Therefore disable the ASCII output in CAN FD mode by default but
make it switchable with a new '@' command in interactive input mode.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-01-22 14:51:20 +01:00
Oliver Hartkopp c3129b678a cansniffer: add CAN FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-01-22 14:48:14 +01:00
Oliver Hartkopp 540dcaa821 cansniffer: convert to struct canfd_frame for FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-01-22 13:50:03 +01:00
Oliver Hartkopp fb186ed6c8 cansniffer: add error handling for read/write of sniffsets
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-01-22 13:49:23 +01:00
Oliver Hartkopp a705182b28 candump: trivial typo exchange sentence point with closing bracket
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-11-28 20:14:43 +01:00
Oliver Hartkopp 0d84033fa4 canplayer: introduce option to limit the number of processed frames
Analogue to the '-n <count>' option to limit the number of processed CAN
frames in candump and cangen this option makes sense in canplayer too.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-10-30 13:02:42 +02:00
Oliver Hartkopp 0edab8a402 cangen: improve help text to point out decimal places for the gap value
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-10-20 06:12:27 +02:00
Oliver Hartkopp 622fcbb9b3 Makefile: remove obsolete requirements for lib.h
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-10-19 08:57:22 +02:00
Oliver Hartkopp f7307b8290 can-utils: check for return values of if_nametoindex()
if_nametoindex() returns zero and a specific errno in the case the network
interface does not exist. The missing check leads to the use of the 'any'
CAN device but leaves the user alone as the user gets no error message.

Reported-by: Lothar Rubusch <lotophagon@protonmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-10-18 09:37:46 +02:00
Oliver Hartkopp 7b8457ce9f j1939cat: fix long long unsigned int warning in x_name printf
warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 8 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]

Fixes: cc155d2f63 ("j1939cat: make use of new RX UAPI")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-10-11 20:54:22 +02:00
Oliver Hartkopp affdc1b799 can: uapi: update can.h to latest upstream version
This update includes:

commit f5076c6ba02e ("can: uapi: can.h: mark union inside struct can_frame packed")
commit 7e97d274db92 ("can: uapi: update CAN-FD frame description")
commit 025468842212 ("can: uapi: introduce CANFD_FDF flag for mixed content in struct canfd_frame")

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-06-01 19:55:40 +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
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
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