Arrays and CTYPE

G

Glenn Pringle

Ok. I ran into a problem here. I have been dabbling with Python and I
thought that this would be a good exercise but I got stuck.

I have a DLL and one of the functions(getState) in that DLL returns an
array. I'm having a hard time getting access to the contents of that
array.

Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
Would greatly appreciate if somebody points me in the right direction.


Thanks,


Glenn
 
C

Chris Rebert

Ok. I ran into a problem here. I have been dabbling with Python and I
thought that this would be a good exercise but I got stuck.

I have a DLL and one of the functions(getState) in that DLL returns an
array. I'm having a hard time getting access to the contents of that
array.

Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
Would greatly appreciate if somebody points me in the right direction.

Set hold.getState.restype appropriately. Read the fine docs:
http://docs.python.org/library/ctypes.html#return-types
http://docs.python.org/library/ctypes.html#fundamental-data-types

Cheers,
Chris
 
N

Nobody

Ok. I ran into a problem here. I have been dabbling with Python and I
thought that this would be a good exercise but I got stuck.

I have a DLL and one of the functions(getState) in that DLL returns an
array.

If the DLL was written in C (or C++), it can't return an array; it will
return a pointer instead.
I'm having a hard time getting access to the contents of that
array.

Set getState.restype to a pointer type, e.g.:

hold.getState.restype = POINTER(c_int)

Pointer types can be indexed with [], as in C.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,230
Latest member
LifeBoostCBD

Latest Threads

Top