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

Expose additional socket constants for CAN_BCM flags #81266

Closed
karlding mannequin opened this issue May 29, 2019 · 4 comments
Closed

Expose additional socket constants for CAN_BCM flags #81266

karlding mannequin opened this issue May 29, 2019 · 4 comments
Labels
3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@karlding
Copy link
Mannequin

karlding mannequin commented May 29, 2019

BPO 37085
Nosy @taleinat, @ambv, @miss-islington, @karlding
PRs
  • bpo-37085: Expose SocketCAN bcm_msg_head flags #13646
  • [3.8] bpo-37085: Expose SocketCAN bcm_msg_head flags (GH-13646) #15049
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-07-31.12:04:47.124>
    created_at = <Date 2019-05-29.06:53:00.895>
    labels = ['3.8', 'type-feature', 'library', '3.9']
    title = 'Expose additional socket constants for CAN_BCM flags'
    updated_at = <Date 2019-07-31.12:04:47.003>
    user = 'https://github.com/karlding'

    bugs.python.org fields:

    activity = <Date 2019-07-31.12:04:47.003>
    actor = 'taleinat'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-07-31.12:04:47.124>
    closer = 'taleinat'
    components = ['Library (Lib)']
    creation = <Date 2019-05-29.06:53:00.895>
    creator = 'karlding'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37085
    keywords = ['patch']
    message_count = 4.0
    messages = ['343865', '348792', '348793', '348799']
    nosy_count = 4.0
    nosy_names = ['taleinat', 'lukasz.langa', 'miss-islington', 'karlding']
    pr_nums = ['13646', '15049']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue37085'
    versions = ['Python 3.8', 'Python 3.9']

    @karlding
    Copy link
    Mannequin Author

    karlding mannequin commented May 29, 2019

    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 (https://docs.python.org/3/library/socket.html#socket.CAN_BCM) seems to imply that these constants should already be included, but they are not.

    See the Linux headers for more details: https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/can/bcm.h

    @karlding karlding mannequin added 3.8 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels May 29, 2019
    @ambv
    Copy link
    Contributor

    ambv commented Jul 31, 2019

    New changeset 31c4fd2 by Łukasz Langa (karl ding) in branch 'master':
    bpo-37085: Expose SocketCAN bcm_msg_head flags (bpo-13646)
    31c4fd2

    @miss-islington
    Copy link
    Contributor

    New changeset d8b914a by Miss Islington (bot) in branch '3.8':
    bpo-37085: Expose SocketCAN bcm_msg_head flags (GH-13646)
    d8b914a

    @taleinat
    Copy link
    Contributor

    Karl, many thanks for bringing this up, making a PR and iterating on it with me!

    @taleinat taleinat added the 3.9 only security fixes label Jul 31, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 (EOL) end of life 3.9 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants