Hello,
i've got a problem with pointers in the following function which i want
to use:
I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value)
The function is supposed to read out the status of a digital port of
analog digital interface card.
I got this function from Dask.h which came with the card. The relevant
lines concerning this function are the following:
typedef short I16;
typedef unsigned short U16;
typedef unsigned long U32;
I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value)
I tried to implement this function into python:
# I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value);
ReadOPort = dask.DO_ReadPort
ReadOPort.argtypes = [c_ushort, c_ushort, c_ulong]
ReadOPort.restype = c_short
I can't handle the pointer "Value" which should be an unsigned long
pointer. I'd be very happy, if u could give me a hint how to implement
this pointer into python.
Thanks a lot
Carlo and Pierre 3 4979
Le 29 Aug 2005 06:19:17 -0700, ru**********@web.de a écrit : Hello, i've got a problem with pointers in the following function which i want to use:
I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value)
The function is supposed to read out the status of a digital port of analog digital interface card. I got this function from Dask.h which came with the card. The relevant lines concerning this function are the following:
typedef short I16; typedef unsigned short U16; typedef unsigned long U32;
I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value)
I tried to implement this function into python: # I16 __stdcall DO_ReadPort (U16 CardNumber, U16 Port, U32 *Value); ReadOPort = dask.DO_ReadPort ReadOPort.argtypes = [c_ushort, c_ushort, c_ulong] ReadOPort.restype = c_short
I can't handle the pointer "Value" which should be an unsigned long pointer. I'd be very happy, if u could give me a hint how to implement this pointer into python.
You can use the ctypes.byref() function (as it is in an argulent list):
ReadOPort.argtypes = (c_ushort, c_ushort, ctypes.POINTER(c_ulong) )
ReadOPort.restype = c_short
status = c_ulong() # status value to be read
number = c_ushort(1) # CardNumber = 1
port = c_ushort(11)
rc = ReadOPort(number, port, ctypes.byref(status))
print rc, ststus Thanks a lot
Carlo and Pierre
thanks a bunch, i just got the answer myself. next time i think about
it a little longer.
thanks again
carlo
F. Petitjean wrote: Le 29 Aug 2005 06:19:17 -0700, ru**********@web.de a écrit :
....
You can use the ctypes.byref() function (as it is in an argulent list):
ReadOPort.argtypes = (c_ushort, c_ushort, ctypes.POINTER(c_ulong) ) ReadOPort.restype = c_short status = c_ulong() # status value to be read number = c_ushort(1) # CardNumber = 1 port = c_ushort(11) rc = ReadOPort(number, port, ctypes.byref(status)) print rc, ststus
Just as an FYI, Thomas has recently added code which does the byref
automatically. The version of ctypes in CVS HEAD will allow you to pass
in a c_ulong where the argtype is ctypes.POINTER(c_ulong).
Have fun,
Mike
--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thomas Heller |
last post by:
ctypes 0.9.2 released - Oct 28, 2004
====================================
Overview
ctypes is a ffi (Foreign Function Interface) package for Python
2.3 and higher.
ctypes allows to call...
|
by: Lenard Lindstrom |
last post by:
Posted in a previous thread was some Python code for accessing Window's
Simple MAPI api using the ctypes module.
http://groups-beta.google.com/group/comp.lang.python/msg/56fa74cdba9b7be9
This...
|
by: Richard Jones |
last post by:
Does anyone know how to do the equivalent of this using ctypes?
image_data = malloc(width * height * components);
row_pointers = png_get_rows(png_ptr, info_ptr);
for (y = 0; y < height; y++)...
|
by: sjdevnull |
last post by:
Hey,
I'm trying to wrap GNU readline with ctypes (the Python readline
library doesn't support the callback interface), but I can't figure out
how to set values to a variable inside the library. ...
|
by: Diez B. Roggisch |
last post by:
Hi,
I'm working under mac os x with the OpenCV-library that I load via ctypes.
From a ObjectiveC-methodcall I get an integer, that "really" is a
pointer to an IplImage-structure.
I've got a...
|
by: stalex |
last post by:
I'm wrapping a C function exists in a shared library. Its prototype
looks like as follows
int getFileNames(int aSize, char **names);
The documentation says that the asSize is the number of...
|
by: Jack |
last post by:
I'm not able to build IP2Location's Python interface so I'm
trying to use ctypes to call its C interface. The functions
return a pointer to the struct below. I haven't been able to
figure out how...
|
by: Matt |
last post by:
Hi friends,
Okay so well, I have quite a problem right now with a file stream. What
I am doing is to use the Cannon SDK dlls to get control over my old
Cannon A60 Camera for some surveillance...
|
by: Ron Garret |
last post by:
CTypes on a 64-bit machine appears to be truncating pointers to 32 bits:
$ uname -a
Linux monster1 2.6.18-6-amd64 #1 SMP Mon Jun 16 22:30:01 UTC 2008 x86_64
GNU/Linux
$ cat foo.c
void*...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |