Skip to content

send_periodic fails on 32bit system using socketcan #470

Closed
@fuchsch1234

Description

@fuchsch1234

Trying to use send_periodic on a socketcan bus fails with the following error message:

Traceback (most recent call last):  

  File "./test.py", line 8, in <module>
    bus.send_periodic(msg, 0.01, 9)
  File "/usr/local/lib/python3.5/dist-packages/can/bus.py", line 201, in send_periodic
    task = self._send_periodic_internal(msg, period, duration)
  File "/usr/local/lib/python3.5/dist-packages/can/interfaces/socketcan/socketcan.py", line 601, in _send_periodic_internal
    task = CyclicSendTask(bcm_socket, msg, period, duration)
  File "/usr/local/lib/python3.5/dist-packages/can/interfaces/socketcan/socketcan.py", line 254, in __init__
    self._tx_setup(message)
  File "/usr/local/lib/python3.5/dist-packages/can/interfaces/socketcan/socketcan.py", line 274, in _tx_setup
    send_bcm(self.bcm_socket, header + frame)
  File "/usr/local/lib/python3.5/dist-packages/can/interfaces/socketcan/socketcan.py", line 206, in send_bcm
    raise can.CanError(base + "You are probably referring to a non-existing frame.")
can.CanError: Couldn't send CAN BCM frame. OS Error 22: Invalid argument
You are probably referring to a non-existing frame.

I'm using python-can 3.0.0 with python 3.5.3 on 32-bit Debian Stretch.

The same set of flags and values sent to the BCM is working in C.
Debugging shows the problem is a wrong size of the bcm_header. On my machine sizeof(struct bcm_msg_header) is 40 bytes, but the BCM header created in build_bcm_header is 36 bytes long. This causes the invalid argument error from the kernel.
Adding 4 padding bytes at the end of the bcm header remedies the error.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions