python-can
python-can copied to clipboard
WIP: Add method to calculate load on a bus
PR created to address Issue #972. WIP since I'm not done testing this.
I also preemptively opened a PR because I'm having some difficulty determining what the bitrate of a particular CAN interface is configured to be. If anyone could point me in the right direction, I'd be grateful. I saw that some custom interfaces have bitrates hard-coded in their respective constants.py files.
You should take a look into canbusload from SocketCAN CAN utils:
https://github.com/linux-can/can-utils/blob/master/canbusload.c
At least when you are working on Linux (Debian/Ubuntu) apt install can-utils should work for you as it installs canbusload too.
Codecov Report
Merging #1105 (681dbf8) into develop (fe18a34) will decrease coverage by
0.08%. The diff coverage is13.33%.
:exclamation: Current head 681dbf8 differs from pull request most recent head fd43fb9. Consider uploading reports for the commit fd43fb9 to get more accurate results
@@ Coverage Diff @@
## develop #1105 +/- ##
===========================================
- Coverage 66.03% 65.94% -0.09%
===========================================
Files 86 86
Lines 8917 8932 +15
===========================================
+ Hits 5888 5890 +2
- Misses 3029 3042 +13
You should take a look into
canbusloadfrom SocketCAN CAN utils: https://github.com/linux-can/can-utils/blob/master/canbusload.cAt least when you are working on Linux (Debian/Ubuntu)
apt install can-utilsshould work for you as it installscanbusloadtoo.
Thank you for the suggestion. It seems the method I implemented is somewhat different since it's intended to be used as a method of an object such as ThreadSafeBus, rather than continuously polling multiple channels. I have tested my code but have not hardcoded test cases.
Going to give this some more attention- I'd like to add additional functionality so that a thread is spawned to track CAN traffic in the background.
No longer need this feature.
Hi @wbarnha, I was interested in this feature, do you mind explaining why it is not needed anymore?
Thx
Long story short, this was written when I was not aware of all tools in can-utils. I believe there's an application that tracks bitrate for you, but unfortunately I cannot remember its name.
Plus there's definitely more efficient ways of calculating this rather than my slow implementation.