Closed
Labels
Description
Originally reported by: Kyle Altendorf (Bitbucket: altendky, GitHub: altendky)
I just created a socketcan/PCAN only bus checker. It tries to create a bus for each interface/channel and checks for exceptions to filter out the unavailable ones.
https://github.com/altendky/st/blob/7c87276d1bb7b58e8d9c060b40d047fed5a5032d/epyq/busselector.py#L19
It's pretty hacky and hardcoded but I thought I would share it in case anyone wanted to expand on it and integrate it into python-can.
Activity
hardbyte commentedon Mar 20, 2016
Original comment by Kyle Altendorf (Bitbucket: altendky, GitHub: altendky):
Corrected to shutdown tested buses.
https://github.com/altendky/st/blob/8a5e5294e1eca60b48f24c4ae0508846511e9413/epyq/busselector.py#L19
hardbyte commentedon Mar 25, 2016
Original comment by Brian Thorne (Bitbucket: hardbyte, GitHub: hardbyte):
Hi Kyle, I think this would be a good addition to the
can.interfacesapi although there should be a way to configure which interfaces to check. I remember having a fairly time consuming loop doing something similar for trying different Kvaser channels.hardbyte commentedon Mar 26, 2016
Original comment by Kyle Altendorf (Bitbucket: altendky, GitHub: altendky):
I agree though I am unlikely to expand much in the near future. If I do, I will certainly share it.
cowo78 commentedon Feb 8, 2017
IMHO we can think about extending the BusABC interface with a detect_hardware static or something like that.
It should report configuration dicts and the available channels for each detected piece of hardware.
felixdivo commentedon Feb 23, 2018
The canal interface already implements that automatic discovery, but as a fallback when no channel was given in
kwargsorcan.rc. See #245.felixdivo commentedon Feb 23, 2018
Let's suppose
BusABChas a detect method, like Giuseppe (@cowo78) proposed. I would call itdetect_available_channelssince not all interfaced work with actual hardware. For examplevirtualorsocketcan'svcan0only work in software. It could look like this (notice that it is not abstract):Then I would define this method and make it accessible directly from the
canmodule:What do you think about this?
EDIT: The good thing about this would be that existing interface implementations would not have to be changed and the feature could be added incrementally.