hardbyte / python-can

The can package provides controller area network support for Python developers
https://python-can.readthedocs.io
GNU Lesser General Public License v3.0
1.31k stars 604 forks source link

usb2can dll problem #188

Closed TianTianlove closed 7 years ago

TianTianlove commented 7 years ago

Hi, I have a problem when I use this tool. I place the .dll file in the same folder with my xxx.py. When I want to send a message, There is always an error.

Traceback (most recent call last): File "E:/PythonWorkspace/CANmatrixTest/test/canInterface.py", line 22, in send_one() File "E:/PythonWorkspace/CANmatrixTest/test/canInterface.py", line 11, in send_one bus = Usb2canBus("ED000200") File "D:\Program Files\Python36\lib\site-packages\python_can-2.0.0b1-py3.6.egg\can\interfaces\usb2can\usb2canInterface.py", line 93, in init File "D:\Program Files\Python36\lib\site-packages\python_can-2.0.0b1-py3.6.egg\can\interfaces\usb2can\usb2canabstractionlayer.py", line 59, in init File "D:\Program Files\Python36\lib\ctypes__init__.py", line 425, in LoadLibrary return self._dlltype(name) File "D:\Program Files\Python36\lib\ctypes__init.py", line 347, in init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 is not a valid Win32 application

My Code:

`import can from can.interfaces.usb2can.usb2canInterface import Usb2canBus

def send_one(): bus = Usb2canBus("ED000200") msg = can.Message(arbitration_id=0xc0ffee, data=[0, 25, 0, 1, 3, 1, 4, 1], extended_id=True) try: bus.send(msg) print("Message sent on {}".format(bus.channel_info)) except can.CanError: print("Message NOT sent")

if name == "main": send_one()`

I don't know where is wrong, Is there anyone know how to solve the problem and help me? I am using python3.6 OS is Win 64x

TianTianlove commented 7 years ago

My Python is 64x, I change it to 32x, It's ok