Commit Graph

1257 Commits (master)

Author SHA1 Message Date
Marc Kleine-Budde 9c82d462f4 Android.mk: remove executable bit
This was added, probably by accident in commit:

    103fd96 can-utils: fix local header path for AOSP build

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-16 16:50:42 +01:00
Yegor Yefremov 393a91c7d8 slcand: reimplement daemonize routine
Replace daemonize() routine with daemone() system call, because of
conflicting licenses. daemonize() routine was derived from under
GNU Free Documentation License licensed code. This license is
incompatible with GPL-2+.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-16 16:31:50 +01:00
Yegor Yefremov 38fb68fb50 slcand: add flow control option
Add option '-t' to specify flow control type. Two types are
supported: 'hw' - RTS/CTS and 'sw' - XON/XOFF.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-16 16:31:50 +01:00
Yegor Yefremov c7aa0b7051 slcanpty: declare command buffer static
ASCII command buffer char buf[200] must be declared as static,
because it holds incomplete commands between pty2can() calls.
Without static it is not guaranteed, that buf retains the same
data between calls.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-16 16:31:50 +01:00
Brennan Ashton 31936b5a17 can-calc-bit-timing: fix MCP251x bit rate calculation
This patch adds the missing -1 to "bt->brp", as correctly used in the kernel
driver.

Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-06 10:35:45 +01:00
Oliver Hartkopp 61733e322a asc2log: inform about uninstalled locales at date conversion failures
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-11-28 16:12:17 +01:00
Kurt Van Dijck 75dfd666c4 testj1939: print API calls 2013-11-28 10:58:59 +01:00
Kurt Van Dijck 234729507e j1939.page: add relevant API calls 2013-11-28 09:56:54 +01:00
Kurt Van Dijck 7fb5f009fd j1939.page: restructure 2013-11-28 09:56:37 +01:00
Kurt Van Dijck 854f47fa84 testj1939: use send() when connect()ed
When using connect(), don't re-use the peername but use send() without
destination information
2013-11-20 11:21:07 +01:00
Kurt Van Dijck d66e6ce4ee testj1939: remember if peername was provided
When peername was not provided, the program uses send() rather than
sendto() so the API calls are better demonstrated
2013-11-20 11:21:07 +01:00
Kurt Van Dijck 77c08edead add .gitignore 2013-11-20 11:21:07 +01:00
Kurt Van Dijck 198c5801ec import sample program & help page 2013-11-20 11:14:44 +01:00
Kurt Van Dijck fe748b1c2c initial 2013-11-18 23:30:03 +01:00
Oliver Hartkopp 16c970d40e slcand: silence warning about set but unused variable
The dummyFile pointer was only needed to redirect stdxxx streams but it's
content was never used. Re-use the pFile pointer for this reason which is
unused at that point to silent the compiler warning about the set and unused
dummyFile variable.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-09-16 09:08:56 +02:00
Oliver Hartkopp 35d2bc1381 slcand: fix whitespace issues and unify coding style
Fixed coding style inspired by Linux checkpatch.pl
Additionally removed a comment in the write() result check in the 'if (speed)'
statement to make sure the write() is not optimized away as the executed code
was empty.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-09-15 21:54:37 +02:00
Oliver Hartkopp 94006e996d slcand: add slcan_attach and UART settings
slcand takes settings known from slcan_attach to configure CAN
interface, like open/close channel, set bitrate etc (Oliver Hartkopp).

In addition -S option sets UART's baudrate (Yegor Yefremov).

This way slcand combines three autilities in one: old slcand,
slcan_attach and stty.

Example: slcand -o -s8 -S 3000000 ttyUSB0

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Reviewed-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-09-15 21:08:00 +02:00
Oliver Hartkopp ad7f44095a cangw: add an option for the per rule limitation of frame hops
Usually the received CAN frames can be processed/routed as much as 'max_hops'
times (which is given at module load time of the can-gw module).
Introduce a new configuration option ( -l <hops> ) to reduce the number of
possible hops for a specific gateway rule to a value smaller then max_hops.

Mainline upstream commit:

http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=391ac1282dd7ff1cb8245cccc5262e8e4173edc4

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-09-04 20:30:34 +02:00
Uwe Kleine-König 93ef3b1d81 can-utils: Don't overwrite PREFIX and DESTDIR when provided via the environment
For creating a Debian package providing PREFIX and DESTDIR via the
environment is the easiest option. So use ?= to assign these two
variables to honor the values in the environment.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-08-18 12:49:50 +02:00
Uwe Kleine-König cc82fd9737 cansniffer: fix file name in header
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-08-17 19:04:48 +02:00
Uwe Kleine-König 03c1bacfde can-utils: trivial: fix typos concerning "separation" and "useful"
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-08-15 21:09:27 +02:00
Yegor Yefremov d7496a0bf0 can-utils: AOSP build clean up
Remove unneeded includes. Both AOSP and NDK builds tested.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-07-10 11:04:40 +02:00
Oliver Hartkopp c05267faca slcanpty: probe stdin capabilities at startup
/dev/null returns EOF therefore select() finishes immediately.
Now EOF is probed on start.

