agrobot_base/Python/waveshare_usb_can_fd/test1.py

20 lines
634 B
Python
Raw Permalink Normal View History

2025-05-06 18:47:59 +00:00
import ctypes
import os
dll_path = os.path.abspath("ControlCANFD.dll")
canfd = ctypes.windll.LoadLibrary(dll_path)
ZCAN_OpenDevice = canfd.ZCAN_OpenDevice
ZCAN_OpenDevice.argtypes = [ctypes.c_uint, ctypes.c_uint, ctypes.c_uint]
ZCAN_OpenDevice.restype = ctypes.c_void_p
print("Testando valores possíveis de DEVICE_TYPE (02000)...")
for device_type in range(0, 2000):
handle = ZCAN_OpenDevice(device_type, 0, 0)
if handle:
print(f"✅ Sucesso com DEVICE_TYPE = {device_type} — Handle: {handle}")
break
else:
print("❌ Nenhum DEVICE_TYPE funcionou! Verifique o driver ou compatibilidade da DLL.")