Commit Graph

979 Commits (fd0837f7e6524483dd773aed785d1cf8b5ab50ef)

Author SHA1 Message Date
Marc Kleine-Budde fd0837f7e6 can-calc-bit-timing: move kernel compatibility stuff into own header 2023-08-01 21:45:43 +02:00
Marc Kleine-Budde 90baa696cd
Merge pull request #444 from marckleinebudde/can-calc-bittiming-v6.3
can-calc-bit-timing: import bit timing calculation algorithm from v6.3
2023-08-01 14:19:05 +02:00
Marc Kleine-Budde ca304faad3 can-calc-bit-timing: import bit timing calculation algorithm from v6.3 2023-08-01 14:13:43 +02:00
Marc Kleine-Budde dc77f54bc1 can-calc-bit-timing: import 64 bit math helpers from kernel 2023-08-01 14:13:43 +02:00
Marc Kleine-Budde 0be066bee6 cansequence: main(): allow to bind on "any" interface
This is handy for running cansequence during an ifdown/ifup or a
rmmod/insmod cycle.
2023-07-07 08:34:11 +02:00
Marc Kleine-Budde 87def9b1fa cansequence: main(): use C99 initializers for struct sockaddr_can addr
By using C99 initializers for struct sockaddr_can addr the not
assigned members are automatically set to 0x0, resulting in not
passing uninitialized memory to the bind() syscall.

Also remove the printing of the socket family, type and proto, this
was interesting back in the days, when the numbers were not fixed, yet.
2023-07-07 08:34:11 +02:00
Marc Kleine-Budde ba5d7de30d
Merge pull request #438 from marckleinebudde/candump-cleanup
candump: main(): use C99 initializers for struct sockaddr_can addr
2023-07-04 09:41:18 +02:00
Marc Kleine-Budde 6c7542a3ff candump: main(): use C99 initializers for struct sockaddr_can addr
By using C99 initializers for struct sockaddr_can addr the not
assigned members are automatically set to 0x0, resulting in not
passing uninitialized memory to the bind() syscall.
2023-07-04 09:19:08 +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
Marc Kleine-Budde 9e08e2272b
Merge pull request #424 from yashi/canbusload-add-error-message
canbusload: Enhance error message for missing bitrate
2023-06-02 14:09:12 +02:00
Yasushi SHOJI 1d43b3c6f3 canbusload: Enhance error message for missing bitrate
When canbusload is executed without bit rate, it exits with an exit
code of 1 and prints help, but without explaining why.  Users cannot
know what was wrong.  When other errors occur, though, canbusload
prints an error message along with the help.

Print an error message when bit rate is not given or "@" is not found.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-06-02 20:59:39 +09:00
Yasushi SHOJI b8e26388f8 canlogserver: Update the description
Update the description of canlogserver in README.md and help message.

This closes #421.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-05-13 17:25:17 +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
Marc Kleine-Budde 4cfc12e218
Merge pull request #426 from passgat/no-mmu
Add support for Linux/no-mmu with vfork
2023-05-09 10:15:10 +02:00
Dario Binacchi 5ed3b4ded6 Don't compile programs using fork() on MMU-less systems
Systems that lack a MMU cannot use fork() to create the child process.
The patch does not compile the affected programs on MMU-less systems.

