Linux CAN drivers development
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Ratheendran <ba.rsrajeshwaran@tataelxsi.co.in>,
	Robert Schwebel <r.schwebel@pengutronix.de>,
	John Whitmore <arigead@gmail.com>,
	Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Cc: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: Re: detect auto baud rate on can bus in linux driver.
Date: Wed, 30 Apr 2014 18:35:12 +0200	[thread overview]
Message-ID: <53612640.90106@hartkopp.net> (raw)
In-Reply-To: <20140430144124.GC28036@vandijck-laurijssen.be>

On 30.04.2014 16:41, Kurt Van Dijck wrote:
> Hey,
> 
> On Wed, Apr 30, 2014 at 05:42:22PM +0530, Ratheendran wrote:
>> Thanks again, I Appreciate your support, this has helped my understanding
>> ,build confidence on socketcan.
> [...]
>> Hi kurt,
>>
>> I am not able to set the timeout scenario for candump command, do i need to
>> send a killall signal to candump after a wait period.
>>
> 
> I believe this approach is a good one, but the timeout thing is the tricky part.
> I'll take a look next few days.
> 

There is already an option '-T <msecs>' for this in the latest candump on the
latest gitorious can-utils git:

Usage: candump [options] <CAN interface>+
  (use CTRL-C to terminate candump)

Options: -t <type>   (timestamp: (a)bsolute/(d)elta/(z)ero/(A)bsolute w date)
         -c          (increment color mode level)
         -i          (binary output - may exceed 80 chars/line)
         -a          (enable additional ASCII output)
         -S          (swap byte order in printed CAN data[] - marked with '`' )
         -s <level>  (silent mode - 0: off (default) 1: animation 2: silent)
         -b <can>    (bridge mode - send received frames to <can>)
         -B <can>    (bridge mode - like '-b' with disabled loopback)
         -u <usecs>  (delay bridge forwarding by <usecs> microseconds)
         -l          (log CAN-frames into file. Sets '-s 2' by default)
         -L          (use log file format on stdout)
         -n <count>  (terminate after receiption of <count> CAN frames)
         -r <size>   (set socket receive buffer to <size>)
         -d          (monitor dropped CAN frames)
         -e          (dump CAN error frames in human-readable format)
         -x          (print extra message infos, rx/tx brs esi)
         -T <msecs>  (terminate after <msecs> without any reception)

So 

	candump -T 1000 -n 4 can0 | wc -l

would produce values from 1 to 4 when there was some traffic within one
second of reception or zero when not traffic was detected.

if [ `candump -T 1000 -n 4 can0 | wc -l` -ne 0 ]; then

	echo "traffic";
else
	echo "nothing";
fi

So updating your can-utils helps :-)

Regards,
Oliver

 

  reply	other threads:[~2014-04-30 16:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24 13:20 detect auto baud rate on can bus in linux driver Ratheendran
2014-04-27  9:44 ` John Whitmore
2014-04-27 18:01   ` Kurt Van Dijck
2014-04-29  8:33     ` Ratheendran S. Rajeshwaran
2014-04-29  8:35       ` Ratheendran S. Rajeshwaran
2014-04-29 19:58       ` Robert Schwebel
     [not found]         ` <5360E8A6.8040204@tataelxsi.co.in>
2014-04-30 14:41           ` Kurt Van Dijck
2014-04-30 16:35             ` Oliver Hartkopp [this message]
2014-05-01 18:49               ` Kurt Van Dijck
     [not found]                 ` <5363243E.7070406@tataelxsi.co.in>
2014-05-02 11:00                   ` Kurt Van Dijck
2014-04-29 12:47     ` Heinz-Jürgen Oertel
     [not found]       ` <535FA7BB.3070700@tataelxsi.co.in>
2014-04-29 14:12         ` Heinz-Jürgen Oertel
     [not found]     ` <535F5449.7000108@tataelxsi.co.in>
2014-04-29 13:33       ` Kurt Van Dijck
2014-04-29 14:12         ` Wolfgang Grandegger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53612640.90106@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=arigead@gmail.com \
    --cc=ba.rsrajeshwaran@tataelxsi.co.in \
    --cc=dev.kurt@vandijck-laurijssen.be \
    --cc=linux-can@vger.kernel.org \
    --cc=r.schwebel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox