From: Daniel Squires <dan@engineeredarts.co.uk>
To: tom_usenet@optusnet.com.au, linux-can@vger.kernel.org
Subject: Re: socket can receive order
Date: Thu, 10 Sep 2015 09:08:30 +0100 [thread overview]
Message-ID: <55F13A7E.6020706@engineeredarts.co.uk> (raw)
In-Reply-To: <55F0EB15.30601@optusnet.com.au>
On 10/09/15 03:29, Tom Evans wrote:
> 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.
Yes, I had read that whole article and didn't use the hardware /
firmware there for those reasons. I needed 1Mbit also. I am using the
STM32F4 Discovery boards with a CAN phy attached. I didn't know where to
start with t kernel module which is why i am suing the one from there at
present, it would be nice to get a "standardised" usb class kernel
module, but i guess that would require input form the USB implementers
group.
>
> 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));
>
I hadn't noticed it could be done in that way, had been using ip
utility, but was aware of the 10 frames default queue size and that it
could be changed. In my very basic OOO test app i'm actually sending
packets with incrementing values until there is no space (send returns
ENOBUF), then doing the receives and checking the values until there is
nothing to receive, before continuing to send from the previous failed
value.
>
> http://socket-can.996257.n3.nabble.com/Solving-ENOBUFS-returned-by-write-td2886.html
>
>
> Tom
>
>
>
--
Dan Squires
Engineered Arts Ltd.
prev parent reply other threads:[~2015-09-10 8:08 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
2015-09-10 8:08 ` Daniel Squires [this message]
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=55F13A7E.6020706@engineeredarts.co.uk \
--to=dan@engineeredarts.co.uk \
--cc=linux-can@vger.kernel.org \
--cc=tom_usenet@optusnet.com.au \
/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.