help with a config

41 views
Skip to first unread message

Вячеслав Мальцев

unread,
Jan 20, 2020, 6:57:25 AM1/20/20
to python-can
config with Python-can1.4.3 works.

I ask for your help, with a change in the config python-can 3

#!python
#
from __future__ import print_function
import time
import os
import sys
import threading
import can
can.rc['interface'] = 'socketcan_ctypes'
from threading import Thread, Timer
from can.interfaces.interface import Bus
can_interface = 'can0'

global var
var=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()
error
 from can.interfaces.interface import Bus
ImportError: No module named interface


For new versions you need to create
nano /etc/can.conf
can
.rc['interface'] = 'socketcan'
can
.rc['channel'] = 'can0'
right?


Reply all
Reply to author
Forward
0 new messages