-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Candump losing frames on Rasbperry Pi #335
Comments
This sending setup starts three processes which are scheduled by the system - and probably not in-time. https://docs.kernel.org/networking/can.html#broadcast-manager-protocol-sockets-sock-dgram If you want to stay with can-utils tools you can also forge a logfile to send/replay it with 'canplayer`.
Please try: The resulting logfile is the standard compact (but readable) SocketCAN logfile format and can also be converted with In your case it might be
I assume the problems to be fixed with the hints from above. |
I made a log file logsnd.log with requests to replay it with canplayer via candump. I got such kind of log: and put canplayer into script cansnd.sh: Then I changed candump command to: Results:
|
Good!
Next step would be to increase the TX queue len in the CAN driver to be more robust against arbitration lost due to the traffic from the outside:
By default the txqueuelen is 10. |
With TX queue value 500, I recorded 6 files, only 2 of them were without data lost. I tried also to increase this value to 3000, 5000 and so on. At 8000 1 file out of 10 was with data lost. Should I continue with increasing this value? Is there any limitation on that? Why did you suggest 500? |
500 was just a guess to see what happens.
I assume either the MCP2515/SPI to cause the issue OR the physical settings (bitrate/sample-point/bus-termination). Which is your communication counterpart CAN node? Is the CAN bus terminated correctly with 2 x 120 Ohms? |
In CANalyzer statistic window, the maximum bus load was detected as 19.97%. I think the same value should be visible with Regarding physical settings, bitrate 250kbps is proper as this is configured inside ECU.
I'm communicating with real ECU for vehicle. Resistance between CAN H & CAN L was just measured and equals to 60.4 Ohms, also proper. Could you please tell me more about |
E.g. the Seeed CAN FD CAN HAT seems to support up to 40MHz SPI clock https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/seeed-can-fd-hat-v2-overlay.dts While your RS485 CAN HAT https://www.waveshare.com/wiki/RS485_CAN_HAT seems to support 1MHz or 2MHz. That doesn't seem that much. And sending & receiving might then be more tricky than just receiving. When you have a CANalyser: Did you check, what happens if you remove the ECU and switch the RasPi and the CANalyser to 1MBit/s bitrate and create CAN traffic loads (with the PC or RasPi)? |
That seems more powerful board, but also more expensive. The goal is to create a device using the cheapest solutions
I made a CANalyzer script, that is sending random messages with ID 0x7F1 every 10 ms 157 times. ECU is disconnected and I put a resistance to CAN bus. CANalyzer HW is configured for 1Mbps. Additional frames are presented in bus. Max load is 3.09%. So I run several times candump and in parallel run script on PC to send 7F1 frames. In every case, I get logs with data missing. |
Args! That looks like some IRQ/wakeup/SPI issue :-/ Maybe @marckleinebudde can help with this as he is pretty deep in the MCP2518FD & SPI topic AFAIK ... |
Try running the raspi at full clock speed:
|
When I run this command in terminal it looks like some process is going on and I can't even close this. Only switch power off/on. Should I put it to background by |
Run that command before attaching the system to the CAN bus. Does a simple
|
Yes, sudo works. Ok I will try to put it to rc.local file before can bus up command. |
|
Can I verify current configuration for CPU by this command? |
|
I found a solution to make all CPU* run in performance mode, executing it in terminal: |
So, when I enabled performance mode, I recorded 25 files. Only 13 of them are good, In other files, I see 1 or 2 frames missed. During logging of 5th, 6th and 7th files, I noticed the error message in CANalyzer trace. After 7th file, the error got freezed and not updated anymore. |
Is the outcome better or worse? |
Seems, it becomes more stable, as earlier I saw more data missed.
I think, it's related to CANalyzer Tx frame, which I generate to simulate vehicle bus. |
So there's a BIT error on the bus. Is that due to a software problem on the raspi? Don't think so. |
I think no, because in ID line there is ID of the frame, which I generate on PC. And this is also not major problem, because the error was present only during 3 logging phases. |
I would play with the "sample point" and the "three samples" option. |
What is "three samples" option? On the vehicle, I expect around 5-6 nodes. Before, I implemented CAN functions via python-can library. It was tested successfully on the desk with connection RPi<->ECU, but on the vehicle I faced problems. That's why I try different solutions now. |
Hello, I have two scripts which run in parallel. One is for sending requests to ECU via cansend command with 20ms delay and another one is candump command to record frames from ECU to log file. Protocol is simple: request to ECU->response from ECU. So I expect to send 157 requests and get 157 responses.
When there is only communication device<->ECU, in 90% cases all frames from ECU are recorded in log file. In 10% cases, 1 frame is not recorded. And when I simulate some additional CAN frames on the bus, the number of not recorded frames increased.
My hardware is Raspberry Pi 4 with RS485 CAN HAT board. The bitrate is 250kbps.
After OS loads, I run this command:
ip link set can0 up type can bitrate 250000 sample-point 0.75
This is how I send requests to ECU:
cansend can0 7F0#F4.04.00.00.52.80.D8.24
sleep 0.02
cansend can0 7F0#F4.04.00.00.52.80.D8.28
This is my candump command:
candump can0, 7F1:7FF -t A -T 5000 > /home/pi/RC/CAN/Logs/log-$(date +%Y-%m-%d_%H:%M:%S).txt
Now I can't find out the problem of losing frames. Whether it is raspberry limitation or other case?
I would appreciate any comment and add any additional info.
Thanks.
The text was updated successfully, but these errors were encountered: