I want periodic CAN transmission on bus objects so application code can start a repeating send without writing its own timing loop. The public API should be bus.send_periodic(msgs, period, duration=None, store_task=True, autostart=True, modifier_callback=None), where msgs is either a single can.Message or a non-empty sequence of messages, period is the interval in seconds, and the returned task object exposes at least stop(), start() for restartable tasks, and modify_data(messages) for modifiable tasks.
For a simple bus subclass that records calls to send, calling task = bus.send_periodic(can.Message(arbitration_id=0x123, data=[1]), 0.01) should begin sending that message repeatedly until task.stop() is called. Calling bus.send_periodic([msg_a, msg_b], 0.01) with two messages that have the same arbitration ID and channel should cycle through them in order on successive sends. If duration=0.05 is supplied, transmission should stop after roughly that duration; if autostart=False is supplied, no messages should be sent until task.start() is called.
Invalid inputs should fail immediately: a value that is neither a Message nor a sequence of Message objects raises ValueError, an empty sequence raises ValueError, a sequence with mixed arbitration IDs raises ValueError, and a sequence with mixed channels raises ValueError. If modifier_callback is provided, it should be called before each send and can mutate the message data for that send. modify_data() should accept a replacement message or message sequence without changing timing, but it should raise ValueError if the replacement changes the arbitration ID or changes the number of messages.
The bus should track periodic tasks by default so bus.stop_all_periodic_tasks(remove_tasks=True) stops every task started through send_periodic and clears the tracked list. When store_task=False, the returned task should still run and be stoppable, but it should not be tracked by the bus. Stopping an individual tracked task should remove it from the bus tracking list, and bus.shutdown() should stop tracked periodic tasks as part of cleanup. A thread-safe bus wrapper should still allow periodic sending to share the underlying bus safely with normal send() calls.