Commit Graph
100 Commits
Author SHA1 Message Date
Oliver Hartkopp 5e713b3ee0 cansniffer: remove obsolete semicolons
Silence compiler warning.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-13 10:16:52 +02:00
Oliver Hartkopp 5d5ccf38ee fix include order and unify local include placement
In commit https://github.com/linux-can/can-utils/commit/b153fe3f3591
("clang-tidy: sort includes alphabetically") the position of the "lib.h"
include has been moved in a way that struct canfd_frame has not been
defined anymore and lead to a warning when compiling cangen.c

This patch reverts that specific move and unifies the location of local
includes at the end of the include list.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-13 10:03:19 +02:00
Oliver Hartkopp f6d963b5d9 isotpsend: add support for blocking write flag
With the new flag 'CAN_ISOTP_WAIT_TX_DONE' the send()/write() syscall returns
when the PDU is completely passed to the CAN netdevice queue. Depending on
STmin and other settings for the tx-queue-len this does not necessarily mean
that the PDU has been completely sent on the CAN interface at that time.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-01 20:42:50 +02:00
Oliver Hartkopp 7cb3e760fe logfile: add new extra info field
This patch adds a fourth string field in the can logfile format.
This new field contains the rx/tx direction information R/T as the
first entry (only one character separated from the CAN frame by space).

To generate the logfile format with this extra field candump has to be
called with the '-x' option for extra message infos,
e.g. 'candump -x -l can0' or 'candump -x -L can0'

log2asc and asc2log are extended to support the direction information
but still support the previous format without direction information.

The format extension does not affect legacy tools, e.g. the existing
canplayer ignores this extra information and does not need to be changed.

Therefore the existing logfiles remain valid and usable.

The extra message infos will be colon separated when there's need for
additional content beyond the rx/tx direction information, e.g. R:xx:yyy

Suggested-by: Pallavi Revanna https://github.com/brpallu
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-08-18 13:29:36 +02:00
Oliver Hartkopp a4905ed7c8 fix timeval to ASCII unsigned value conversion
As reported by Oleksij Rempel here
https://github.com/linux-can/can-utils/issues/233#issuecomment-674818935
the representation of timeval timestamps are signed values which leads to
negative values on 32 bit machines addressing the year 2038 unix sec counter
overflow.

Fix the issue on 32 bit systems by converting the timeval values to unsigned
ASCII value representations.

Fixes: https://github.com/linux-can/can-utils/issues/234
Reported-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-08-18 12:51:35 +02:00
Oliver Hartkopp 669fa79b21 j1939: Fix arithmetic on a pointer warning
Fix missing (recently introduced) j1939 files that have not been fixed
in commit 43610bd621 ("Fix arithmetic on a pointer warning") from
Gary Bisson.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-06-12 20:08:18 +02:00
Oliver Hartkopp 75d9c7e95f j1939: Fix comparison type mismatch warnings
Fix missing (recently introduced) j1939 files that have not been fixed
in commit 46895a41c5 ("Fix comparison type mismatch warnings") from
Gary Bisson.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-06-12 20:08:18 +02:00
Oliver Hartkopp 85ae5aaecf j1939acd: fix unused variable warning
open_socket() has a parameter to provide a network device name which
is properly assigned by its callers to s.intf in main().
Instead of using the callers value open_socket() directly accesses the
global s.intf which generates an unused variable warning with clang.

Fix this by using the provided parameter (no functional change).

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-06-12 20:08:18 +02:00
Oliver Hartkopp 62f995601e Android.mk: Introduce LOCAL_VENDOR_MODULE to build in AOSP tree
Change path for canutils modules from system/bin to vendor/bin in the
case of building in AOSP tree.

https://github.com/linux-can/can-utils/pull/204

