All of lore.kernel.org
 help / color / mirror / Atom feed
* Full Buffers and the Passive bus
@ 2012-08-31 16:36 Andrew Bell
  2012-08-31 16:49 ` Oliver Hartkopp
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Bell @ 2012-08-31 16:36 UTC (permalink / raw)
  To: linux-can

Is there some way within socket CAN to detect the state when no nodes
are on the BUS?  I do get CAN_ERR_TX_TIMEOUT error frames after some
time, but I'm writing to the BUS faster than frames drain from the
buffers, so eventually buffers fill up and writes start failing.  In
this case, write does return ENOBUFS.  But I'd like to be able to
differentiate between the case where buffers are full because of some
transient condition (I'm writing too fast for the BUS) and the
condition when nobody is home to receive anything at all.

Suggestions appreciated.

--
Andrew Bell
andrew.bell.ia@gmail.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Full Buffers and the Passive bus
  2012-08-31 16:36 Full Buffers and the Passive bus Andrew Bell
@ 2012-08-31 16:49 ` Oliver Hartkopp
  2012-08-31 16:52   ` Andrew Bell
  2012-08-31 17:37   ` Kurt Van Dijck
  0 siblings, 2 replies; 6+ messages in thread
From: Oliver Hartkopp @ 2012-08-31 16:49 UTC (permalink / raw)
  To: Andrew Bell; +Cc: linux-can

On 31.08.2012 18:36, Andrew Bell wrote:

