agrobot_base/Python/waveshare_usb_can_fd/test1.py

20 lines
634 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.")