0

I've trying some diagnostics over my ECU and for that, I need to send a particular message at every 50ms. I am using MCP2515 CAN BUS module and raspberry pi for communication. The problem is, when the program is initialised it works fine. But after few moments it gives the error,"Transmit Buffer Full". I tried to fix it by increasing the txqueuelen to 20000 but still I'm getting the same response.I have even tried the command bus.flush_tx_buffer that I found on a website but it seems that it is not working. I have been working over this for past two weeks and searched everywhere on the internet and couldn't find appropriate solution. Please help me out on this. I am using python-can 3.3.4 library for this project.

Here is my code:

bus = can.interface.Bus(channel = channel, bustype = bustype, bitrate = 500000)
s_msg = can.Message(arbitration_id=0x1860, data = [0x15, 0x40, 0x26, 0x90, 0x46, 0x78, 0x53, 0x79], is_extended_id=False)


i=0
while i > 0:

    bus.send(s_msg)
    print(s_msg)
    r_msg = bus.recv()
    print(r_msg)
    print(i)
    time.sleep(0.05)
    bus.flush_tx_buffer()

Here is the response when I ran ip -details -statistics link show 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 20000  (UNSPEC)
        RX packets 2266  bytes 18128 (17.7 KiB)
        RX errors 0  dropped 2266  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • It seems like nobody on the bus is ack'ing your packet and therefore the are pile up on the tx buffer. Is there anybody on the bus? is some node writing a zero (dominant level) on the ack time slot? – Fusho Feb 12 '22 at 09:46
  • Hello @Fusho, no I don't think the node is writing zero. The node, in response sends back data at very high speed (50ms), could that be the issue? – Vivek Parate Feb 12 '22 at 11:24
  • In a CAN-bus, if a node sends a packet and nobody acks during the ack-bit timeslot, that packet is assumed to be not successfully transmitted, so it stays on the tx buffer and queued for next pckt transmission: if you write more pkts on the buffer but no one is tx, then the buffer will run out of space. You somebody acking that bit, so the packet can be removed from the tx buffer. – Fusho Feb 12 '22 at 11:35
  • Thanks for the help @Fusho. Is there any command that can clear the transmit buffer (like the one I used `bus.flush_tx_buffer`)? The one I am using dosen't seems to be doing its job. – Vivek Parate Feb 12 '22 at 11:57
  • The problem will not be solved by flashing the txbuffer in any case (it will just get full again without tx anything...). If you are on Linux, could you paste the output of `ip -details -statistics link show can0`, where you have to change `can0` with the name of your interface. Which backend are you using, [socketCan](https://www.kernel.org/doc/Documentation/networking/can.txt)? – Fusho Feb 12 '22 at 12:17
  • Here is the Output. I will be sending it in two parts ``4: can0: mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 2000 link/can promiscuity 0 minmtu 0 maxmtu 0 can state ERROR-ACTIVE restart-ms 0 bitrate 500000 sample-point 0.750 tq 250 prop-seg 2 phase-seg1 3 phase-seg2 2 sjw 1 mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1 clock 4000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 0 0 0 numtxqueues 1 numrxqueues 1`` – Vivek Parate Feb 12 '22 at 12:24
  • `` gso_max_size 65536 gso_max_segs 65535 RX: bytes packets errors dropped missed mcast 1580219 198404 3 18 0 0 TX: bytes packets errors dropped carrier collsns 67776 8472 0 0 0 0 `` I am using socketCan. – Vivek Parate Feb 12 '22 at 12:26
  • I would suggest you paste it on your question with good formatting. OTOH, please, execute the command when the buffer is already full (if you are not already...) – Fusho Feb 12 '22 at 12:43
  • Also, it seems `is_extended_id` should be true since you are using more than 11 bits for `arbitration_id`. – Fusho Feb 12 '22 at 12:51
  • Okay i'll post it in the question. – Vivek Parate Feb 12 '22 at 12:58
  • Yes I kept the `is_extended_id true initially, but i got the desired output on standard ID – Vivek Parate Feb 12 '22 at 13:29
  • Hi @Fusho I have added the response in the question. – Vivek Parate Feb 16 '22 at 07:32
  • Do you have another device connected? Are you receiving messages from other devices? You can't send can messages without another device to ack them. – RufusVS Jul 12 '22 at 03:03

0 Answers0