hardbyte / python-can

The can package provides controller area network support for Python developers
https://python-can.readthedocs.io
GNU Lesser General Public License v3.0
1.3k stars 605 forks source link

Ability to send_periodic() a group of messages with different arbitration ids and a variable rate period #1732

Open sschueth opened 10 months ago

sschueth commented 10 months ago

Problem Description:

1. Transmit a group of messages with a Group Period and intra-Message Period

When transmitting a group of messages with send_periodic(), the only option is to transmit each message at a uniform period seconds. There are scenarios where the larger group of messages needs to have a period of period seconds but between each message within the group a non-uniform period of period_intra seconds is desired. For example, if I have a group of messages, msg_group = [msg1, msg2], that needs to have a group period of 500 ms, however the period between msg1 and msg2 must be less than 100 ms then this is not possible with the current methods. I'm suggesting adding an optional period_intra attribute.

2. Transmit a group of messages with different arbitration ids

Unable to explicitly group messages with different arbitration ids to the same task. In some scenarios, it is desired to explicitly guarantee order of transmission on the bus and a defined period between messages within a group. The current implementation seems to be aimed at supporting mux'd messages only.

Proposed Solution:

1. Transmit a group of messages with a Group Period and intra-Message Period

Create a child class to provide the methods to run variable rate messaging for a group of messages.

2. Transmit a group of messages with different arbitration_ids

Modify CyclicSendTaskABC and ModifiableCyclicTaskABC to support a group of messages with different arbitration ids.

Additional context

This issue and proposed solution came from implementing updates to meet J1939-76 transmission. The ability to pass the SHM and SDM as a group into a single task is important because it explicitly links the two messages and guarantees the SHM will transmit prior to the SDM. In addition, these proposed changes allow for period to be set as the SDG period and the period_intra set as the SRVT period allowing for compliance with J1939-76 timing.

sschueth commented 10 months ago

Related Pull Request:

https://github.com/hardbyte/python-can/pull/1733