PYTHON-CAN with vector

Issue #91 new
tejeshreddy created an issue

i am executing below python code

from future import print_function

import can from can import interfaces import time can.rc['interface'] = 'vector' can.rc['channel'] = '1'

##from can.interfaces.interface import *

def send_one(): bus = can.interface.Bus(channel='1' , bustype='vector') 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='1' , bustype='vector') 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)

and i am getting below errors

Traceback (most recent call last): File "C:\Users\tejeswara.reddy\Desktop\NeS\python_scripts\trail_latest.py", line 36, in <module> send_one() File "C:\Users\tejeswara.reddy\Desktop\NeS\python_scripts\trail_latest.py", line 13, in send_one bus = can.interface.Bus(channel='1' , bustype='vector') File "C:\Python37-32\lib\site-packages\can\interface.py", line 127, in new return cls(channel, args, *config) File "C:\Python37-32\lib\site-packages\can\interfaces\vector\canlib.py", line 134, in init "xlGetChannelIndex") can.interfaces.vector.exceptions.VectorError: xlGetChannelIndex failed (XL_ERR_HW_NOT_PRESENT)

and i want the steps how python will interact with hardware and send a message

if someone provides that will be great for me
thanks in advance

Comments (0)

  1. Log in to comment