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