This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Expose additional socket constants for CAN_BCM flags
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: karlding, lukasz.langa, miss-islington, taleinat
Priority: normal Keywords: patch

Created on 2019-05-29 06:53 by karlding, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13646 merged karlding, 2019-05-29 07:25
PR 15049 merged miss-islington, 2019-07-31 08:47
Messages (4)
msg343865 - (view) Author: Karl Ding (karlding) * Date: 2019-05-29 06:53
When reading through the values exposed via the socket library, I noticed that currently, only the SocketCAN BCM opcode enums are exposed via the socket constants. These correspond to the following from the Linux headers:

        enum {
        	TX_SETUP = 1,	/* create (cyclic) transmission task */
        	TX_DELETE,	/* remove (cyclic) transmission task */
        	TX_READ,	/* read properties of (cyclic) transmission task */
        	TX_SEND,	/* send one CAN frame */
        	RX_SETUP,	/* create RX content filter subscription */
        	RX_DELETE,	/* remove RX content filter subscription */
        	RX_READ,	/* read properties of RX content filter subscription */
        	TX_STATUS,	/* reply to TX_READ request */
        	TX_EXPIRED,	/* notification on performed transmissions (count=0) */
        	RX_STATUS,	/* reply to RX_READ request */
        	RX_TIMEOUT,	/* cyclic message is absent */
        	RX_CHANGED	/* updated CAN frame (detected content change) */

It would be nice to expose the BCM flags #defines as well.

        #define SETTIMER            0x0001
        #define STARTTIMER          0x0002
        #define TX_COUNTEVT         0x0004
        #define TX_ANNOUNCE         0x0008
        #define TX_CP_CAN_ID        0x0010
        #define RX_FILTER_ID        0x0020
        #define RX_CHECK_DLC        0x0040
        #define RX_NO_AUTOTIMER     0x0080
        #define RX_ANNOUNCE_RESUME  0x0100
        #define TX_RESET_MULTI_IDX  0x0200
        #define RX_RTR_FRAME        0x0400
        #define CAN_FD_FRAME        0x0800

These BCM flags are used as part of the BCM header that has the aforementioned opcodes. The flags are set on the bcm_msg_head struct:

        struct bcm_msg_head {
            __u32 opcode;
            __u32 flags;
            __u32 count;
            struct bcm_timeval ival1, ival2;
            canid_t can_id;
            __u32 nframes;
            struct can_frame frames[0];

The existing documentation for the BCM constants ( seems to imply that these constants should already be included, but they are not.

See the Linux headers for more details:
msg348792 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2019-07-31 08:47
New changeset 31c4fd2a10d90beaa37d630e5f74a471e14e089d by Łukasz Langa (karl ding) in branch 'master':
bpo-37085: Expose SocketCAN bcm_msg_head flags (#13646)
msg348793 - (view) Author: miss-islington (miss-islington) Date: 2019-07-31 09:10
New changeset d8b914a30b0849476345a19ce0a0ab1ade171b19 by Miss Islington (bot) in branch '3.8':
bpo-37085: Expose SocketCAN bcm_msg_head flags (GH-13646)
msg348799 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2019-07-31 12:04
Karl, many thanks for bringing this up, making a PR and iterating on it with me!
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81266
2019-07-31 12:04:47taleinatsetstatus: open -> closed

versions: + Python 3.9
nosy: + taleinat

messages: + msg348799
resolution: fixed
stage: patch review -> resolved
2019-07-31 09:10:43miss-islingtonsetnosy: + miss-islington
messages: + msg348793
2019-07-31 08:47:39lukasz.langasetnosy: + lukasz.langa
messages: + msg348792
2019-07-31 08:47:35miss-islingtonsetpull_requests: + pull_request14800
2019-05-29 07:25:54karldingsetkeywords: + patch
stage: patch review
pull_requests: + pull_request13541
2019-05-29 06:53:00karldingcreate