> Is there some way within socket CAN to detect the state when no nodes
> are on the BUS?  I do get CAN_ERR_TX_TIMEOUT error frames after some
> time, but I'm writing to the BUS faster than frames drain from the
> buffers, so eventually buffers fill up and writes start failing.  In
> this case, write does return ENOBUFS.  But I'd like to be able to
> differentiate between the case where buffers are full because of some
> transient condition (I'm writing too fast for the BUS) and the
> condition when nobody is home to receive anything at all.
> 
> Suggestions appreciated.


Hello Andrew,

this first idea was to check, if the successful transmissions increase the tx
counter in the netdevice statistics. When there's no increasing value no
frames have been sent on the wire.

But maybe there's another suggestion out there ...

Regards,
Oliver


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Full Buffers and the Passive bus
  2012-08-31 16:49 ` Oliver Hartkopp
@ 2012-08-31 16:52   ` Andrew Bell
  2012-08-31 16:53     ` Andrew Bell
  2012-08-31 17:32     ` Oliver Hartkopp
  2012-08-31 17:37   ` Kurt Van Dijck
  1 sibling, 2 replies; 6+ messages in thread
From: Andrew Bell @ 2012-08-31 16:52 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: linux-can

On Fri, Aug 31, 2012 at 11:49 AM, Oliver Hartkopp
<socketcan@hartkopp.net> wrote:
> On 31.08.2012 18:36, Andrew Bell wrote:
>
>> Is there some way within socket CAN to detect the state when no nodes
>> are on the BUS?  I do get CAN_ERR_TX_TIMEOUT error frames after some
>> time, but I'm writing to the BUS faster than frames drain from the
>> buffers, so eventually buffers fill up and writes start failing.  In
>> this case, write does return ENOBUFS.  But I'd like to be able to
>> differentiate between the case where buffers are full because of some
>> transient condition (I'm writing too fast for the BUS) and the
>> condition when nobody is home to receive anything at all.
>>
>> Suggestions appreciated.
>
>
> Hello Andrew,
>
> this first idea was to check, if the successful transmissions increase the tx
> counter in the netdevice statistics. When there's no increasing value no
> frames have been sent on the wire.

Thanks for the idea.

What is the interface/API for getting these statistics?

-- 
Andrew Bell
andrew.bell.ia@gmail.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Full Buffers and the Passive bus
  2012-08-31 16:52   ` Andrew Bell
@ 2012-08-31 16:53     ` Andrew Bell
  2012-08-31 17:32     ` Oliver Hartkopp
  1 sibling, 0 replies; 6+ messages in thread
From: Andrew Bell @ 2012-08-31 16:53 UTC (permalink / raw)
  Cc: linux-can

On Fri, Aug 31, 2012 at 11:52 AM, Andrew Bell <andrew.bell.ia@gmail.com> wrote:
> On Fri, Aug 31, 2012 at 11:49 AM, Oliver Hartkopp
> <socketcan@hartkopp.net> wrote:
>> On 31.08.2012 18:36, Andrew Bell wrote:
>>
>>> Is there some way within socket CAN to detect the state when no nodes
>>> are on the BUS?  I do get CAN_ERR_TX_TIMEOUT error frames after some
>>> time, but I'm writing to the BUS faster than frames drain from the
>>> buffers, so eventually buffers fill up and writes start failing.  In
>>> this case, write does return ENOBUFS.  But I'd like to be able to
>>> differentiate between the case where buffers are full because of some
>>> transient condition (I'm writing too fast for the BUS) and the
>>> condition when nobody is home to receive anything at all.
>>>
>>> Suggestions appreciated.
>>
>>
>> Hello Andrew,
>>
>> this first idea was to check, if the successful transmissions increase the tx
>> counter in the netdevice statistics. When there's no increasing value no
>> frames have been sent on the wire.
>
> Thanks for the idea.
>
> What is the interface/API for getting these statistics?
>
> --
> Andrew Bell
> andrew.bell.ia@gmail.com



-- 
Andrew Bell
andrew.bell.ia@gmail.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Full Buffers and the Passive bus
  2012-08-31 16:52   ` Andrew Bell
  2012-08-31 16:53     ` Andrew Bell
@ 2012-08-31 17:32     ` Oliver Hartkopp
  1 sibling, 0 replies; 6+ messages in thread
From: Oliver Hartkopp @ 2012-08-31 17:32 UTC (permalink / raw)
  To: Andrew Bell; +Cc: linux-can

On 31.08.2012 18:52, Andrew Bell wrote:

> On Fri, Aug 31, 2012 at 11:49 AM, Oliver Hartkopp
> <socketcan@hartkopp.net> wrote:
>> On 31.08.2012 18:36, Andrew Bell wrote:
>>
>>> Is there some way within socket CAN to detect the state when no nodes
>>> are on the BUS?  I do get CAN_ERR_TX_TIMEOUT error frames after some
>>> time, but I'm writing to the BUS faster than frames drain from the
>>> buffers, so eventually buffers fill up and writes start failing.  In
>>> this case, write does return ENOBUFS.  But I'd like to be able to
>>> differentiate between the case where buffers are full because of some
>>> transient condition (I'm writing too fast for the BUS) and the
>>> condition when nobody is home to receive anything at all.
>>>
>>> Suggestions appreciated.
>>
>>
>> Hello Andrew,
>>
>> this first idea was to check, if the successful transmissions increase the tx
>> counter in the netdevice statistics. When there's no increasing value no
>> frames have been sent on the wire.
> 
> Thanks for the idea.
> 
> What is the interface/API for getting these statistics?
> 


/sbin/ifconfig reads /proc/net/dev for this reason.

But strace /sbin/ifstat turns out, that ifstat uses AF_NETLINK sockets.

(..)
socket(PF_NETLINK, SOCK_RAW, 0)         = 4
setsockopt(4, SOL_SOCKET, SO_SNDBUF, [32768], 4) = 0
setsockopt(4, SOL_SOCKET, SO_RCVBUF, [1048576], 4) = 0
bind(4, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
getsockname(4, {sa_family=AF_NETLINK, pid=5009, groups=00000000}, [12]) = 0
time(NULL)                              = 1346434087
send(4, "\34\0\0\0\22\0\1\3(\364@P\0\0\0\0\2\0\0\0\10\0\35\0\1\0\0\0", 28, 0) = 28
recvmsg(4, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\374\3\0\0\20\0\2\0(\364@P\221\23\0\0\0\0\4\3\1\0\0\0I\0\1\0\0\0\0\0"..., 16384}], msg_controllen=0, msg_flags=0}, 0) = 3652
recvmsg(4, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"8\2\0\0\20\0\2\0(\364@P\221\23\0\0\0\0\30\1\5\0\0\0\301\0\1\0\0\0\0\0"..., 16384}], msg_controllen=0, msg_flags=0}, 0) = 1704
recvmsg(4, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0(\364@P\221\23\0\0\0\0\0\0\5\0\0\0\301\0\1\0\0\0\0\0"..., 16384}], msg_controllen=0, msg_flags=0}, 0) = 20
close(4)                                = 0
(..)

I would try the AF_NETLINK method, but i have no sample code at hand.

Please check out for the ifstat code yourself.

Regards,
Oliver

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Full Buffers and the Passive bus
  2012-08-31 16:49 ` Oliver Hartkopp
  2012-08-31 16:52   ` Andrew Bell
@ 2012-08-31 17:37   ` Kurt Van Dijck
  1 sibling, 0 replies; 6+ messages in thread
From: Kurt Van Dijck @ 2012-08-31 17:37 UTC (permalink / raw)
  To: Oliver Hartkopp; +Cc: Andrew Bell, linux-can

On Fri, Aug 31, 2012 at 06:49:02PM +0200, Oliver Hartkopp wrote:
> On 31.08.2012 18:36, Andrew Bell wrote:
> 
> > Is there some way within socket CAN to detect the state when no nodes
> > are on the BUS?  I do get CAN_ERR_TX_TIMEOUT error frames after some
> > time, but I'm writing to the BUS faster than frames drain from the
> > buffers, so eventually buffers fill up and writes start failing.  In
> > this case, write does return ENOBUFS.  But I'd like to be able to
> > differentiate between the case where buffers are full because of some
> > transient condition (I'm writing too fast for the BUS) and the
> > condition when nobody is home to receive anything at all.
> > 
> > Suggestions appreciated.
> 
> 
> Hello Andrew,
> 
> this first idea was to check, if the successful transmissions increase the tx
> counter in the netdevice statistics. When there's no increasing value no
> frames have been sent on the wire.
> 
> But maybe there's another suggestion out there ...

Successfull transmissions generate incoming messages if CAN_RAW_RECV_OWN_MSGS
is set ...

The use case I have in mind (and successfully implemented) is to catch
a bootloader on the bus in its bootloader state. I guess we all know this
use case.

In case no frames get out since the PC is alone, I see no loopback'd frames
of myself, so I need not repeating my 'catch frame' again.
If I receive my loopback'd 'catch frame', I know I must repeat it within
a specified time interval.

Kind regards,

-- 
Kurt Van Dijck
GRAMMER EiA ELECTRONICS
http://www.eia.be
kurt.van.dijck@eia.be
+32-38708534

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-31 17:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-31 16:36 Full Buffers and the Passive bus Andrew Bell
2012-08-31 16:49 ` Oliver Hartkopp
2012-08-31 16:52   ` Andrew Bell
2012-08-31 16:53     ` Andrew Bell
2012-08-31 17:32     ` Oliver Hartkopp
2012-08-31 17:37   ` Kurt Van Dijck

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.