All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: "Max S." <max@schneidersoft.net>
Cc: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>,
	Wolfgang Grandegger <wg@grandegger.com>
Subject: Re: GS_USB
Date: Mon, 11 Nov 2013 22:49:39 +0100	[thread overview]
Message-ID: <528150F3.8090406@hartkopp.net> (raw)
In-Reply-To: <1384199350.3483.20.camel@blackbox>



On 11.11.2013 20:49, Max S. wrote:
> Hmm. Seems I missed something.
> 


>>>
>>> http://lxr.free-electrons.com/source/Documentation/networking/can.txt#L891
>>>
>>>
>>
>> Yes.
>>
>> Usually the CAN controller sits in BUS_OFF until it detects correct CAN frames
>> _or_ until the controller is re-initialized.
> 
> From the CAN2.0A spec chapter 7
> 12. An node which is ’bus off’ is permitted to become ’error active’ (no
> longer ’bus off’) with its error counters both set to 0 after 128
> occurrence of 11 consecutive ’recessive’ bits have been monitored on the
> bus.

Hm - I assume this does not mean 128*11 bits but 128 occurences of 11
consecutive ’recessive’ bits with at least one dominant bit in between.
But I'm not sure about that.

> 
> So: When the controller goes into bus off because of a short on can high
> to low. It will inevitably observe recessive bits. and consequently come
> back out of bus off. It will then attempt to resend and hit bus off
> again. rinse & repeat.


> 
> Why is it necessary to be able to get the controller out of bus off
> manually?

Think about a misconfigured bitrate.
The application should decide if it's better to stay calm (in BUS_OFF) or
whether it should try to re-initialize the CAN controller and start again.

> 
> I was able to improve the firmware to make status updates faster.
> The following is the current state: @250K bitrate
>  (000.000011)  can0  20000040   [8]  00 00 00 00 00 00 00 01  ERRORFRAME
> 	bus-off
> 	error-counter-tx-rx{{0}{1}}
>  (000.005980)  can0  20000100   [8]  00 00 00 00 00 00 00 80  ERRORFRAME
> 	restarted-after-bus-off
> 	error-counter-tx-rx{{0}{128}}
>  (000.000013)  can0  20000008   [8]  00 00 40 00 00 00 00 00  ERRORFRAME
> 	protocol-violation{{back-to-error-active}{}}
>  (000.000006)  can0  20000004   [8]  00 08 00 00 00 00 60 00  ERRORFRAME
> 	controller-problem{tx-error-warning}
> 	error-counter-tx-rx{{96}{0}}
>  (000.000008)  can0  20000004   [8]  00 20 00 00 00 00 80 00  ERRORFRAME
> 	controller-problem{tx-error-passive}
> 	error-counter-tx-rx{{128}{0}}
>  (000.002014)  can0  20000040   [8]  00 00 00 00 00 00 00 01  ERRORFRAME
> 	bus-off
> 	error-counter-tx-rx{{0}{1}}
> 
>>
>> The CAN controller should not recover itself as this might be wrong depending
>> on the use-case.
> 
> Is recovery (getting out of bus off) not part of the CAN spec?

As discussed above the controller get's out of the BUS_OFF state when
receiving correct CAN traffic.

Or by kicking the controller by restarting it :-)

> 
>>
>> Therefore the manual "restart" can be initiated by some user application or it
>> can be handled inside the driver e.g. 200ms after a BUS_OFF detection by the
>> "restart-ms" option.
>>

Regards,
Oliver

  parent reply	other threads:[~2013-11-11 21:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-04 12:31 GS_USB Max S.
2013-10-04 13:23 ` GS_USB Marc Kleine-Budde
2013-10-05 20:36 ` GS_USB Wolfgang Grandegger
2013-10-07 14:22   ` GS_USB Max S.
2013-10-07 14:37     ` GS_USB Wolfgang Grandegger
2013-10-07 19:52       ` GS_USB Max S.
2013-10-07 20:30         ` GS_USB Wolfgang Grandegger
2013-11-03 17:12           ` GS_USB Max S.
2013-11-03 19:42             ` GS_USB Wolfgang Grandegger
2013-11-09 23:19             ` GS_USB Wolfgang Grandegger
2013-11-11  2:10               ` GS_USB Max S.
2013-11-11  8:05                 ` GS_USB Wolfgang Grandegger
2013-11-11 15:41                   ` GS_USB Oliver Hartkopp
     [not found]                     ` <1384199350.3483.20.camel@blackbox>
2013-11-11 21:49                       ` Oliver Hartkopp [this message]
2013-11-15 10:39                         ` GS_USB Max S.
2013-11-23 16:05                           ` GS_USB Max S.
2013-12-04 21:17                             ` GS_USB Max S.
2013-12-05 19:05                               ` GS_USB Oliver Hartkopp
2013-12-05 19:07                                 ` GS_USB Oliver Hartkopp
2013-12-09 17:53                                   ` GS_USB Max S.
2013-12-05 20:18                               ` GS_USB Wolfgang Grandegger
2013-12-05 20:42                                 ` GS_USB Wolfgang Grandegger
2013-12-07 10:06                             ` GS_USB Wolfgang Grandegger
2013-12-09 10:52                               ` GS_USB Marc Kleine-Budde
2013-12-09 13:15                                 ` GS_USB 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=528150F3.8090406@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=max@schneidersoft.net \
    --cc=wg@grandegger.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.