Electronic – Issue with CAN communication

can

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?

Best Answer

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.