Voglio chiamare una funzione all'interno di una DLL da Python. Ma sto ottenendo questo errore:Chiamare una funzione DLL da Python
"Attribute Error function not found"
Questo è il mio codice:
import os
import ctypes
os.chdir("C:\\Program Files\\Compact Automated Testing System V2.0")
# Load DLL into memory.
CATSDll = ctypes.WinDLL ("CATS.dll")
# Set up prototype and parameters for the desired function call.
CATSDllApiProto = ctypes.WINFUNCTYPE (ctypes.c_uint8,ctypes.c_double)
CATSDllApiParams = (1, "p1", 0), (1, "p2", 0),
# Actually map the call (setDACValue) to a Python name.
CATSDllApi = CATSDllApiProto (("setDACValue", CATSDll), CATSDllApiParams)
# Set up the variables and call the Python name with them.
p1 = ctypes.c_uint8 (1)
p2 = ctypes.c_double (4)
CATSDllApi(p1,p2)
Ma la documentazione DLL mostra una funzione setDACValue
con ChannelId
& DAC Voltage
come gli ingressi.
Quanto sopra si basa su un pezzo di codice disponibile da StackOverflow.
Ho anche provato il metodo semplice di usare cdll.LoadLibrary & quindi chiamando la funzione, ma anche questo dà lo stesso errore.
Qualcuno può suggerirmi cosa c'è che non va? Grazie.
completa Traceback:
Traceback (most recent call last):
File "C:\Users\AEC_FULL\Softwares\eclipse\plugins\org.python.pydev_3.9.2.201502050007\pysrc\pydevd.py", line 2235, in <module>
globals = debugger.run(setup['file'], None, None)
File "C:\Users\AEC_FULL\Softwares\eclipse\plugins\org.python.pydev_3.9.2.201502050007\pysrc\pydevd.py", line 1661, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Users\AEC_FULL\Saravanan\Workspace\CATS\CATS.py", line 18, in <module>
CATSDllApi = CATSDllApiProto (("setDACValue", CATSDll), CATSDllApiParams)
AttributeError: function 'setDACValue' not found
Potrebbe fornire la firma della funzione 'setDACValue'? – kvorobiev
Ciao kvorobiev ..aggiunto la firma .. – user3561075