Co-developed-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
2023-05-08 18:30:50 +02:00
Marc Kleine-Budde e44db7366b
Merge pull request #430 from marckleinebudde/cangen-fix
cangen: main(): avoid loop initial declaration
2023-04-30 21:02:48 +02:00
Marc Kleine-Budde 085b5546a5 cangen: main(): avoid loop initial declaration
| cangen.c: In function ‘parse_dataoptarg’:
| cangen.c:422:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
|   for (int i = 0; i < CANFD_MAX_DLEN && i < arglen / 2; i++) {
|   ^
| cangen.c:422:2: note: use option -std=c99 or -std=gnu99 to compile your code
| cangen.c: In function ‘main’:
| cangen.c:796:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
|     for (int i = 0; i < frame.len; i++) {
|     ^

Reported-by: https://github.com/yannS2016
Link: https://github.com/linux-can/can-utils/issues/428
Fixes: e409aa4c8c ("cangen: new generation mode - partially randomized payload (-D)")
2023-04-30 21:01:19 +02:00
Marc Kleine-Budde 28a9a6c42f
Merge pull request #429 from marckleinebudde/cangen-fix
cangen: parse_dataoptarg(): avoid loop initial declaration
2023-04-30 20:12:45 +02:00
Marc Kleine-Budde 3c9fd96881 cangen: parse_dataoptarg(): avoid loop initial declaration
| cangen.c: In function ‘parse_dataoptarg’:
| cangen.c:422:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
|   for (int i = 0; i < CANFD_MAX_DLEN && i < arglen / 2; i++) {
|   ^
| cangen.c:422:2: note: use option -std=c99 or -std=gnu99 to compile your code
| cangen.c: In function ‘main’:
| cangen.c:796:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
|     for (int i = 0; i < frame.len; i++) {
|     ^

Reported-by: https://github.com/yannS2016
Link: https://github.com/linux-can/can-utils/issues/428
Fixes: e409aa4c8c ("cangen: new generation mode - partially randomized payload (-D)")
2023-04-30 20:07:24 +02:00
Marc Kleine-Budde c8fef7d60d
Merge pull request #416 from yashi/exit-status-when-signaled
Exit status when signaled
2023-03-22 16:37:40 +01:00
Marc Kleine-Budde dc04751cb3
Merge pull request #418 from Hyatche/master
[fix] Adding lib.c to rule of slcanpty build for AOSP / AAOS
2023-03-22 15:06:49 +01:00
Hyatche 3352b156a9
[fix] Adding lib.c to rule of slcanpty build
See issue : https://github.com/linux-can/can-utils/issues/417
2023-03-22 14:51:39 +01:00
Yasushi SHOJI 69ded0fbad slcand: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

slcand was returning 0 when SIGINT and SIGTERM is received.  This
commit, instead, return 128 + signum when it gets a signal.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:23:18 +09:00
Yasushi SHOJI 7490986650 j1939acd: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

For j1939acd.c, it was using s.sig_term as a boolean key to exit from
the while loop.  This commit replaces a.sig_term with a.signal_num,
which holds the signal it received.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:23:10 +09:00
Yasushi SHOJI 7e35c7e1de canfdtest: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

canfdtest.c was effectively raising the received signal again to run
the default signal handler.  This has been declined by the maintainer
because it's over-engineering.  This commit replaces it with the
method proposed by the maintainer.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:23:01 +09:00
Yasushi SHOJI f45de1b782 canlogserver: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

canlogserver.c was using a non-safe function, exit(3), in the signal
handler.  This commit replaces it with the way other programs in
can-utils are using; set running = 0 to exit from the while loop.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:22:53 +09:00
Yasushi SHOJI 16a717c81e canbusload: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

canbusload.c was using a non-safe function, exit(3), in the signal
handler.  This commit replaces it with the way other programs in
can-utils are using; set running = 0 to exit from the while loop.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:22:41 +09:00
Yasushi SHOJI 180eceff4d isotptun: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:22:30 +09:00
Yasushi SHOJI 3ef3d72738 cansniffer: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:22:21 +09:00
Yasushi SHOJI 3caf692925 cansequence: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:22:12 +09:00
Yasushi SHOJI 74e0d28d1a cangen: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:22:01 +09:00
Yasushi SHOJI 4ec42fa089 candump: Follow Bash exit status when signaled
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit.  Follow the common behavior so that we
know how the programs are killed.

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
2023-03-20 10:21:54 +09: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
Ashcon Mohseninia 999c650e87 slcan: increase BTR char limit to 8 for 32bit BTR
As required by some Atmel MCU SLCAN implementations.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-02-23 16:36:33 +01:00
Marc Kleine-Budde 2323d506d6
Merge pull request #406 from marckleinebudde/cangen-fix-usage
cangen: print_usage(): add missing newlines
2023-02-07 19:59:04 +01:00
Marc Kleine-Budde cdc617545f cangen: print_usage(): add missing newlines
Fixes: f55ea38d14 ("cangen: add option for absolute timeouts")
Fixes: c6f2cf7c2f ("cangen: add support for SO_TXTIME")
2023-02-07 19:57:08 +01:00
majkk1 e409aa4c8c cangen: new generation mode - partially randomized payload (-D)
Part of the fixed data payload can be randomized using the 'x' character.
Nibbles marked with 'x' will be randomized.

For example $ vcan0 -D 11xx3344DEADBEEF -L 8:
 -> second byte of the payload will be randomized.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-01-28 19:00:57 +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
Marc Kleine-Budde fe3717948b
Merge pull request #399 from marckleinebudde/fix-old-toolchains
buildsystem: add missing defines for CLOCK_TAI, SO_TXTIME and SCM_TXTIME
2023-01-24 11:54:14 +01:00
Marc Kleine-Budde e898c8a854 buildsystem: 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")
2023-01-24 10:04:06 +01:00
Marc Kleine-Budde 77ec9b3c2d Revert "cangen: use if_nametoindex() to avoid overflows"
This reverts commit 1f96d674c0.

Link: https://github.com/linux-can/can-utils/pull/396
Link: 1f96d674c0 (commitcomment-97455025)
2023-01-20 09:58:44 +01:00
Marc Kleine-Budde 5aa72c5e9e
Merge pull request #395 from marckleinebudde/mcp251xfd-dump
mcp251xfd dump: add support for dumps created with Linux kernel >= v5.18
2023-01-03 20:45:26 +01:00
Marc Kleine-Budde f3b35e8e80 mcp251xfd-dump: add support for dumps created with Linux kernel >= v5.18 2023-01-03 20:31:54 +01:00
Marc Kleine-Budde b4042d0205 mcp251xfd-dump: add test data 2023-01-03 20:31:54 +01:00
Marc Kleine-Budde 0847fb34b4 mcp251xfd-gen-testdata: add script to generate mcp251xfd-dump data 2023-01-03 20:18:47 +01:00
Marc Kleine-Budde ceb9761544 mcp251xfd-dump: regmap: skip lines that cannot be read 2023-01-03 15:46:07 +01:00
Marc Kleine-Budde 088176e4e0 mcp251xfd-dump: fail if no registers can be read from regmap file 2023-01-03 15:46:07 +01:00
Marc Kleine-Budde aadf98b49b
Merge pull request #394 from marckleinebudde/candump-cleanups
candump cleanups
2023-01-03 10:49:40 +01:00
Marc Kleine-Budde 92ae2b0e3d candump: sort getopt() by order of option in usage 2023-01-03 10:37:15 +01:00