I'm trying to access an array of ints in DLL from Python. I'm following the guidelines in the ctypes documentation page, but I get Null pointer access exception. My code is:
if __name__ == "__main__":
cur_dir = sys.path[0]
os.chdir(cur_dir)
api = CDLL("PCIE_API")
PciAgentIndex=POINTER(c_uint32).in_dll(api, "PciAgentIndex")
print(PciAgentIndex)
print(PciAgentIndex[0])
And I get:
ValueError: NULL pointer access
When I printing the last line.
When I run this code snippet through Eclipse debugger and check the content attribute of PciAgentIndex I get:
str: Traceback (most recent call last):
File "C:\Program Files\eclipse\plugins\org.python.pydev_2.7.5.2013052819\pysrc\pydevd_resolver.py", line 182, in _getPyDictionary
attr = getattr(var, n)
ValueError: NULL pointer access
What am I doing wrong? I'm on Windows and using Python 3.3.2.