linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julien Pilet <julien@anemomind.com>
To: "linux-can@vger.kernel.org" <linux-can@vger.kernel.org>
Subject: Bad reading from mcp2515 with j1939
Date: Fri, 15 Apr 2016 11:54:40 +0200	[thread overview]
Message-ID: <136B5347-DD98-4021-98C5-2FD18FC925A4@anemomind.com> (raw)

Hi,

I am using a MCP2515 for a nautical application. It turns out that in my lab, everything goes fine. On two boats, though, I get strange readings from can0.

I connected the MCP2515 to a sensor reporting a boat speed of 0 m/s.
  can0  09F50323   [8]  79 00 00 FF FF 00 FF FF

The first data byte is the sequence ID, it is incremented in each packet.
The two following bytes encode the boat speed.

candump gives me the following:

  can0  09F50323   [8]  7A 00 00 FF FF 00 FF FF
  can0  09F50323   [8]  7B 00 00 FF FF 00 FF FF
  can0  09F50323   [8]  7C 00 00 FF FF 00 FF FF
  can0  09F50323   [8]  7D 00 00 FF FF 00 FF FF
  can0  09F50323   [8]  7E 00 00 FF FF 00 FF FF
  can0  09F50323   [8]  7F 00 00 FF FF 00 FF FF
  can0  09F50323   [8]  80 80 00 FF FF 00 FF FF
  can0  09F50323   [8]  81 00 00 FF FF 00 FF FF
  can0  09F50323   [8]  82 80 00 FF FF 00 FF FF
  can0  09F50323   [8]  83 00 00 FF FF 00 FF FF
  can0  09F50323   [8]  84 80 00 FF FF 00 FF FF
  can0  09F50323   [8]  85 00 00 FF FF 00 FF FF
  can0  09F50323   [8]  86 80 00 FF FF 00 FF FF

Suddenly, when SID reaches 0x80, the speed is not 0 anymore: it is 0x0080 (encoded little endian 80 00). This is clearly wrong.
I observed similar problems with sensors of different manufacturers, so I do not think the sensor is faulty. 
The pattern repeats: for seq ID between 00 and 0x79, everything works fine. For seq ID 0x80 - 0xFA (the last seq ID sent) every packet with an even sequence ID has a spurious bit set in the 2nd byte.

I failed to reproduce the error in the lab, so it is hard for me to plug a oscilloscope and observe what is going on. I observe no error when transmitting the same data on my test network (which is much shorter and simpler than a real one).

Did I miss something in the configuration ? How is it possible that bad packets pass through?

Here’s how my configuration looks like:

# ifconfig can0
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:22823 errors:3 dropped:0 overruns:0 frame:3
          TX packets:7 errors:1 dropped:1 overruns:0 carrier:1
          collisions:0 txqueuelen:10 
          RX bytes:182584 (178.3 KiB)  TX bytes:31 (31.0 B)

# ./bin/ip -details link show can0
5: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10
    link/can 
    can <TRIPLE-SAMPLING> state ERROR-PASSIVE restart-ms 0 
    bitrate 250000 sample-point 0.875 
    tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
    mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
    clock 8000000
    j1939 on

I’m using a 3.10.17 kernel modified by Intel for their Edison module. I patched it with j1939-v3.10.

Any idea or suggestion would be appreciated!

Thanks,
Julien.

             reply	other threads:[~2016-04-15  9:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15  9:54 Julien Pilet [this message]
2016-04-15 10:19 ` Bad reading from mcp2515 with j1939 Kurt Van Dijck
2016-04-15 13:02   ` Julien Pilet
2016-04-15 14:52     ` Wolfgang Grandegger
2016-04-15 16:25       ` Julien Pilet
2016-04-15 16:34         ` Wolfgang Grandegger
2016-04-18  5:48           ` Wolfgang Grandegger
2016-04-18  4:29         ` Tom Evans
2016-04-15 13:07 ` Ramesh Shanmugasundaram

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=136B5347-DD98-4021-98C5-2FD18FC925A4@anemomind.com \
    --to=julien@anemomind.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).