Other /dev/null as stdin workarounds:
- lscanpty ... < /dev/ptmx (dirty but works)
- cat </dev/null | slcanpty ... (doesn't work for me and even the patch
  is "disabled" then)

Signed-off-by: Janusz Uzycki <j.uzycki@elproma.com.pl>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-06-11 22:21:38 +02:00
Oliver Hartkopp d469336649 slcanpty: fix pty terminal flags for correct NL/CR handling
Signed-off-by: Janusz Uzycki <j.uzycki@elproma.com.pl>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-06-11 22:11:19 +02:00
Oliver Hartkopp c9422deb0b slcanpty: handle incomplete messages from pty correctly
Make sure that we have minimum one complete SLCAN messages from pty in the
receive buffer before we start processing the received SLCAN message.

Fragments of a received incomplete message are stored to be appended by the
next read() syscall in pty2can().

This patch is a rework of an initial patch from Ulrich Escher. Tnx!

Reported-by: Ulrich Escher <git@myvdr.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-06-08 12:57:17 +02:00
Oliver Hartkopp 704d5f22d1 slcanpty: detect that master PTY descriptor closed
Terminate slcanpty when the pty file descriptor is closed instead of performing
an endless loop in the select() statement.

Reported-by: Janusz Uzycki <j.uzycki@elproma.com.pl>
Signed-off-by: Janusz Uzycki <j.uzycki@elproma.com.pl>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-06-07 20:02:57 +02:00
Yegor Yefremov df76977207 can-utils: AOSP build improvements
Add local headers and GCC flags for all can-utils targets.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-02-18 10:21:34 +01:00
Oliver Hartkopp 8db365d285 lib: fix typo: exended -> extended
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-02-15 23:39:32 +01:00
Oliver Hartkopp eaf87a3bf6 lib: add support for non-zero dlc values in CAN 2.0B RTR frames
As Hakan Engblom pointed out a CAN 2.0B RTR frame can contain a non-zero DLC
value which was not addressed by parse_canframe() and sprint_canframe().

This patch adds support for non-zero DLC values in a way that legacy logfiles
are still usable as the DLC can optionally be added.

Reported-by: Hakan Engblom <H.Engblom@tele-radio.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-02-15 23:25:13 +01:00
Alexander Stein e5c81aa221 candump: Add timeout option if no message has been received
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-02-12 17:56:35 +01:00
Konrad Anton 667356cc36 cangen: use long long in time computation for -g to support >2.1s
The computation of nanosleep times for the "-g" option (delay between sends)
overflows when more than 2100ms are given.

Signed-off-by: Konrad Anton <konrad.anton@awinia.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-02-07 13:57:49 +01:00
Yegor Yefremov ca313a52a8 slcand: fix build warnings
Remove unused variable name.

Fix FILE pointer check (fopen() returns a pointer not an integer).

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-02-04 12:11:32 +01:00
Yegor Yefremov 103fd9631b can-utils: fix local header path for AOSP build
Use path relative to the can-utils source code and to root of
the AOSP repository.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2013-02-01 10:32:06 +01:00
Oliver Hartkopp 29c3e344a5 cangw: fix inverse filter display when printing the configured rules
A configured inverse filter e.g.

cangw -A -s can0 -d can1 -e -f 123~7FF

has been displayed with 'cangw -L' like this:

cangw -A -s can0 -d can1 -e -f 20000123:7FF # 0 handled 0 dropped 0 deleted

While 0x20000000 was the value of CAN_INV_FILTER.

This patch fixes the output to the expected display:

cangw -A -s can0 -d can1 -e -f 123~7FF # 0 handled 0 dropped 0 deleted

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-01-29 20:50:46 +01:00
Oliver Hartkopp 9dad9f7354 cangw: support new can-gw features for Linux 3.9+
Added new option '-i' for can-gw rules to allow to route CAN frames back to the
originating/incoming CAN interface (which is disabled by default).

