-
Notifications
You must be signed in to change notification settings - Fork 656
Closed
Description
Originally reported by: Sebastian Kienitz (Bitbucket: skienit, GitHub: Unknown)
Hi,
I wonder why I cant use the cyclic send function even though I can send single messages. I have two physical devices connected to each other to proof if its working.
In the following code "send_one()" works perfectly, but "send_cyclic()" doesnt:
#!python
from __future__ import print_function
import can
import time
can.rc['interface'] = 'socketcan_ctypes'
can.rc['channel'] = 'can0'
from can.interfaces.interface import *
def send_one():
bus = can.interface.Bus(channel='can0' , bustype='socketcan_ctypes')
msg = can.Message(arbitration_id=0xc0ffee,
data=[0, 25, 0, 1, 3, 1, 4, 1],
extended_id=False)
try:
bus.send(msg)
print("Message sent on {}".format(bus.channel_info))
except can.CanError:
print("Message NOT sent")
def send_cyclic():
bus = can.interface.Bus(channel='can0' , bustype='socketcan_ctypes')
msg = can.Message(arbitration_id=0xc0ffee,
data=[0, 25, 0, 1, 3, 1, 4, 1],
extended_id=False)
try:
can.send_periodic('can0', msg, 0.020)
print("Message sent periodically on {}".format(bus.channel_info))
except can.CanError:
print("Message NOT sent")
if __name__ == "__main__":
send_one()
send_cyclic()
time.sleep(10)