python-can icon indicating copy to clipboard operation
python-can copied to clipboard

WIP: Add method to calculate load on a bus

Open wbarnha opened this issue 4 years ago • 4 comments

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.

wbarnha avatar Jul 09 '21 22:07 wbarnha

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.

hartkopp avatar Jul 11 '21 10:07 hartkopp

Codecov Report

Merging #1105 (681dbf8) into develop (fe18a34) will decrease coverage by 0.08%. The diff coverage is 13.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     

codecov[bot] avatar Jul 14 '21 12:07 codecov[bot]

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.

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.

wbarnha avatar Jul 16 '21 21:07 wbarnha

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.

wbarnha avatar Apr 22 '22 23:04 wbarnha

No longer need this feature.

wbarnha avatar Nov 03 '22 16:11 wbarnha

Hi @wbarnha, I was interested in this feature, do you mind explaining why it is not needed anymore?

Thx

JayTeeBat avatar Jul 18 '23 20:07 JayTeeBat

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.

wbarnha avatar Jul 18 '23 20:07 wbarnha