Hello I am using python with can analyzer hardware vn1610
import time
import can
count=0
a=0
for i in range(1,1000): # zero to max range ( 0 - 2048 )
a=a+1
print(a) #code stops running at a=64[enter image description here][1]
bus = can.interface.Bus(bustype='vector', app_name=None, channel=0,bitrate=500000)
msg = can.Message(arbitration_id=i, data=[0x02,0x11,0x02,0x00 ,0x00 ,0x00, 0x00, 0x00],dlc=3, extended_id=False)
bus.send(msg)
print ("Request msg:",msg)
response=bus.recv(0.02)
print ("Response msg:",response)
I am getting can.interfaces.vector.exceptions.VectorError: xlGetChannelIndex failed (XL_ERR_HW_NOT_PRESENT) as a error. What is causing this error?
It is stopping because you are creating a new interface everytime.
Probably CANalyzer supports maximum of 64 interfaces [citation needed] and that is why it stops after a = 64.
You don't have to create interface everytime. Move
bus = can.interface.Bus(bustype='vector', app_name=None, channel=0,bitrate=500000)
out of for
loop and your code should work. As you don't have to create interface again and again.