1
This commit is contained in:
@@ -1,33 +1,32 @@
|
||||
import ctypes
|
||||
import os
|
||||
|
||||
# Load DLL with stdcall convention
|
||||
# Load DLL
|
||||
dll_path = os.path.join(os.path.dirname(__file__), "libs", "atcore.dll")
|
||||
atcore = ctypes.WinDLL(dll_path)
|
||||
lib = ctypes.CDLL(dll_path, winmode=0)
|
||||
|
||||
# Type definitions
|
||||
AT_H = ctypes.c_int
|
||||
AT_64 = ctypes.c_longlong
|
||||
AT_BOOL = ctypes.c_int
|
||||
|
||||
# Constants
|
||||
AT_SUCCESS = 0
|
||||
AT_HANDLE_SYSTEM = 1
|
||||
|
||||
# Setup AT_InitialiseLibrary
|
||||
atcore.AT_InitialiseLibrary.argtypes = []
|
||||
atcore.AT_InitialiseLibrary.restype = ctypes.c_int
|
||||
# Define AT_InitialiseLibrary
|
||||
lib.AT_InitialiseLibrary.argtypes = []
|
||||
lib.AT_InitialiseLibrary.restype = ctypes.c_int
|
||||
|
||||
# Setup AT_GetInt
|
||||
atcore.AT_GetInt.argtypes = [AT_H, ctypes.c_wchar_p, ctypes.POINTER(AT_64)]
|
||||
atcore.AT_GetInt.restype = ctypes.c_int
|
||||
# Define AT_GetInt
|
||||
lib.AT_GetInt.argtypes = [AT_H, ctypes.c_wchar_p, ctypes.POINTER(AT_64)]
|
||||
lib.AT_GetInt.restype = ctypes.c_int
|
||||
|
||||
# Setup AT_FinaliseLibrary
|
||||
atcore.AT_FinaliseLibrary.argtypes = []
|
||||
atcore.AT_FinaliseLibrary.restype = ctypes.c_int
|
||||
# Define AT_FinaliseLibrary
|
||||
lib.AT_FinaliseLibrary.argtypes = []
|
||||
lib.AT_FinaliseLibrary.restype = ctypes.c_int
|
||||
|
||||
print("Initializing library...")
|
||||
ret = atcore.AT_InitialiseLibrary()
|
||||
ret = lib.AT_InitialiseLibrary()
|
||||
if ret != AT_SUCCESS:
|
||||
print(f"ERROR: Initialize failed, code: {ret}")
|
||||
exit(1)
|
||||
@@ -35,14 +34,14 @@ print("Initialize OK")
|
||||
|
||||
# Get device count
|
||||
device_count = AT_64(0)
|
||||
ret = atcore.AT_GetInt(AT_HANDLE_SYSTEM, "Device Count", ctypes.byref(device_count))
|
||||
ret = lib.AT_GetInt(AT_HANDLE_SYSTEM, "Device Count", ctypes.byref(device_count))
|
||||
if ret != AT_SUCCESS:
|
||||
print(f"ERROR: Get device count failed, code: {ret}")
|
||||
else:
|
||||
print(f"Device count: {device_count.value}")
|
||||
|
||||
# Finalize
|
||||
ret = atcore.AT_FinaliseLibrary()
|
||||
ret = lib.AT_FinaliseLibrary()
|
||||
if ret != AT_SUCCESS:
|
||||
print(f"ERROR: Finalize failed, code: {ret}")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user