-
Notifications
You must be signed in to change notification settings - Fork 604
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
Add protocol
property to BusABC to determine active CAN Protocol
#1532
Conversation
Just to clarify: you say
but you actually just want to know whether CAN FD is currently active, right? Generally i don't mind standardizing this for all interfaces, but with CAN XL coming soon it might make sense to use an enum instead of a boolean flag. Otherwise we would need to add |
Sure, I can implement this as an enum. Let me know what you want it to look like, something along the lines:
|
CAN FD is already part of ISO 11898 and CAN XL will also be part of 11898. So instead of @hardbyte not sure how to contact you but i recommend @lumagi as maintainer ;) |
@lumagi - Lukas thanks so much for your contributions so far. As suggested I've invited you to the repository as a collaborator. Use your new powers for good! In essence, please be sensible and request reviews for non-trivial changes 👍 Great idea @zariiii9003! |
@hardbyte Thank you for the invitation, I appreciate it! And thanks for the recommendation @zariiii9003 ;) |
Regarding the naming of the enum, I think I like Edit: Maybe |
Here is an interesting sentence
So it is either "DataLinkLayer" or "Protocol". I'm not sure which one is technically correct in our case. I prefer |
Ok, to me either one would be fine: |
14cba14
to
26fe9d4
Compare
can/interfaces/udp_multicast/bus.py
Outdated
super().__init__(channel, **kwargs) | ||
super().__init__( | ||
channel, **kwargs, protocol=CANProtocol.CAN_FD if fd else CANProtocol.CAN_20 | ||
) | ||
|
||
self.is_fd = fd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zariiii9003 Would you consider this is_fd
flag as a public attribute that would lead to a breaking API change if it were removed? With the protocol
field it's technically redundant and could be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could replace it with a property and raise a DeprecationWarning with a removal scheduled for version 5.
Done |
The property is scheduled for removal in v5.0
The property is superseded by BusABC.protocol and scheduled for removal in version 5.0.
9528af4
to
652d5cc
Compare
Yes sure, I don't mind. I only have a couple Bus implementations left, so this can probably change state away from draft soon. But I imagine there's gonna be some feedback :D |
# Conflicts: # can/__init__.py # can/interfaces/canalystii.py # can/interfaces/cantact.py # can/interfaces/etas/__init__.py # can/interfaces/gs_usb.py # can/interfaces/ics_neovi/neovi_bus.py # can/interfaces/iscan.py # can/interfaces/ixxat/canlib_vcinpl.py # can/interfaces/ixxat/canlib_vcinpl2.py # can/interfaces/kvaser/canlib.py # can/interfaces/neousys/neousys.py # can/interfaces/nican.py # can/interfaces/nixnet.py # can/interfaces/pcan/pcan.py # can/interfaces/robotell.py # can/interfaces/serial/serial_can.py # can/interfaces/slcan.py # can/interfaces/systec/ucanbus.py # can/interfaces/udp_multicast/bus.py # can/interfaces/usb2can/usb2canInterface.py # can/interfaces/vector/canlib.py # test/serial_test.py # test/test_interface_canalystii.py
I resolved all the merge conflicts from #1551. I hope i didn't break anything. |
Thanks for resolving the conflicts! And also the rogue black test - It was not able to come to terms with my local black version. |
40f9ea8
to
6b53ef4
Compare
You could install the correct versions with |
a290a46
to
6914cba
Compare
@zariiii9003 I think I'm through with all the implementations, if you would like to take a look. |
The attribute is now set as class attribute with default value and can be overridden in the subclass constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! The enum comparisons should be fixed though 😄
Fix property access and enum comparison Co-authored-by: zariiii9003 <[email protected]>
Great, thanks for the review! How many reviewers do you normally have for greater changes like this one? |
At some point 2 reviews were required. But we had more active maintainers at that point. I will merge this after a 4.2.1 bugfix release to avoid backporting headaches. |
protocol
property to BusABC to determine active CAN Protocol
@zariiii9003 When do you think this will make it into a release? Will this have to wait until a major release or will this go into the next minor? To be honest, I am quite looking forward to having this feature available :D |
Sure, I can take care of that. I'll probably get around to doing that over the weekend. |
Something that I have been missing in the past about the generic
BusABC
is to introspect CAN-FD support independent of the bus implementation. The way I would imagine this is to simply have an attribute calledis_fd
or something similar that will returnTrue
if the bus supports the CAN-FD protocol.As an example, I have implemented this for the PCAN bus to gather some feedback. If this gets support, I will implement it for all interfaces.