-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
bpo-42653: Add constants to socket module for IsoTp CAN protocol #26174
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
Conversation
IsoTp CAN protocol is available since Kernel v5.10 but several constants from isotp.h have not found their way into socket module. This commit adds that header file if configure finds it. Signed-off-by: Patrick Menschel <[email protected]>
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Use PyModule_AddIntMacro() to add all constants from isotp.h . Signed-off-by: Patrick Menschel <[email protected]>
Signed-off-by: Patrick Menschel <[email protected]>
Signed-off-by: Patrick Menschel <[email protected]>
This one slipped by, sorry. Signed-off-by: Patrick Menschel <[email protected]>
The issue number was found eventually. Apparently there already was a PR with this topic. Signed-off-by: Patrick Menschel <[email protected]>
|
Dear Reviewer, |
|
My pullrequest seems to lack these edit: Ah okay, these are part of the inclusion in the mainline kernel. I missed these. |
|
Yes,
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/can/isotp.h
The one on @hartkopp 's repo is outdated.
|
For unknown reason, HAVE_LINUX_CAN_ISOTP_H was not set during build. After changing the order of items in that particular line of configure.ac, it now works as expected. Signed-off-by: Patrick Menschel <[email protected]>
This may not be necessary but it is clean. Also normalize the comment line above. Signed-off-by: Patrick Menschel <[email protected]>
|
The patch also works on Python 3.9.5. This was build on a rpi0w. |
CAN_ISOTP_SF_BROADCAST is new and not always available. This was the case on a recent RaspberryPi Kernel. Therefore make it optional and exclude it from test. Also add condition for testing the constants. Signed-off-by: Patrick Menschel <[email protected]>
| PyModule_AddIntMacro(m, CAN_ISOTP_WAIT_TX_DONE); | ||
| #ifdef CAN_ISOTP_SF_BROADCAST | ||
| /* This constant is new and not always available */ | ||
| PyModule_AddIntMacro(m, CAN_ISOTP_SF_BROADCAST); |
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 assume the version of the kernel could be checked on buildtime, couldn't it?
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.
Technically yes, but there is no guarantee that this symbol really is there when the kernel version is above a specific version.
If you install the headers yourself with linux-headers-$(uname -r), the assumption works.
But if the installation of headers has been obscured, like with Raspberry Pi 's package raspberrypi-kernel-headers, this assumption no longer works. It just adds another assumption that the packages
raspberrypi-kernel-headers and raspberrypi-kernel are in sync.
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.
Personally, I would argue that the mainline upstream kernel is the source of truth and this must be fixed downstream. No idea how the CPython project deals with these kinds of issues.
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.
Well, lets wait for the Reviewer to comment on this. This should theoretically be @tiran.
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.
aye.
|
BUMP. This PR is stale for about a month now. Is there a way to accelerate this? |
|
Need to re-target Doc/whatsnew/3.10.rst to 3.12. |
While you are at it: Meanwhile another new constant |
|
Be aware, these PRs have been stale for over a year.
I consider them dead.
|
Yes but when @MaxwellDupre makes the zombie run again ... ;-) |
This PR adds constants to socket module for IsoTp CAN protocol.
IsoTp CAN protocol is mainline since Kernel v5.10.
The basic socket constant for IsoTp has been available since Python 3.7 (August 2018),
so it could be used for default use-cases without having issues.
However several constants from isotp.h have not found their way into socket module yet.
When using advanced options like padding, this flaw becomes visible.
https://gitlab.com/Menschel/socketcan/-/blob/master/socketcan/socketcan.py#L18
This PR may be related to #23794.
https://bugs.python.org/issue42653