Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a6cc551

Browse files
committed
Issue #22631: Added Linux-specific socket constant CAN_RAW_FD_FRAMES.
Patch courtesy of Joe Jevnik.
1 parent d827be8 commit a6cc551

8 files changed

Lines changed: 65 additions & 1 deletion

File tree

Doc/library/socket.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,18 @@ Constants
279279

280280
.. versionadded:: 3.4
281281

282+
.. data:: CAN_RAW_FD_FRAMES
283+
284+
Enables CAN FD support in a CAN_RAW socket. This is disabled by default.
285+
This allows your application to send both CAN and CAN FD frames; however,
286+
you one must accept both CAN and CAN FD frames when reading from the socket.
287+
288+
This constant is documented in the Linux documentation.
289+
290+
Availability: Linux >= 3.6.
291+
292+
.. versionadded:: 3.5
293+
282294
.. data:: AF_RDS
283295
PF_RDS
284296
SOL_RDS

Doc/whatsnew/3.5.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,9 @@ Changes in the Python API
792792
in Python 3.5, all old `.pyo` files from previous versions of Python are
793793
invalid regardless of this PEP.
794794

795+
* The :mod:`socket` module now exports the CAN_RAW_FD_FRAMES constant on linux
796+
3.6 and greater.
797+
795798
Changes in the C API
796799
--------------------
797800

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ Flemming Kjær Jensen
664664
Philip H. Jensen
665665
Philip Jenvey
666666
MunSic Jeong
667+
Joe Jevnik
667668
Chris Jerdonek
668669
Jim Jewett
669670
Pedro Diaz Jimenez

Misc/NEWS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
+++++++++++
1+
+++++++++++
22
Python News
33
+++++++++++
44

@@ -9,6 +9,8 @@ Release date: XXX
99

1010
Core and Builtins
1111
-----------------
12+
- Issue #22631: Added Linux-specific socket constant CAN_RAW_FD_FRAMES.
13+
Patch courtesy of Joe Jevnik.
1214

1315
- Issue #23731: Implement PEP 488: removal of .pyo files.
1416

Modules/socketmodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6617,6 +6617,9 @@ PyInit__socket(void)
66176617
PyModule_AddIntMacro(m, CAN_RAW_LOOPBACK);
66186618
PyModule_AddIntMacro(m, CAN_RAW_RECV_OWN_MSGS);
66196619
#endif
6620+
#ifdef HAVE_LINUX_CAN_RAW_FD_FRAMES
6621+
PyModule_AddIntMacro(m, CAN_RAW_FD_FRAMES);
6622+
#endif
66206623
#ifdef HAVE_LINUX_CAN_BCM_H
66216624
PyModule_AddIntMacro(m, CAN_BCM);
66226625
PyModule_AddIntConstant(m, "CAN_BCM_TX_SETUP", TX_SETUP);

configure

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10495,6 +10495,36 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1049510495
fi
1049610496
fi
1049710497

10498+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CAN_RAW_FD_FRAMES" >&5
10499+
$as_echo_n "checking for CAN_RAW_FD_FRAMES... " >&6; }
10500+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10501+
/* end confdefs.h. */
10502+
/* CAN_RAW_FD_FRAMES available check */
10503+
#include <linux/can/raw.h>
10504+
int
10505+
main ()
10506+
{
10507+
int can_raw_fd_frames = CAN_RAW_FD_FRAMES;
10508+
;
10509+
return 0;
10510+
}
10511+
_ACEOF
10512+
if ac_fn_c_try_compile "$LINENO"; then :
10513+
10514+
10515+
$as_echo "#define HAVE_LINUX_CAN_RAW_FD_FRAMES 1" >>confdefs.h
10516+
10517+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10518+
$as_echo "yes" >&6; }
10519+
10520+
else
10521+
10522+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10523+
$as_echo "no" >&6; }
10524+
10525+
fi
10526+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
10527+
1049810528
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for OSX 10.5 SDK or later" >&5
1049910529
$as_echo_n "checking for OSX 10.5 SDK or later... " >&6; }
1050010530
cat confdefs.h - <<_ACEOF >conftest.$ac_ext

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,6 +2876,16 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
28762876
fi
28772877
fi
28782878

2879+
AC_MSG_CHECKING(for CAN_RAW_FD_FRAMES)
2880+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* CAN_RAW_FD_FRAMES available check */
2881+
#include <linux/can/raw.h>]],
2882+
[[int can_raw_fd_frames = CAN_RAW_FD_FRAMES;]])],[
2883+
AC_DEFINE(HAVE_LINUX_CAN_RAW_FD_FRAMES, 1, [Define if compiling using Linux 3.6 or later.])
2884+
AC_MSG_RESULT(yes)
2885+
],[
2886+
AC_MSG_RESULT(no)
2887+
])
2888+
28792889
AC_MSG_CHECKING(for OSX 10.5 SDK or later)
28802890
AC_COMPILE_IFELSE([
28812891
AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@
531531
/* Define to 1 if you have the <linux/can.h> header file. */
532532
#undef HAVE_LINUX_CAN_H
533533

534+
/* Define if compiling using Linux 3.6 or later. */
535+
#undef HAVE_LINUX_CAN_RAW_FD_FRAMES
536+
534537
/* Define to 1 if you have the <linux/can/raw.h> header file. */
535538
#undef HAVE_LINUX_CAN_RAW_H
536539

0 commit comments

Comments
 (0)