CAN frames that are deleted due to the violation of the max_hops limit are now
printed when displaying the configured rules with 'cangw -L'.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-01-29 20:17:52 +01:00
Oliver Hartkopp 221794dbe8 slcanpty: Add support for the Unix 98 pseudo-terminal interface
Most Linux distributions do not configure their kernels to use the BSD
pseudo-terminal interface (/dev/pty* and /dev/tty*) anymore; they uses the
Unix 98 pseudo-terminal interface instead (/dev/ptmx and /dev/pts/*).

http://www.kernel.org/doc/man-pages/online/pages/man4/pts.4.html

This change follows the slcan_attach changes:
http://sourceforge.net/tracker/index.php?func=detail&aid=3467521&group_id=146269&atid=764681

Signed-off-by: Ulrich Escher<git@myvdr.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-12-20 11:37:43 +01:00
Marc Kleine-Budde ddef031408 can-calc-bit-timing: add support for ti_hecc
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-11-26 21:57:57 +01:00
Marc Kleine-Budde 423f018b30 can-calc-bit-timing: add 66.66 MHz mscan refclock
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-11-26 21:57:54 +01:00
Marc Kleine-Budde 3c89d3ab55 can-calc-bit-timing: add 24 and 66 MHz flexcan ref clock
as found on some imx boards.

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-11-26 21:57:52 +01:00
Marc Kleine-Budde 8fe2391877 configure: enable silent rules if available
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-11-26 21:57:45 +01:00
Marc Kleine-Budde 8d47d736f2 configure: adjust bug report address
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-11-26 21:57:24 +01:00
Oliver Hartkopp 0fb5680a61 slcanpty: fix wrong usage of nbytes variable
nbytes is used after writing the CAN frame to check for an additional command
in the string buffer. Therefore using nbytes while writing the CAN frame is
wrong. Replace it with 'tmp' which can be used here without problems.

Signed-off-by: ulrich escher<git@myvdr.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-26 21:44:22 +01:00
Oliver Hartkopp d547068185 candump: unify displayed timestamp length to 10 digits
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-24 21:31:01 +01:00
Oliver Hartkopp 836d3cc012 remove obsolete SVN ID tags
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 20:57:16 +01:00
Oliver Hartkopp 589fa16c27 removed unused variable warnings by removing the variables
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 20:43:55 +01:00
Oliver Hartkopp f123d73d9a cangw: add semantic check for checksum options
The options to for adding checksums (-c or -x) can only be used in conjunction
with modifications (-m) applied to the routed CAN frames.

Signed-off-by: Andre Naujoks <nautsch2@googlemail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 20:20:38 +01:00
Oliver Hartkopp d166ecc8a3 candump: new option to print extra message information
Added -x option to print extra message infos per frame:

  RX/TX : Indicates whether the frame was sent or received from the local host
  BRS   : bit rate setting enabled (CAN FD only)
  ESI   : error state indicator (CAN FD only)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 20:06:50 +01:00
Oliver Hartkopp fcbdf71f1a Add new format option when mixing EFF/SFF frame output
Added new view CANLIB_VIEW_INDENT_SFF flags to fix the sloppy output of
fprint_long_canframe() when mixing EFF & SFF CAN identifiers.

candump: Once an EFF frame is detected the indention is enabled.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 19:59:18 +01:00
Oliver Hartkopp e7631bd7f9 canfd: upgrade tools to support CAN FD for Linux 3.6
This is a major upgrade of the basic tools to handle CAN FD frames.
The library to parse and print CAN frames and logfiles has been extended.

In detail:

 asc2log.c      |    5 +
 candump.c      |   24 ++++---
 cangen.c       |  172 +++++++++++++++++++++++++++++++++------------------
 canlogserver.c |   28 +++++---
 canplayer.c    |   25 ++++---
 cansend.c      |   55 ++++++++++++----
 lib.c          |  189 ++++++++++++++++++++++++++++++++++++++-------------------
 lib.h          |  109 ++++++++++++++++++++++++--------
 log2asc.c      |    8 +-
 log2long.c     |   26 ++++++-
 10 files changed, 440 insertions(+), 201 deletions(-)

asc2log.c / log2asc.c
- updates for new lib functions
- still can only handle CAN2.0 frames (no new info about ASC file layout)

log2long.c / canlogserver.c / canplayer.c
- updates for new lib functions to handle CAN FD

lib.h / lib.c
- reworked lib functions to handle CAN FD
- parse_canframe() now returns CAN_MTU and CANFD_MTU on success, 0 at failure
- added can_dlc2len() and can_len2dlc() helpers
- moved hexstring2candata to hexstring2data to support simple byte buffers
- in the long CAN frame representation use %03X/%08X instead of %3X/%8X
- introduced unified buffer size definitions for ASCII CAN frames
- updated documentation

cangen.c
- support CAN FD frames (added -f option to create CAN FD frames)
- added -m option ('mix') to create random extended / RTR / CAN FD frames
- fixed the 'fixed data' option which was zero'ing the payload by the time
- updated help text

candump.c
- support CAN FD frames (print, bridge, log)
- distinguish frame types by length info: [0] = CAN2.0 [00] = CAN FD frame

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 19:47:21 +01:00
Oliver Hartkopp a2b13452c7 Update includes to Linux 3.6 with CAN FD support.
There has been a change with __kernel_sa_family_t in Linux 3.1 which was not
adopted in this update so far to be backward compatible with old environments.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 18:52:01 +01:00