Skip to content

send_periodic() only sends messages once and then exits #292

@Felhamed

Description

@Felhamed

I am using python-can with Python 3.5.2 and 4.13.0-37-generic #42~16.04.1-Ubuntu with the following code:

#!/usr/bin/python3
import can
import time
import logging

logging.basicConfig(level=logging.INFO)

def periodic_send(msg,bus):
        task = bus.send_periodic(msg, 0.20)
        assert isinstance(task, can.CyclicSendTaskABC)

if __name__ == "__main__":
    bus = can.interface.Bus(bustype='socketcan', channel='can0', bitrate=250000)
    can_ids = [0x181080F5, 0x181081F5, 0x181082F5, 0x181083F5, 0x181084F5, 0x181085F5, 0x181086F5, 0x181087F5, 0x181088F5, 0x181089F5]
    for can_id in can_ids:
        msg_volt = can.Message(arbitration_id=can_id, data=[1, 0, 0, 0, 0, 0, 0, 0], extended_id=True)
        periodic_send(msg_volt,bus)
        msg_temp = can.Message(arbitration_id=can_id, data=[2, 0, 0, 0, 0, 0, 0, 0], extended_id=True)
        periodic_send(msg_temp,bus)

I am trying to send each set of data over the 10 can_ids in the array periodically (200ms) forever, when I try to run the script it only sends each message once and exits. Am I missing something? Appreciate your help.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions