Device Stops Broadcasting After Certain Number of Messages

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
alexeg
Posts: 2
Joined: Wed 11. May 2022, 21:01

Device Stops Broadcasting After Certain Number of Messages

Post by alexeg » Wed 11. May 2022, 21:40

Hello,

I am using PEAK-USB on Linux using the netdev drivers included in the kernel. I just have the USB connected with terminators at both ends of a empty CAN line. There are no other devices on the bus, just trying to get this to be able to broadcast messages first. I am able to set up the device:

Code: Select all

sudo ip link set can0 type can bitrate 1000000
sudo ifconfig can0 txqueuelen 1000
sudo ip link set up can0
Then, to test to make sure it is broadcasting messages, I run this simple script to continue sending messages up to the counter:

Code: Select all

i=1
while (( $i<50 ))
do
cansend can0 1FF#FFFFF00000000000
sleep 1
((++i))
done
To read the messages I just use candump in another terminal window:

Code: Select all

candump can0
After 33 messages it stops coming through. I can see the code is still running (until the counter runs out) as expected, but no more messages are coming through on the candump output:

Code: Select all

candump can0
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
  can0  1FF   [8]  FF FF F0 00 00 00 00 00
It seems there may be an error occurring somewhere, but I'm not sure where. I can see that there are some dropped messages and carrier messages with the ifconfig. And there may be some errors on the bus, but not sure what they are:

Code: Select all

ip -details -statistics link show can0
5: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/can  promiscuity 0 minmtu 0 maxmtu 0 
    can state ERROR-PASSIVE (berr-counter tx 0 rx 0) restart-ms 0 
	  bitrate 1000000 sample-point 0.750 
	  tq 125 prop-seg 2 phase-seg1 3 phase-seg2 2 sjw 1
	  pcan_usb: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
	  clock 8000000 
	  re-started bus-errors arbit-lost error-warn error-pass bus-off
	  0          0          0          51         51         0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    RX: bytes  packets  errors  dropped overrun mcast   
    816        102      0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 

Code: Select all

ifconfig can0
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 102  bytes 816 (816.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 111  bytes 888 (888.0 B)
        TX errors 0  dropped 20 overruns 0  carrier 20  collisions 0
Unsure of what to do about this, any help would be appreciated.
Thank you,
Alex

M.Maidhof
Support
Support
Posts: 1468
Joined: Wed 22. Sep 2010, 14:00

Re: Device Stops Broadcasting After Certain Number of Messages

Post by M.Maidhof » Thu 12. May 2022, 09:39

Hi,

a CAN bus needs at least a second CAN node which will acknowledge the CAN frames on the physical layer of the CAN bus sytem. In your case you will generate acknowledge errors in the CAN controller, and the sender will stop transmitting new frames because the TX queues are full. Have a look on the CAN with a scope, so that you will see that the CAN controller will repeat the same message until it will be acknowledged. Using CAN with just one node is like having one phone but no one to talk to...

regards

Michael

alexeg
Posts: 2
Joined: Wed 11. May 2022, 21:01

Re: Device Stops Broadcasting After Certain Number of Messages

Post by alexeg » Thu 12. May 2022, 21:28

Hello,

Thank you for the response. Yes, that seems to have done the trick. I plugged it into another device that can read CAN messages and that ended up working (after I set the correct baudrate). I am relatively new to CAN protocol so I didn't realize there was a need for the message to be acknowledged by at least 1 other receiver in order for the transmitter to continue broadcasting.

Thank you for the help!
Alex

Post Reply