All of lore.kernel.org
 help / color / mirror / Atom feed
* Bad reading from mcp2515 with j1939
@ 2016-04-15  9:54 Julien Pilet
  2016-04-15 10:19 ` Kurt Van Dijck
  2016-04-15 13:07 ` Ramesh Shanmugasundaram
  0 siblings, 2 replies; 9+ messages in thread
From: Julien Pilet @ 2016-04-15  9:54 UTC (permalink / raw)
  To: linux-can@vger.kernel.org

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.

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

end of thread, other threads:[~2016-04-18  5:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-15  9:54 Bad reading from mcp2515 with j1939 Julien Pilet
2016-04-15 10:19 ` 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

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.