#!python#from __future__ import print_functionimport timeimport osimport sysimport threadingimport cancan.rc['interface'] = 'socketcan_ctypes'from threading import Thread, Timerfrom can.interfaces.interface import Buscan_interface = 'can0'
global varvar=1
def dumpcan(): global var for message in Bus(can_interface): if var==1: msg = unicode(message).encode('utf +8') canid = msg[26:29] msg = msg[45:69] if canid == ("464"):#### aktivation tvtuner #### if msg == ("e0 01 00"): bus = can.interface.Bus() msg = can.Message(arbitration_id=0x264, data=[0xa0, 0x01, 0x00], extended_id=False) bus.send(msg)
#
# How to make that when there is no canid ("464"), send this message once? if msg == ("a1 01"): bus = can.interface.Bus() msg = can.Message(arbitration_id=0x264, data=[0x10, 0x15, 0x01, 0x00, 0x02, 0x00, 0x00], extended_id=False) bus.send(msg)dumpcan()
from can.interfaces.interface import BusImportError: No module named interface
nano /etc/can.conf
can.rc['interface'] = 'socketcan'
can.rc['channel'] = 'can0'