无法导入vxlapi:找不到函数'xlCanReceive'

时间:2019-08-16 11:43:07

标签: python-3.x can-bus

我试图编译一个与Cancasexl接口以从ECU发送和接收信号的代码。我正在使用的库是python-can。

但是我收到一条错误消息:

Could not import vxlapi: function 'xlCanReceive' not found

raise ImportError("The Vector API has not been loaded")
ImportError: The Vector API has not been loaded

我尝试从矢量网站更新CancaseXL驱动程序,以为这可能是驱动程序问题,但仍然显示。

def Can_receive_all(self):
  bus = can.interface.Bus(bustype='vector', channel=self.ch_list, bitrate=500000, app_name=self.can_app_name)
  try:
     while True:
        recv_msg = bus.recv()
        print(recv_msg)
      # if recv_msg is not None:
      # self.print_can_data(recv_msg)
   except Exception as ex:
     print(ex)

我期望来自ECU的Rx信号,但出现错误。

1 个答案:

答案 0 :(得分:0)

在阅读Python-CAN documentation时,您似乎必须具有矢量硬件配置程序,才能将CANCase与Python-CAN一起使用。该文档指出以下内容:

Vector
This interface adds support for CAN controllers by Vector.

By default this library uses the channel configuration for CANalyzer. To use a 
different application, open Vector Hardware Config program and create a new 
application and assign the channels you may want to use. Specify the application name 
as app_name='Your app name' when constructing the bus or in a config file.

Channel should be given as a list of channels starting at 0.

Here is an example configuration file connecting to CAN 1 and CAN 2 for an 
application named “python-can”:

[default]
interface = vector
channel = 0, 1
app_name = python-can