Suggested-by: Pavel Salomatov https://github.com/PsycheEYE
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-06-04 18:02:10 +02:00
Oliver Hartkopp 647210ee1c Android.mk: Add missing targets
The J1939 tools and asc2log was missing in the Android build.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-06-04 18:02:10 +02:00
Oliver Hartkopp 2c87dcf468 can-utils: fix unused variable warnings
As pointed out by Gary Bisson clang complains about unused variables in
some valid cases.

Reported-by: Gary Bisson <gary.bisson@boundarydevices.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-28 19:32:20 +02:00
Oliver Hartkopp d91288f754 README: cansniffer is now also 29 bit CAN ID capable
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-11 15:26:05 +02:00
Oliver Hartkopp 9b75c6020f asc2log: support milliseconds resolution in date/time string
While strptime() does not support fractions of seconds in the date/time
string some new asc files support the milliseconds resolution.

When detecting this new format the msecs are retrieved by a separate
sscanf() invocation and added to the timeval's tv_usec element.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-10 19:22:53 +02:00
Oliver HartkoppandGitHub 41c8ead6c0 Rework for CAN FD support and fixes for asc to log file conversion tools
Detailed change log:

log2asc:
- support CAN FD tags and Classic CAN frames
- support RTR frames including DLC values
- new option '-r' disable the RTR DLC value for potential compatibility reasons
- new option '-f' to use the CANFD format for Classic CAN too

asc2log:
- support CAN FD tags and Classic CAN frames
- be robust against fractions of seconds in date/time string
- fix reading of RTR frames including DLC values in Classic CAN parsing
- fix date/time string detection

cangen:
- new option '-E' to support ESI bit for CAN FD frame generation
(was needed for reference log file generation)
2020-05-10 16:45:21 +02:00
Oliver Hartkopp 3bb659d18d asc2log: fix handling for RTR frames in Classic CAN mode
Fix reading of the RTR representation without and with DLC (v8.5+ tools).

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-10 15:09:55 +02:00
Oliver Hartkopp 9cde2ebe8f asc2log: fix date string detection
The former check was too complex and did not catch all valid cases.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-10 14:41:34 +02:00
Oliver Hartkopp 7729c046c5 cangen: support ESI bit for CAN FD frame generation
The CAN FD frames support BTR and ESI as special flags. While BTR could
be generated by cangen the ESI bit could not be generated so far.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-10 12:03:35 +02:00
Oliver Hartkopp 61dbb56ef6 log2asc: support DLC values in Classic CAN RTR frames
RTR frames contain a valid DLC value which has not been exposed in the
ASC file format since v8.5 of the tools.

So log2asc will expose this DLC value by default which can be changed
by applying the '-r' option to create the former format.

It can be assumed that the tools pre v8.5 will ignore the value but
if not this switch will make sure to create the old format.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-10 11:45:03 +02:00
Oliver Hartkopp 3014d390b4 log2asc: support CANFD format also for Classic CAN
The CANFD tagged format also supports the encapsulation of Classic CAN
frames which is selected when logging on CAN FD capable CAN interfaces.

With a new option '-f' this CANFD format is selected.

Although this representation is even more inefficient it is seems to be
the common way and increases the readability for mixed CAN/CANFD logs.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-10 11:22:05 +02:00
Oliver Hartkopp ad9fc28f9e asc2log: add sanity checks for search pattern
Add some more sanity checks and increase readability for the sscanf()
procedure to read a CANFD tagged line.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-10 10:44:11 +02:00
Oliver Hartkopp 9a079942cd log2asc: support CANFD asc file generation
The CANFD asc format adds information about the CAN controllers bitrate
settings, CRCs and message length (in bits) and its duration.

The plan is to provide static values for these attributes that we can not
get from the log file anyway and stay on the 'old style' format for
classic CAN frames - which has been successfully tested on the latest tools.

The remaining drawback is that the 'old style' format is not able to
provide a DLC information for RTR frames.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-09 22:08:19 +02:00
Oliver Hartkopp ed9c646608 log2asc: reorder code to prepare CAN FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-09 19:04:53 +02:00
Oliver Hartkopp df0b25c17e asc2log: support CANFD tagged asc file content
Handles CANFD asc files with classic CAN and CAN FD frames.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-09 18:42:55 +02:00
Oliver Hartkopp 3c8197e4d1 asc2log: make date time sting milliseconds aware
strptime() does not support milliseconds but the latest ASC logfile
also provides a fraction of seconds, e.g.

date Fri May 8 08:49:04.052 pm 2020

Read the value into the year variable before parsing the real year.
We will therefore omit the milliseconds resolution for now.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-09 18:19:24 +02:00
Oliver Hartkopp 43a3cca54d asc2log: reorder code to prepare CAN FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-09 13:10:27 +02:00
Oliver Hartkopp becc0fc6cc cansniffer: fix buffer length in readsettings()
The Android build discovered a char buffer overflow in readsettings().

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-05-07 18:49:20 +02:00
Oliver HartkoppandGitHub c5cb7e1a7c Merge pull request #200 from hartkopp/29bit-cansniffer
cansniffer: support EFF frames with 29 bit CAN IDs

Convert cansniffer from CAN_BCM to CAN_RAW sockets and handle the
content filter in user space. Conversion CAN_RAW including slot
concept and sorting contributed by @coryjfowler.

Functional changes visible to users:
    
- New format for settings file (using 'r' and 'w' interactive commands)
- New command '8' to switch in a compact binary view for 80 columns view
- New head line layout
- The gap time between CAN frames is displayed in milli seconds (ms)
- The interactive filters support 29 bit CAN IDs
- New interactive command to clear/redraw the screen (<SPACE><ENTER>)
- New interactive commands to enable/disable SFF/EFF frames
    a<ENTER>        - enable 'a'll SFF CAN-IDs to sniff
    n<ENTER>        - enable 'n'one SFF CAN-IDs to sniff
    A<ENTER>        - enable 'A'll EFF CAN-IDs to sniff
    N<ENTER>        - enable 'N'one EFF CAN-IDs to sniff
- Fixes in bit change colorization and gap calculation detected at rework
2020-05-07 18:35:50 +02:00
Oliver Hartkopp 7575d43fd2 cangen: fix doubled description in help text
The help2man conversion created a second application description.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 19:11:41 +02:00
Oliver Hartkopp 2a8867f3cb cansniffer: add short description in help text
Following other can-utils applications.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 19:06:57 +02:00
Oliver Hartkopp ab2e8ffe0e cansniffer: formatting and variable renaming
Some unification of code formatting and rename of a variable in
print_snifline() which does not represent a CAN ID anymore.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 18:56:25 +02:00
Oliver Hartkopp ac55db508a cansniffer: exit after displaying help text
Do not start the application when the user wants to read the help text.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 09:55:28 +02:00
Oliver Hartkopp 64e33bf9ad cansniffer: add new interactive commands to enable/disable SFF/EFF frames
With the new commands

a<ENTER>        - enable 'a'll SFF CAN-IDs to sniff
n<ENTER>        - enable 'n'one SFF CAN-IDs to sniff
A<ENTER>        - enable 'A'll EFF CAN-IDs to sniff
N<ENTER>        - enable 'N'one EFF CAN-IDs to sniff

the EFF/SFF frames can be added/removed with a single command.
Of course this could be done with the '+' and '-' filters too.
But 'N' is much easier to type then '-0000000000000000' ...

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 09:52:20 +02:00
Oliver Hartkopp adf29573f4 cansniffer: add interactive command to clear/redraw the screen
For efficiency reasons on slow embedded machines cansniffer usually
does not clear the screen but only writes updates on required lines.
Sometimes the written lines exceed the terminal lines and people
resize the window which is not detected by cansniffer.

