Commit Graph

144 Commits (71bcd74a7d59da20687885881bcb81c35e571b5b)

Author SHA1 Message Date
Wolfgang Grandegger 71bcd74a7d can-utils/lib: fix build issues introduced with sprintf_can_error_frame()
Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
2011-02-14 16:10:39 +00:00
Wolfgang Grandegger 796475677a candump: add option -e to dump error messages in human readable format
If "candump" is called with the option "-e", the error messages are
dumped in human readable format:

  # candump -e any,0:0,#FFFFFFFF
  ...
  can0  20000088  [8] 00 00 80 19 00 00 00 00   ERRORFRAME
        protocol-violation{{error-on-tx}{acknowledge-slot}}
        bus-error
        error-counter{tx{128}rx{97}}
  ...
  can0  2000008C  [8] 00 08 80 19 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-warning}
        protocol-violation{{error-on-tx}{acknowledge-slot}}
        bus-error
        error-counter{tx{128}rx{97}}

"candump" actually calles a library function snprintf_can_error_frame()
to do the formatting. It could be used for other purposes as well.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Acked-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
2011-02-14 15:49:27 +00:00
Oliver Hartkopp c9e79e55c3 candump: Avoid ragged output of timestamp values when printing differential
timestamps (commandline option -td).
Idea & original patch by Uwe Bonnes.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2011-01-19 17:43:07 +00:00
Oliver Hartkopp d262a552bb cangen: set seed value for pseudo random numbers
As pointed out by Andre Naujoks the pseudo random generator should be
initialized with a seed to prevend this ugly behaviour:

$ ./cangen vcan2 -v & ./cangen vcan1 -v
[1] 5995
  vcan2  567#69.98.3C.64.73.48
  vcan1  567#69.98.3C.64.73.48
  vcan2  451#4A.94.E8.2A.EC.58.55.62
  vcan1  451#4A.94.E8.2A.EC.58.55.62
  vcan2  729#BA.58.1B.3D.AB.D7.7E.50
  vcan1  729#BA.58.1B.3D.AB.D7.7E.50
(..)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2011-01-19 17:35:37 +00:00
Oliver Hartkopp 7ef581fec0 slcan_attach: added '-f' commandline option to read status flags.
In the case of pending bus errors on some slcan adapters the read of the
status flags resets the adapter and clears the error LED.

This patch adds the commandline option to send the status read command to the
adapter as suggested by Thorsten Godau.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2011-01-09 11:49:20 +00:00
Oliver Hartkopp eb1a99f8c7 slcan_attach: 'close' the slcan adapter before setting a bitrate
As investigated by Thorsten Godau the bitrate can only be set after the
slcan adapter is in 'close' state.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Tested-by: Thorsten Godau <dl9sec@gmx.net>
2011-01-09 11:35:03 +00:00
Oliver Hartkopp c9cdc9d069 slcand: replace char pointers with static char buffers
The buffers to build the pathnames had been malloc'ed and never been free'd.
This patch removes the malloc stuff entirely.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2011-01-06 19:20:18 +00:00
Oliver Hartkopp 3a9baeda05 candump: Added '-u <usecs>' commandline option to delay bridged CAN frames by
usecs microseconds.
2010-11-29 19:11:11 +00:00
Oliver Hartkopp 5d1dbedd19 cangen: Added '-n <count>' commandline option analogue to candump tool.
Inspired by Uwe Bonnes.
2010-11-29 18:58:12 +00:00
Oliver Hartkopp 33ff70f940 slcand : added new commandline option to support direct assignment of a CAN
netdevice name to the given tty (by renaming the created netdevice).

Signed-off-by: Robert Haddon <robert.haddon@cirrascale.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2010-11-19 19:52:39 +00:00
Oliver Hartkopp d1efcd1d75 slcan_attach: Added new commandline option to specify the created netdevice name. 2010-11-17 11:55:46 +00:00
Oliver Hartkopp f213d0fea8 slcan_attach: Print the name of the assigned netdevice after attaching the tty. 2010-11-17 06:59:20 +00:00
Oliver Hartkopp 6aeb7d1faa Added new socketoptions to force the isotp protocol to intentionally
misbehave for regression tests.

CAN_ISOTP_TX_STMIN:
Set a value in nano secs that's used as minimum CF gap by the sender.
This value is used instead of the value provided by the receiver inside the FC.

CAN_ISOTP_RX_STMIN:
Ignores received CF frames which timestamps differ less than this value in nano
secs. This is used to test the receivers misbehaviour when the receiver
provides a lower stmin value that he's able to cope with. Received CF frames
are silently dropped when they come faster than specified by this value.
2010-11-14 08:55:06 +00:00
Oliver Hartkopp d3468d907f Fix datatype issue in sscanf() on 64bit systems.
On 64bit systems a 'long' is a 64bit value but the target values of scanf()
are always 32bit in the affected code - which means just an 'unsigned int'.
Unsigned int is fine on 32 and 64 bit systems.

Thanks to Andre Naujoks for reporting this issue.
2010-09-25 10:24:37 +00:00
Oliver Hartkopp 1463ee4ce4 Added support for inverted CAN ID filters. 2010-09-24 18:23:42 +00:00
Oliver Hartkopp d7fe33eb4b Fixed calculation of needed bits on the physical wire according Ken Tindells
*worst* case calculation for stuff-bits.
(see "Guaranteeing Message Latencies on Controller Area Network" 1st ICC'94)
Due to the bitstuffing estimation the calculated busload may exceed 100%.
2010-09-24 17:56:53 +00:00
Marc Kleine-Budde f5576a9833 can-calc-bit-timing: remove rtcantl1
No one can verify the timing parameters to be correct.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-07-20 14:10:38 +00:00
Marc Kleine-Budde 5c74d8d806 can-calc-bit-timing: add more can controller definitions and ref clocks
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-07-20 13:43:20 +00:00
Marc Kleine-Budde b9f9cd0c62 can-calc-bit-timing: calculate bit timings for all known controllers by default
When testing or improving the bit timing algorithm, you're probably
interested in the values of all can controllers. Further you might not
know the all reference clocks of the controllers.

This patch add a "ref_clock" member to the "struct can_bittiming_const"
that holds the reference clock of the controller in Hz.

By default now the bit timing is calculated for all known can
controllers with the default ref_clock defined in "can_bittiming_const".

It's still possible to overwrite the ref clock with the command line
option "-c".

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-07-20 13:43:16 +00:00
Marc Kleine-Budde 26488b16e6 can-calc-bit-timing: improve printing of bit timing parameters
This patch adds additional fields when printing the bit timing
parameters. Now the real bitrate the nominal and the real sample point
as well as the error of the sample point is displayed.

The output now looks like this:

Bit timing parameters for at91 with 100.000000 MHz ref clock
nominal                                 real Bitrt   nom  real SampP
Bitrate TQ[ns] PrS PhS1 PhS2 SJW BRP Bitrate Error SampP SampP Error     CAN_BR
1000000     50   7    7    5   1   5 1000000  0.0% 75.0% 75.0%  0.0% 0x00040664
 800000     50   8    8    8   1   5  800000  0.0% 80.0% 68.0% 15.0% 0x00040777
 500000    100   8    8    3   1  10  500000  0.0% 87.5% 85.0%  2.9% 0x00090772
 250000    250   6    7    2   1  25  250000  0.0% 87.5% 87.5%  0.0% 0x00180561
 125000    500   6    7    2   1  50  125000  0.0% 87.5% 87.5%  0.0% 0x00310561
 100000    500   8    8    3   1  50  100000  0.0% 87.5% 85.0%  2.9% 0x00310772
  50000   1250   6    7    2   1 125   50000  0.0% 87.5% 87.5%  0.0% 0x007c0561
  20000 ***bitrate not possible***
  10000 ***bitrate not possible***

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-07-20 13:43:12 +00:00
Marc Kleine-Budde ccd199739e can-calc-bit-timing: use algorithm from the kernel
This patch copies the algorithm functions (can_update_spt and
can_calc_bittiming) from the kernel. Then some glue code is added that
these functions compile in userspace.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-07-20 13:43:08 +00:00
Marc Kleine-Budde daed6be029 can-calc-bit-timing: fix indention
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-07-20 13:43:04 +00:00
Marc Kleine-Budde b2d3f4f735 add can-calc-bit-timing to Makefiles + gitignore
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-07-20 13:43:01 +00:00
Marc Kleine-Budde fa9c05021c add can-calc-bit-timing
Add the tool as sent by Wolfgang via email
(<4BE152D2.6060306@grandegger.com>).

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-07-20 13:42:57 +00:00
Oliver Hartkopp 5655d53acb Remove compiler warning :
warning: suggest explicit braces to avoid ambiguous ‘else’
2010-05-14 12:50:17 +00:00
Oliver Hartkopp 62c030b21f Added isotpserver in autotool config file and gitignore 2010-05-14 12:43:42 +00:00
Oliver Hartkopp b68a79ebde Added tiny ip server to send ISO 15765-2 PDUs via internetsockets to the CAN bus and vice versa. 2010-05-14 12:03:32 +00:00
Oliver Hartkopp c8247c8a57 Allow to have 4, 5 or 6 decimal places instead of only 4 & 6. 2010-05-11 10:01:49 +00:00
Marc Kleine-Budde 84e6b373f5 add autotools infrastructure
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-04-19 12:12:18 +00:00
Marc Kleine-Budde cfeb884137 add .gitignore
This may be usefull once the can-utils are migrated to git.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-04-19 12:12:04 +00:00
Marc Kleine-Budde f7be786e9a cangw: replace obsolete bzero by memset
uclibc for example doesn't implement bzero

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-04-19 12:11:49 +00:00
Oliver Hartkopp c6b3ceff83 Added CRC8 profiles to handle additional data for checksum generation. 2010-04-16 08:46:17 +00:00
Oliver Hartkopp 9e8f9200fb Added checksum functionality and some documentation in gw.h 2010-04-12 14:41:14 +00:00
Oliver Hartkopp a784e1e46f Complete rework of CAN netlink gateway.
Major changes:

- rework internal structures to prepare routings and modifications of CAN traffic also to non-CAN interfaces
- fix reading of netlink messages in cangw.c (added RTCAN_RTA / RTCAN_PAYLOAD macros)
- rework reading of gw-job lists in cgw_dump_jobs()
- rename of functions and API definitions to have a common namespace cgw_
- added infrastructure to perform crc8 and xor checksums in CAN frame data[]

TODO:

- add and test functionality for crc8 and xor checksums in CAN frame data[]
- add help text for crc8 and xor checksums in CAN frame data[]
2010-04-10 16:38:48 +00:00
Oliver Hartkopp ee562a9724 Some binaries in can-utils depend on features in the socket-can svn
repository. Building with exported headers from an unpatched kernel will
fail due to missing symbols or headers.

This patch adds two make variables to optionally disable building such
binaries, like this:

make PROGRAMS_ISOTP= PROGRAMS_CANGW= PROGRAMS_SLCAN= all

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
2010-03-17 19:21:38 +00:00
Oliver Hartkopp f731bbe2a2 To simplify packaging of can-utils, add DESTDIR and PREFIX support to
the can-utils Makefile.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net>
2010-03-17 19:12:26 +00:00
Oliver Hartkopp 3765e1d25b Initialize packet counters when printing each routing entry. 2010-03-04 10:59:24 +00:00
Oliver Hartkopp d81a13866b Rework of help text. 2010-02-27 16:07:58 +00:00
Oliver Hartkopp afa14f102d When sending a sequence, we need to resend the same frame when poll() returns.
Fixed that to be a valid data source e.g. for ptx cansequence.
2010-02-26 08:38:47 +00:00
Oliver Hartkopp e089e5d0ba Added commandline option '-p <timeout>' to enable polling on the writing socket.
Inspired by Marc Kleine-Budde :-)
2010-02-25 20:53:19 +00:00
Oliver Hartkopp 3a0612c14a Added funtionality to flush all GW jobs in one netlink message. 2010-02-23 19:13:17 +00:00
Oliver Hartkopp 37744ac503 Beautify the listing of registered gwjobs (cangw -L). 2010-02-22 18:57:45 +00:00
Oliver Hartkopp a48038d82b Added feature to list created gateway jobs.
Also added some fixes and removed debug printf's.
2010-02-22 09:57:12 +00:00
Oliver Hartkopp bd1ebaaf28 Added netlink error message support to be able to provide return values.
Renamed some structure elements. Updated usage text.
2010-02-21 12:34:34 +00:00
Oliver Hartkopp 0dc9fcc98e Moved kernel parsing of netlink attributes into can_can_parse_attr().
Added functionalitiy to remove formerly created CAN GW jobs.
2010-02-20 20:41:24 +00:00
Oliver Hartkopp 67b604e53b Added cangw netlink gateway configuration tool.
TODO (in both cangw and can-gw.ko) : Support removal and listing of rules.
So far the gateway jobs are only removed on can-gw.ko module unload or when
the used CAN netdevices disappear.
2010-02-19 13:33:59 +00:00
Oliver Hartkopp 9327499121 Try to ignore the usual value restrictions of sockopt SO_RCVBUF when running
as root (with CAP_NET_ADMIN) by using SO_RCVBUFFORCE if possible.
2010-01-15 19:15:08 +00:00
Oliver Hartkopp 3c019ea611 Added '-d' option to support the receive packet drop counting introduced in
http://git.kernel.org/?p=linux/kernel/git/davem/net-next-2.6.git;a=commitdiff;h=3b885787ea4112eaa80945999ea0901bf742707f

This is done by using recvmsg() instead of recvfrom() to allow the timestamp
and the dropcounter to be received within one syscall.

When the application (here 'candump') ist not fast enough to process the
incomming CAN frames the frames are dropped in the socket receive queue.
When this happens and '-d' is set, we get this info now:
DROPCOUNT: dropped 1 CAN frame on 'xxx' socket (total drops 1)
2010-01-15 18:35:37 +00:00
Oliver Hartkopp c11220e9c9 fflush the new configurable stdout output to allow proper pipe/netcat setups. 2009-11-25 18:51:31 +00:00
Oliver Hartkopp f135ce3d47 Allow to specify the name of the IP tunnel netdevice via commandline option '-n <name>' 2009-11-25 17:15:09 +00:00