All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Evans <tom_usenet@optusnet.com.au>
To: Daniel Squires <dan@engineeredarts.co.uk>, linux-can@vger.kernel.org
Subject: Re: socket can receive order
Date: Thu, 10 Sep 2015 12:29:41 +1000	[thread overview]
Message-ID: <55F0EB15.30601@optusnet.com.au> (raw)
In-Reply-To: <55EECAAE.1020901@grandegger.com>

On 08/09/15 21:46, Wolfgang Grandegger wrote:
>
> Am 08.09.2015 um 13:13 schrieb Marc Kleine-Budde:
>> On 09/08/2015 12:41 PM, Daniel Squires wrote:
>>> On my laptop and Desktop PC I have not seen it happen.
>> I mean what kind of CAN adapter...
>
> "https://github.com/fabiobaltieri/open-usb-can" seems to use a MCP2515
> controller.

http://fabiobaltieri.com/2013/07/23/hacking-into-a-vehicle-can-bus-toyothack-and-socketcan/#more-1419

"my own open hardware USB AVR + MCP2515 interface", "the performances are not 
that good above 250kbps", "It’s tempting to use an SPI controller (the MCP2515 
is very common), but that has terrible performances on highly loaded fast 
busses, and you will end up with problem such as RX buffer underruns and 
out-of-order frames."

He means "overruns". The MCP2515 doesn't have a FIFO. Messages have to be read 
out over a slow SPI bus one bit at a time within one message time or it 
overruns. Or two if the BUKT bit is set, but that risks reading messages in 
the wrong order.

The design uses an ATMEGA32U2 and an MCP2515. I can't see why it shouldn't be 
able to buffer messages from the MCP2515 at relatively high data rates, if the 
code is well written. From my experience though, code for the MCP2515 is 
seldom "well written". It is too easy to fall into a trap and get the message 
arrival order wrong.

This is unlikely to be related to the OP's problem, but just something to be 
aware of.

For anybody still coding and debugging MCP2515 stuff:

http://www.microchip.com/forums/m620741.aspx

 > otherwise its prone to loosing TX packets when loaded.

Do you know about having to do something like the following to stop CAN 
Transmit Drops? The networking stack defaults to DROPPING CAN transmit frames 
before blocking the socket if you don't.

     /bin/echo 256 > /sys/class/net/can0/tx_queue_len
     ...
     int sndbuf = (250 + 8) * 256;
     socklen_t socklen = sizeof(sndbuf);
     /* Minimum socket buffer to try and get it blocking */
     rc = setsockopt(pSkt->skt, SOL_SOCKET, SO_SNDBUF,
                     &sndbuf, sizeof(sndbuf));


http://socket-can.996257.n3.nabble.com/Solving-ENOBUFS-returned-by-write-td2886.html

Tom




  parent reply	other threads:[~2015-09-10  2:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-08  9:42 socket can receive order Daniel Squires
2015-09-08 10:01 ` Marc Kleine-Budde
2015-09-08 10:41   ` Daniel Squires
2015-09-08 11:13     ` Marc Kleine-Budde
2015-09-08 11:17       ` Daniel Squires
2015-09-08 11:20         ` Marc Kleine-Budde
2015-09-08 11:37           ` Daniel Squires
2015-09-08 16:56         ` Oliver Hartkopp
2015-09-09  2:30           ` Austin Schuh
2015-09-09  3:10             ` Brian Silverman
2015-09-09 16:23               ` Oliver Hartkopp
2015-09-09 12:05             ` Daniel Squires
2015-09-09 16:14             ` Daniel Squires
2015-09-09 16:31               ` Oliver Hartkopp
2015-09-17 19:18               ` Oliver Hartkopp
2015-09-08 11:46       ` Wolfgang Grandegger
2015-09-08 11:49         ` Daniel Squires
2015-09-08 11:56         ` Marc Kleine-Budde
2015-09-10  2:29         ` Tom Evans [this message]
2015-09-10  8:08           ` Daniel Squires

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=55F0EB15.30601@optusnet.com.au \
    --to=tom_usenet@optusnet.com.au \
    --cc=dan@engineeredarts.co.uk \
    --cc=linux-can@vger.kernel.org \
    /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.