With entering <SPACE><ENTER> in interactive mode the screen can be
forced to redraw after resizing the terminal window.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 09:51:33 +02:00
Oliver Hartkopp bd6ef44321 cansniffer: support EFF frames with 29 bit CAN IDs
Convert cansniffer from CAN_BCM to CAN_RAW sockets and handle the
content filter in user space. Conversion CAN_RAW including slot
concept and sorting contributed by coryjfowler.

Functional changes visible to users:

- New format for settings file
- New command '8' to switch in a compact binary view for 80 columns view
- New head line layout
- The gap time between CAN frames is displayed in milli seconds (ms)
- The interactive filters support 29 bit CAN IDs

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 09:48:52 +02:00
Oliver Hartkopp 6d112a7209 cansniffer: terminate when settings file is not found
Clean up readsettings() and terminate when the settings file
'sniffset.*' is not found when given on commandline.

The readsettings() status output could not be read anyway due to
instant redraw from CAN frames.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 07:18:47 +02:00
Oliver Hartkopp 6f44582c19 cansniffer: make use of if_nametoindex()
Simplify the code as in other can-utils applications.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 06:57:16 +02:00
Oliver Hartkopp 507ff82d81 cansniffer: remove CAN_BCM specific functionalities
Remove functionalities that are not supported resp. can not be implemented
after the CAN_BCM to CAN_RAW conversion of cansnifffer.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-29 06:49:39 +02:00
Oliver Hartkopp 1665abf46f can-utils: fix missing include of libgen.h
The basename() function needs libgen.h to be included as otherwise this
will fail to compile in some environments.

Reported-by: Robert Schwebel <r.schwebel@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-28 19:14:52 +02:00
Oliver Hartkopp 853989bed2 canplayer: make help text fit into 80 colums again
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-28 19:01:45 +02:00
Oliver Hartkopp f3ced10007 cangw: make help text fit into 80 colums again
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-28 19:01:07 +02:00
Oliver Hartkopp 819a03f6e2 candump: fix/unify help text indention
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-28 18:59:37 +02:00
Oliver Hartkopp e266422c54 isotpdump: make help text fit into 80 colums again
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-28 18:57:26 +02:00
Oliver Hartkopp 5ca66d7bea slcanpty: simplify tool decription in help text
Simplify tool description and format the empty lines like in other
(e.g. slcand) tools.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-27 11:09:05 +02:00
Oliver Hartkopp d007263021 cansend: simplify tool decription in help text
Simplify tool description and format the empty lines like in other
(e.g. slcand) tools.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-27 10:53:02 +02:00
Oliver HartkoppandGitHub f91b537c01 Merge pull request #69 from gerasiov/help-reformat
Reformat output of help/usage information - Thanks Alexander!
2020-04-27 09:16:13 +02:00
Oliver Hartkopp bceadb8696 cansniffer: fix colorization when notching relevant bits
When notching marked (and colored) bits with the interactive '#' command
the binary output omits colored bits - as intended.

But when switching back to the hex and ASCII output the bytes with
notched bits remained uncolored even when some bits inside the hex bytes
would have needed to be colored.

The check for the colored output was a logical AND operation which is
fine for the binary representation but needed to be a bit-wise operation
in the hex/ASCII byte mode case.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-26 15:56:08 +02:00
Oliver Hartkopp eb639c1b3d cansniffer: fix gap calculation output
The gap between two consecutive frames of a specific has been calculated in
handle_timeo() instead of handle_bcm() which lead to values that where
at minimum the loop time of the display refresh.

The effect can be seen when displaying a 10ms gap CAN frame with a 200ms
display refresh (option -l 20 => default) in opposite to a 10ms display
refresh (option -l 1).

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-26 08:30:55 +02:00
Oliver Hartkopp da65fdfe0d isotpsniffer: only invoke LL_OPTS setsockopt when set on commandline
In commit da33f96edf ("isotpsniffer: Add support for llopts") the
setsockopt() syscall for the link layer options CAN_ISOTP_LL_OPTS
has been added.

