4
\$\begingroup\$

I'm new to CAN and currently having problem with a setup.

Enter image description here

The image shows how my devices are connected to each other. I'm using the canutils Linux package to send messages (Linux uses its network layer to register and operate the CAN interfaces). So I start up the devices, bring up a terminal and type the following configuration commands on them:

ip link set can0 type can bitrate 125000 //This one registers an interface for can0 and sets the bit rate to 125000 bit/s.

ifconfig can0 up //Switches on the interface

At start, both devices' IDs are full null. Now, on one of the devices I switch on the listening state, which is:

candump can0

On the other one, I send out a message, something like this:

cansend 123#0x01 0x02 0x30 //123 specifies the ID, after "#" comes the data

Now, when this happens, the sender interface goes from error-active (normal state) to error-passive (error state). The "receiver" doesn't receive anything at all; it stays at error-active state. No messages are processed or catched, the log is clear (ip -d -s link show can0) and on the oscilloscope I can see the diff signal, and the sender is sending the message periodically, non-stop.

Maybe it's waiting for a response? I don't know if it's the whole message or just a fraction of it, but it sure changes with the given data, so I guess it's the whole message. And after that, if I try to send out another message with different data, the program just loads it into a buffer (I know this because after, like, 10 new cansends, it writes out that the buffer is full) and continues to broadcast the same old message. So I have to type canconfig stop -> canconfig start to restart the interface into error-active mode.

I'm sure that I'm messing up something fundamental, but I can't figure it out.

How can I fix this problem? Could it be a software or hardware issue, or maybe both?

\$\endgroup\$
6
  • \$\begingroup\$ Is this a software question or a hardware question? The latter is OK, but the former is off topic. It originally sounded like you were asking about the hardware, but all the details you give are relative to the Unix interface. \$\endgroup\$ Commented Sep 5, 2013 at 22:54
  • \$\begingroup\$ Well, yes, i dont know if its a hardware or a software problem, maybe both, so i thought i would ask it here, since a lot of electronic engineers are experts in embedded programming :) i will ask it on a software forum too. thanks for the reply btw. \$\endgroup\$
    – Thomas
    Commented Sep 6, 2013 at 4:39
  • \$\begingroup\$ Are baud rate of BOTH devices properly configured? I mean, do you execute same start up command for both devices? \$\endgroup\$
    – Swanand
    Commented Sep 9, 2013 at 13:03
  • \$\begingroup\$ Yes, both of them are set to 125k. Btw, i'm using the Angstrom distribution of linux. Setting up a virtual can interface works, so i guess that the package is working properly, maybe i'm messing up something with the hardware setup? \$\endgroup\$
    – Thomas
    Commented Sep 13, 2013 at 9:20
  • \$\begingroup\$ btw i tried to connect the mcp2515's can_tx with its rx pin too, shouldnt that create a working loopback? it is still switches to error-passive upon sending a message. \$\endgroup\$
    – Thomas
    Commented Sep 13, 2013 at 9:32

2 Answers 2

3
\$\begingroup\$

Now, on one of the devices I switch on the listening state

When a node is in Listen only mode, ACK is not sent for messages that have been received.That means, when Node A(Normal Mode,Error Active) sends a msg to Node B(Listen Only,Error Active),Node B doesnt send back ACK for msg's sent by Node A. As a result, Node A will retransmit automatically 127 times before going to Error Passive state automatically. In your setup, switch the Listen only node to Normal mode and check if the problem persists.

And after that, if I try to send out another message with different data, the program just loads it into a buffer (I know this because after, like, 10 new cansends, it writes out that the buffer is full) and continues to broadcast the same old message. So I have to type canconfig stop -> canconfig start to restart the interface into error-active mode.

When Node A(same situation as illustration above),now in error passive state,keeps sending the msg,still no ACK will be received. As a result, after 127 more counts,the Node A will go Bus off. Your Node A has never sent the data out of its buffer and hence your getting Buffer Full. Just Change Listen Only node to Normal mode. It should work.

\$\endgroup\$
-1
\$\begingroup\$

try

>canconfig can0 ctrlmode loopback off

before setting bitrate and bringing up the can0 interface. :)

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.