Skip to content
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 notes/kvaser support for non-iso support #1752

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jacobschaer
Copy link

Some older devices in the wild use non-iso CAN FD (Bosch). Some hardware supports choosing the mode in the driver, others are configurable during install or with a separate application. Kvaser is in the canlib API. PCAN requires either socket-can driver or the Windows GUI. Socket-CAN is an initialization flag.

Add documentation and hooks for kvaser. Relatively unintrusive. It didn't fit nicely with the bit-timings concept as it's purely associated with CRC calculation and stuffing.

@jacobschaer
Copy link
Author

Fixed the test that was failing the black formatting check. The unit test that was failing appears to be intermittent and unrelated to these changes

@@ -39,6 +39,11 @@ in the ``recv`` method. If a message does not match any of the filters,
``recv()`` will return None.


ISO/Non-ISO CAN FD Mode
-----------------------
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-----------------------
~~~~~~~~~~~~~~~~~~~~~~~

This heading is a bit too large.
image
Also, i think the docstring for the new parameter is sufficient, this paragraph does not add any additional information.

@@ -415,6 +415,10 @@ def __init__(
In this case, the bit will be sampled three quanta in a row,
with the last sample being taken in the edge between TSEG1 and TSEG2.
Three samples should only be used for relatively slow baudrates.
:param bool fd_non_iso:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this closer to the fd parameter.

@@ -37,7 +37,14 @@ Here is an example configuration file for using `PCAN-USB <https://www.peak-syst
``bitrate`` (default ``500000``)
Channel bitrate

ISO/Non-ISO CAN FD Mode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heading here also looks out of place. IMO the paragraph is not necessary.

@zariiii9003
Copy link
Collaborator

@lumagi What do you think about adding CanProtocol.CAN_FD_NON_ISO?

@lumagi
Copy link
Collaborator

lumagi commented Mar 12, 2024

@lumagi What do you think about adding CanProtocol.CAN_FD_NON_ISO?

Although it is very specific to this interface, I generally don't see any reasons against it. The enum already has multiple values so there's no real harm in one more. And it would certainly do away with the mess of book flags.

@jacobschaer
Copy link
Author

What value would there be in tracking this in bus's protocol property? For all use cases I've seen ISO and Non-ISO CANFD should behave identically at the app layer - the only difference is some bits in the header change but that's at a layer below python-can. A bus can't mix/match frames between the two types and I don't see any interesting uses of protocol outside of the bus implementations.

Ultimately you still need a kwarg for the Bus init, there's no way to guess if it's ISO or not from say bittimings or other flags.

I agree that it's unfortunate that more drivers don't expose this in a way that python-can can exploit.

I can update the docs per the recommendations later.

New enum for non-iso mode
Documentation sections fixes
Test update
@jacobschaer
Copy link
Author

I made some updates per the suggestions.

Black cleanup
@jacobschaer
Copy link
Author

Fixed the black issue -would be nice if that was in the default workflow but oh well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants