GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-86819: Add ISO-TP CAN socket constants by rumpelsepp · Pull Request #23794 · python/cpython

gh-86819: Add ISO-TP CAN socket constants #23794

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.

Sign up for GitHub

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

Merged
erlend-aasland merged 3 commits into python:main from rumpelsepp:isotp
Sep 17, 2025

Uh oh!

There was an error while loading. Please reload this page.

Merged

gh-86819: Add ISO-TP CAN socket constants #23794

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
f3837ad
Add constants to socket module for ISO-TP CAN protocol
Feb 28, 2022
d4e2960
Run ./Tools/build/regen-configure.sh
rumpelsepp Jul 12, 2024
da06e89
Merge branch 'main' into isotp
erlend-aasland Sep 17, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

7 changes: 7 additions & 0 deletions 7 Doc/whatsnew/3.15.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@ shelve
(Contributed by Andrea Oliveri in :gh:`134004`.)


socket
------

* Add constants for the ISO-TP CAN protocol.
(Contributed by Patrick Menschel and Stefan Tatschner in :gh:`86819`.)


sqlite3
-------

Expand Down
39 changes: 39 additions & 0 deletions 39 Lib/test/test_socket.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2393,6 +2393,45 @@ def testCrucialConstants(self):
socket.CAN_ISOTP
socket.SOCK_DGRAM

@unittest.skipUnless(hasattr(socket, "SOL_CAN_ISOTP"),
"missing <linux/can/isotp.h>")
def testISOTP(self):
socket.SOL_CAN_ISOTP

socket.CAN_ISOTP_OPTS
socket.CAN_ISOTP_RECV_FC

socket.CAN_ISOTP_TX_STMIN
socket.CAN_ISOTP_RX_STMIN
socket.CAN_ISOTP_LL_OPTS

socket.CAN_ISOTP_LISTEN_MODE
socket.CAN_ISOTP_EXTEND_ADDR
socket.CAN_ISOTP_TX_PADDING
socket.CAN_ISOTP_RX_PADDING
socket.CAN_ISOTP_CHK_PAD_LEN
socket.CAN_ISOTP_CHK_PAD_DATA
socket.CAN_ISOTP_HALF_DUPLEX
socket.CAN_ISOTP_FORCE_TXSTMIN
socket.CAN_ISOTP_FORCE_RXSTMIN
socket.CAN_ISOTP_RX_EXT_ADDR
socket.CAN_ISOTP_WAIT_TX_DONE
# This constant is not always available
# socket.CAN_ISOTP_SF_BROADCAST

socket.CAN_ISOTP_DEFAULT_FLAGS
socket.CAN_ISOTP_DEFAULT_EXT_ADDRESS
socket.CAN_ISOTP_DEFAULT_PAD_CONTENT
socket.CAN_ISOTP_DEFAULT_FRAME_TXTIME
socket.CAN_ISOTP_DEFAULT_RECV_BS
socket.CAN_ISOTP_DEFAULT_EXT_ADDRESS
socket.CAN_ISOTP_DEFAULT_RECV_STMIN
socket.CAN_ISOTP_DEFAULT_RECV_WFTMAX

socket.CAN_ISOTP_DEFAULT_LL_MTU
socket.CAN_ISOTP_DEFAULT_LL_TX_DL
socket.CAN_ISOTP_DEFAULT_LL_TX_FLAGS

def testCreateSocket(self):
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
pass
Expand Down
1 change: 1 addition & 0 deletions 1 Misc/NEWS.d/next/Library/2025-08-22-09-53-45.gh-issue-86819.ECxvwx.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:mod:`socket`: Add missing constants for ISO-TP sockets.
37 changes: 37 additions & 0 deletions 37 Modules/socketmodule.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8528,6 +8528,43 @@ socket_exec(PyObject *m)

ADD_INT_MACRO(m, J1939_FILTER_MAX);
#endif
#ifdef HAVE_LINUX_CAN_ISOTP_H
ADD_INT_MACRO(m, SOL_CAN_ISOTP);

ADD_INT_MACRO(m, CAN_ISOTP_OPTS);
ADD_INT_MACRO(m, CAN_ISOTP_RECV_FC);

ADD_INT_MACRO(m, CAN_ISOTP_TX_STMIN);
ADD_INT_MACRO(m, CAN_ISOTP_RX_STMIN);
ADD_INT_MACRO(m, CAN_ISOTP_LL_OPTS);

ADD_INT_MACRO(m, CAN_ISOTP_LISTEN_MODE);
ADD_INT_MACRO(m, CAN_ISOTP_EXTEND_ADDR);
ADD_INT_MACRO(m, CAN_ISOTP_TX_PADDING);
ADD_INT_MACRO(m, CAN_ISOTP_RX_PADDING);
ADD_INT_MACRO(m, CAN_ISOTP_CHK_PAD_LEN);
ADD_INT_MACRO(m, CAN_ISOTP_CHK_PAD_DATA);
ADD_INT_MACRO(m, CAN_ISOTP_HALF_DUPLEX);
ADD_INT_MACRO(m, CAN_ISOTP_FORCE_TXSTMIN);
ADD_INT_MACRO(m, CAN_ISOTP_FORCE_RXSTMIN);
ADD_INT_MACRO(m, CAN_ISOTP_RX_EXT_ADDR);
ADD_INT_MACRO(m, CAN_ISOTP_WAIT_TX_DONE);
#ifdef CAN_ISOTP_SF_BROADCAST
ADD_INT_MACRO(m, CAN_ISOTP_SF_BROADCAST);
#endif

ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_FLAGS);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_EXT_ADDRESS);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_PAD_CONTENT);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_FRAME_TXTIME);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_RECV_BS);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_RECV_STMIN);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_RECV_WFTMAX);

ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_LL_MTU);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_LL_TX_DL);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_LL_TX_FLAGS);
#endif
#ifdef SOL_RDS
ADD_INT_MACRO(m, SOL_RDS);
#endif
Expand Down
4 changes: 4 additions & 0 deletions 4 Modules/socketmodule.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ typedef int socklen_t;
#include <linux/can/bcm.h>
#endif

#ifdef HAVE_LINUX_CAN_ISOTP_H
#include <linux/can/isotp.h>
#endif

#ifdef HAVE_LINUX_CAN_J1939_H
#include <linux/can/j1939.h>
#endif
Expand Down
13 changes: 12 additions & 1 deletion 13 configure
Show comments
View file
Open in desktop

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

4 changes: 2 additions & 2 deletions 4 configure.ac
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3053,10 +3053,10 @@ AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [
#endif
])

# On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h
# On Linux, can.h, can/bcm.h, can/isotp.h, can/j1939.h, can/raw.h require sys/socket.h
# On NetBSD, netcan/can.h requires sys/socket.h
AC_CHECK_HEADERS(
[linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h netcan/can.h],
[linux/can.h linux/can/bcm.h linux/can/isotp.h linux/can/j1939.h linux/can/raw.h netcan/can.h],
[], [], [
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
Expand Down
3 changes: 3 additions & 0 deletions 3 pyconfig.h.in
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,9 @@
/* Define to 1 if you have the <linux/can.h> header file. */
#undef HAVE_LINUX_CAN_H

/* Define to 1 if you have the <linux/can/isotp.h> header file. */
#undef HAVE_LINUX_CAN_ISOTP_H

/* Define to 1 if you have the <linux/can/j1939.h> header file. */
#undef HAVE_LINUX_CAN_J1939_H

Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.