Unfortunately the syscall has been invoked even if there were no values
given on the command line and 'zero values' have been passed to the
kernel which correctly answered with -EINVAL.

And a missing check for a mandatory non-zero value for the MTU.

Fixes: da33f96edf ("isotpsniffer: Add support for llopts")
Reported by: https://github.com/ikuyas
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-02-04 17:28:11 +01:00
Oliver Hartkopp ae69062657 isotpsniffer: remove duplicated code
In commit da33f96edf ("isotpsniffer: Add support for llopts") the setsockopt
call has been executed twice. (copy & paste issue?)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-02-04 08:31:48 +01:00
Oliver HartkoppandGitHub 8027b498cf Merge pull request #191 from hartkopp/candump-remove-bridging
candump: remove bridging functionality
2020-02-01 09:55:23 +01:00
Oliver Hartkopp a9985c7652 candump: remove bridging functionality
The tool 'candump' is used to dump CAN traffic to stdout or logfile.
In early days where the in-kernel CAN gateway (can-gw) with the cangw tool was
not yet implemented the bridging functionality allowed to send received (and
filtered) CAN frames to another outgoing CAN interface.

As we now have can-gw and sending CAN frames from a 'reading tool' seems wrong
especially from the Unix philosophy "Write programs that do one thing and do
it well." this patch removes the obsolete functionality from candump.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-01-04 14:11:34 +01:00
Oliver HartkoppandGitHub 9ae877ce32 Merge pull request #169 from rumpelsepp/isotpsniffer
isotpsniffer: add llopts support, use isprint() instead of open coded check and clean up error paths.
2019-11-14 13:54:05 +01:00
Oliver HartkoppandGitHub 7e9bc7719b Merge pull request #155 from yegorich/reuse-fixes
Reuse fixes
2019-09-26 20:14:40 +02:00
Oliver HartkoppandGitHub 26ae1fffa8 Merge pull request #154 from yegorich/readme-fix
README: update the list of CAN over IP tools
2019-09-19 19:17:15 +02:00
Oliver Hartkopp 226d6393b8 slcan tools: fix stringop-truncation warnings
Rework string handling for ioctl() syscalls for netdev name operations.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-25 18:25:35 +02:00
Oliver Hartkopp 1331c56393 isotptun: fix stringop-truncation warnings
Rework string handling for ioctl() syscalls for netdev name operations.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-25 18:20:37 +02:00
Oliver Hartkopp 319bd5de45 candump: silence format-overflow warning
When -Wformat-overflow= is enabled the gcc notes ...
"‘sprintf’ output between 30 and 82 bytes into a destination of size xx"
Increasing the buffer for the file name to 83 bytes removes the warning.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-23 19:57:06 +02:00
Oliver Hartkopp 83a1210b75 candump: preserve silent mode with enabled log file output format
As seen in https://github.com/linux-can/can-utils/issues/150 the logfile
format switch ignores the silent mode switch.

Fix this by checking the silent mode when using logfile format on stdout.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-23 19:40:27 +02:00
Oliver Hartkopp 818dacd78f candump: fix formatting of status messages regarding standard output
As remarked by Victor in https://github.com/linux-can/can-utils/issues/150
the output in the case of silent mode has puzzled line feeds.

Reported-by: Victor Cushman <VictorSCushman@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-23 19:34:10 +02:00
Oliver Hartkopp d45f3f46bd cangw: add CAN FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-16 15:32:16 +02:00
Oliver Hartkopp 07054c06f5 cangw: remove sanity checks that are better handled in the kernel
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-16 15:26:58 +02:00
Oliver Hartkopp 24923df749 cangw: add new command line option '-X' to handle CAN FD rules
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-16 15:26:50 +02:00
Oliver Hartkopp 0669215a4b cangw: update include files for CAN FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-16 15:26:41 +02:00
Oliver HartkoppandGitHub f185160bfb Merge pull request #139 from buecheko/uds-dump
Add UDS output functionality to isotpdump
2019-05-30 20:37:42 +02:00
Oliver Hartkopp b6cb9a04e5 cansend: enhance help text to point out SFF/EFF identifiers
As suggested by https://github.com/jogo- an example was added that points
out how to send a CAN frame with CAN ID 123 as SFF (11 bit) and EFF (29 bit).

Reference: https://github.com/linux-can/can-utils/issues/126

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-02-14 09:47:46 +01:00
Oliver Hartkopp 46d620b27c cansend: enhance help text for length info in RTR frames
In 'classic' CAN 2.0 the RTR frames contain a length information in the
can_dlc field of a CAN frame control section. This length can be passed
to 'cansend' which has not been documented in the help text so far.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-02-13 14:55:47 +01:00
Oliver HartkoppandGitHub 8991b5c47d Merge pull request #118 from twasilczyk/master
Silence false positive unaligned pointer access warning
2019-01-10 19:28:12 +01:00
Oliver Hartkopp c45a17e96b candump: try to switch bridge socket into CAN FD mode
When using the -b/-B option to send received CAN frames to the brigde interface
the sending failed when processing CAN FD frames. This patch enables CAN FD on
the socket for the bridging interface.

https://github.com/linux-can/can-utils/issues/104

Reported-by: https://github.com/jm3lee
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2018-10-24 09:36:55 +02:00
Oliver Hartkopp 8681e57230 candump: fix EFF CAN ID representation in CAN filter parameter
The documentation stated that the CAN ID is assumed to be an extended CAN
identifier (29 bit ID / EFF) when "can_id and can_mask are both 8 digits".
The check for the CAN ID length to be 8 is common in other CAN utils
(e.g. cansend) but it has never been implemented in candump.

This patch adds that check for EFF CAN IDs and clarifies the documentation.

Thanks to Nick for pointing out this inconsistency!

Reported-by: Nick Elmschig <nick@ikerobotics.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2018-10-23 21:22:11 +02:00
Oliver Hartkopp 47f2e7a180 slcand: move setting of loop variable back into code context
With commit 33a9249571 ("slcand: daemonise only once setup is complete")
the daemonize syscall is moved behind serial tty setup.

This patch moves the missing assignment of the loop variable slcand_running
to get it into the code context of the while() loop.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2018-04-29 19:02:55 +02:00
Oliver HartkoppandGitHub 9d52f81058 Merge pull request #78 from ftheile/patch-1
bzero() is deprecated
2018-03-30 19:03:02 +02:00
Oliver HartkoppandGitHub 8389744f79 Merge pull request #77 from Shmink/master
valgrind no longer reports uninitialised byte(s) from bind call.
2018-03-24 20:56:57 +01:00
Oliver HartkoppandGitHub 6bbcf9d90c Merge pull request #62 from sgh/master
Set low-latency flag on serial port.

Thanks for monitoring!
2018-01-14 14:46:36 +01:00
Oliver Hartkopp ee0233505b canplayer: ensure 6 decimal places in timestamp
Ensure the fractions of seconds are 6 decimal places long to catch
3rd party or handcrafted logfiles that treat the timestamp as float.

See: https://github.com/linux-can/can-utils/issues/60

Reported-by: https://github.com/hauptmech
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-12-13 20:12:32 +01:00
Oliver Hartkopp 33640c8643 candump: make hardware timestamps Linux version agnostic
Hardware timestamps have been introduced in Linux 2.6.30. Check for the
availability of SO_TIMESTAMPING and print an appropriate error message if
missing. Additionally fix some style issues and define the proper length
of ctrlmsg[].

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-12-06 10:16:09 +01:00
Oliver HartkoppandGitHub 7b8607ca89 Merge pull request #59 from FabianInostroza/hw_timestamp
Add option to read hardware timestamps.
2017-12-06 10:15:00 +01:00
Oliver HartkoppandGitHub 60de0d9783 Merge pull request #58 from jschall/patch-1
increase TTYPATH_LENGTH

tnx jschall!
2017-11-29 11:00:08 +01:00
Oliver HartkoppandGitHub 5b518a0a5f Merge pull request #50 from darbedar/main-optimization
omit extra sets and clears - tnx!
2017-08-30 22:05:34 +02:00
Oliver HartkoppandGitHub 846eddd854 Merge pull request #49 from darbedar/master
Another macro usage
2017-08-09 10:47:40 +02:00
Oliver HartkoppandGitHub c6ed797918 Merge pull request #48 from darbedar/master
use a macro for standardization & fix protocol violation location
2017-08-09 08:40:07 +02:00
Oliver Hartkopp 4c8fb05cb4 can-utils: remove strict-aliasing compiler warning
GitHub user 'crossband' raised an issue regarding the strict-aliasing compiler
warning in his specific setup: https://github.com/linux-can/can-utils/issues/42

In fact memcpy() and memset() are a better solution than the former pointer
magics, so remove the issues and the compiler warning flag too.

Reported-by: crossband (https://github.com/crossband)
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-07-01 19:01:01 +02:00
Oliver Hartkopp 5109ca4f3c cangen/cansend: fix typo 'ist' -> 'is'
Reported-by: Stanislavs Rogozins <stanislavs.rogozins@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-06-29 19:55:52 +02:00
Oliver Hartkopp 791890542a README: Add short decription for provided tools
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-04-28 20:42:35 +02:00
Oliver Hartkopp 2a2efbbc7f Updated README.md inspired by Alan (https://github.com/alan707)
Alan sent a pull request to update the README.md with some markdown tweaks
and a SocketCAN logo. Good idea!
After creating a SocketCAN logo PNG in the can-logos repository we can
reference the PNG inside the linux-can organization.
A license file needs to be added too - but this has to be discussed on the
mailing list first.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2017-04-27 21:22:03 +02:00
Oliver Hartkopp 73ae306a11 bcm: add support for CAN FD frames
Update bcm.h following Linux mainline commit 6f3b911d5f29b98752

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2016-10-10 14:19:42 +02:00
Oliver Hartkopp cddb2612b1 candump: print correct interface names on stderr
The cmdlinename[i] output contains the filter definitions e.g.
'can0,300:700' but you want to see only 'can0' when printing on stderr.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2016-08-31 19:14:07 +02:00
Oliver Hartkopp d82ccd76ac slcand: added listen-only option
listen-only option (-l) has been added to slcan-attach in oct 2015.
It is now replicated in slcand

Signed-off-by: interlocuteur <gallard@mmic.net>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2016-05-21 10:31:23 +02:00
Oliver Hartkopp cda61171f1 can: avoid using timeval for uapi
Upstream commit ba61a8d9d780980e8284355a0be750897e7af212

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=ba61a8d9d780980e8284355a0be750897e7af212

The can subsystem communicates with user space using a bcm_msg_head
header, which contains two timestamps. This is problematic for
multiple reasons:

a) The structure layout is currently incompatible between 64-bit
   user space and 32-bit user space, and cannot work in compat
   mode (other than x32).

b) The timeval structure layout will change in 32-bit user
   space when we fix the y2038 overflow problem by redefining
   time_t to 64-bit, making new 32-bit user space incompatible
   with the current kernel interface.
   Cars last a long time and often use old kernels, so the actual
   users of this code are the most likely ones to migrate to y2038
   safe user space.

This tries to work around part of the problem by changing the
publicly visible user interface in the header, but not the binary
interface. Fortunately, the values passed around in the structure
are relative times and do not actually suffer from the y2038
overflow, so 32-bit is enough here.

We replace the use of 'struct timeval' with a newly defined
'struct bcm_timeval' that uses the exact same binary layout
as before and that still suffers from problem a) but not problem
b).

The downside of this approach is that any user space program
that currently assigns a timeval structure to these members
rather than writing the tv_sec/tv_usec portions individually
will suffer a compile-time error when built with an updated
kernel header. Fixing this error makes it work fine with old
and new headers though.

We could address problem a) by using '__u32' or 'int' members
rather than 'long', but that would have a more significant
downside in also breaking support for all existing 64-bit user
binaries that might be using this interface, which is likely
not acceptable.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: linux-can@vger.kernel.org
Cc: linux-api@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-11-05 21:36:42 +01:00
Oliver Hartkopp 8af831f377 cangw: introduce uid command line option
Similar to referencing iptables rules by their line number this UID allows to
reference created routing jobs, e.g. to alter configured data modifications.

The UID is an optional non-zero value which can be provided at routing job
creation time. When the UID is set the UID replaces the data modification
configuration as job identification attribute e.g. at job removal time.

The UID option is provided by mainline Linux 4.2+

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-06-11 20:48:43 +02:00
Oliver Hartkopp 47fbe8fec2 candump: check for joined filter support at runtime
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-04-01 12:58:27 +02:00
Oliver Hartkopp 1a2467ed29 candump: support new raw socket option to join the given CAN filters
The CAN_RAW socket can set multiple CAN identifier specific filters that lead
to multiple filters in the af_can.c filter processing. These filters are
indenpendent from each other which leads to logical OR'ed filters when applied.

This socket option joines the given CAN filters in the way that only CAN frames
are passed to user space that matched *all* given CAN filters. The semantic for
the applied filters is therefore changed to a logical AND.

This is useful especially when the filterset is a combination of filters where
the CAN_INV_FILTER flag is set in order to notch single CAN IDs or CAN ID
ranges from the incoming traffic.

Example:
	candump can0,100~7FF,200~7FF,400~7FF	(logical OR'ed filters)
	candump can0,100~7FF,200~7FF,400~7FF,J	(logical AND'ed filters)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-03-17 20:30:54 +01:00
Oliver Hartkopp e71816295b isotpperf: print link layer data length of measured PDU
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-02-23 10:37:13 +01:00
Oliver Hartkopp 7e1b18f756 isotpperf: display bitrate setting status in summary
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-02-23 10:22:59 +01:00
Oliver Hartkopp 97f64049ac isotpperf: fix printed FC STMin value
Additionally remove the already removed -f option from the help text.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-02-23 10:03:12 +01:00
Oliver Hartkopp c1ac5613fd can-utils: added isotpperf tool for performance measurements
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-02-04 10:17:38 +01:00
Oliver Hartkopp dabe592f45 isotp[server|tun]: update padding and CAN FD features
Update padding and CAN FD features according to the latest isotpsend and
isotprecv changes.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-11-23 12:15:57 +01:00
Oliver Hartkopp a51be177d8 isotp[send|recv]: change command line option for padding bytes
Allow to specify the TX and RX padding content separately.
Due to the optional values it is possible to provide either TX or RX values
which enables and set the given values.

-p 55:AA => TX padding 0x55, RX padding 0xAA
-p 55    => TX padding 0x55
-p 55:   => TX padding 0x55
-p :AA   => RX padding 0xAA

Additionally the comment for the -P <mode> option was updated to point out the
checking mode of the padding in the received PDUs (rx padding).

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-11-20 23:13:37 +01:00
Oliver Hartkopp 523f3d8fc0 isotp[send|recv]: change command line option for extended addressing
Enable to pass the optional second extended address with the '-x' option and
do not pollute the command line options with just another '-X' option.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-11-19 20:44:41 +01:00
Oliver Hartkopp 8150e21a11 isotp: add tool support for ISO 15765-2:2015 with CAN FD
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-11-16 22:24:04 +01:00
Oliver Hartkopp 61a9b8d98e isotpdump: add support for FF_DL escape sequence for 32 bit PDU length
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-11-16 22:14:02 +01:00