I'd like to resize a ctypes array. As you can see, ctypes.resize doesn't work like it could. I can write a function to resize an array, but I wanted to know ... |
I have a DLL containing a C function with a prototype like this:
int c_read_block(uint32 addr, uint32 *buf, uint32 num);
I want to call it from Python using ctypes. The function expects a ... |
I have the function prototype here:
extern "C" void __stdcall__declspec(dllexport) ReturnPulse(double*,double*,double*,double*,double*);
I need to write some python to access this function that is in a DLL.
I have loaded the DLL, but
each of the ... |
We have some binary files created by a C program.
One type of file is created by calling fwrite to write the following C structure to file:
typedef struct {
unsigned ...
|
This is Python question. I have a variable A
>>> A
<Swig Object of type 'uint16_t *' at 0x8c66fa0>
>>> help(A)
class PySwigObject(object)
Swig object carries a C/C++ instance pointer
The instance referred by ... |
I'm trying to call an external library function that returns a NULL-terminated array of NULL-terminated strings.
kernel32 = ctypes.windll.kernel32
buf = ctypes.create_unicode_buffer(1024)
length = ctypes.c_int32()
if kernel32.GetVolumePathNamesForVolumeNameW(ctypes.c_wchar_p(volume),
buf, ctypes.sizeof(buf), ctypes.pointer(length)):
...
|
I wanted to wrap a small C++ code allocating an array with ctypes and there is something wrong with storing the address in a c_void_p object.
(Note: the pointers are intentionally cast ... |
|
I read the official ctypes tutorial and also searched SO, but I could not find a way to declare this kind of structure with ctypes. This structure is returned ... |
I'm calling a C function using ctypes from Python. It returns a pointer to a struct, in memory allocated by the library (the application calls another function to free it ... |
I have a simple byte array I've filled with a x86 -program. Which I need to execute at runtime.
"""
Produces a simple callable procedure which returns a constant.
"""
from ...
|
I use ctypes to access a file reading C function in python. As the read data is huge and unknown in size I use **float in C .
int read_file(const char ... |
I have the below arrays on C how can i interpert them to ctypes datatypes inside structre
struct a {
BYTE a[30];
CHAR b[256];
};
should i interpert a ... |
I'm trying to pass an array of character arrays to a C function using ctypes.
void cfunction(char ** strings)
{
strings[1] = "bad"; //works not what I need.
strings[1][2] = 'd'; //this will ...
|
If I have the follow 2 sets of code, how do I glue them together?
void
c_function(void *ptr) {
int i;
for (i = 0; i < ...
|
This is a followup to Multi-dimensional char array (array of strings) in python ctypes. . I have a c function that manipulates an array of strings. The data type ... |
I was trying to use the ctypes module for a project. I was creating a dynamically allocated array of "max_entries" pairs and once the array was exhausted, I was creating a ... |
I want to pass an array of char pointer to a C function.
I refer to http://docs.python.org/library/ctypes.html#arrays
I write the following code.
from ctypes import *
names = c_char_p * 4
# A 3 ...
|
My following C code works quite well, till my Python code trying to pass an array of char pointer to it.
The output I obtain is
The file_name is python-file
Another ... |
I'm using ctypes to work with libgphoto2 in Python. The following code succeeds on a 32-bit machine, but fails with a Segmentation Fault on a 64-bit machine (Linux, Ubuntu):
import ctypes
gp = ...
|
I'm wrapping a C library that uses callbacks as external memory allocators. Basically, instead of doing malloc and free itself, it exposes several callbacks for making buffers of specified sizes. ... |
I would like to have an array of variable length arrays in ctypes. I know the size of the outer array and all of the inner arrays, too.
I found an interesting ... |
I want to access a C function that returns a struct containing double arrays (where the lengths of these arrays is given by other int members of the struct) from python. ... |
How do I define a multi-dimensional float array using ctypes in python?
Is there a limitation to the number of dimensions that can be defines?
|
I am using Python, PIL and ctypes to do image manipulation. As I hacked stuff together, I used PIL's fromstring function to get the pixel buffer from ctypes into a ... |
I have a C++ callback function that calls into Python using ctypes. This function's parameters are a pointer to an array of double and the number of elements.
There are a ... |
I have a function that accepts a double array as first parameter
cb_type = CFUNCTYPE(c_void_p, c_double * 2, c_int, c_int)
def mycb(cube, ndim, nparams):
print "cube before", [v for v ...
|
I wrote a wrapper class around libpcap for python3 but I'm struggling to find useful documentation on how to deal with ctype arrays in python.
self.packetdata = ctypes.POINTER(ctypes.c_ubyte*65536)()
....
return self.pkthdrPointer.contents.len,self.packetdata.contents
I ... |
I have a native python bridge to some C code, which returns a pointer to an array (array of structs). The struct contains some character arrays (strings). But how can I ... |
I have a C-function that allocates memory at the address passed to and is accessed via Python. The pointer contents does contain an array of structs in the C code, but ... |
#ifndef TNT_H_ #define TNT_H_ #include "tnt/tnt.h" using namespace TNT; #endif struct var_model { Array2D a; Array1D b; }; how to create an array of struct in ctypes/python to send data to the function ext_foo in a dynamically shared library??? I was trying but I got a lot of error message from Python . The code in C++ is: #ifndef TNT_H_ #define ... |
|
|
Hi, I have a function that takes __out LPBYTE *bufptr, as one of the parameters. I am wondering how to create that in ctypes? I attempted to do this. _num_entries = 100; _srv_100 = (c_byte * _num_entries)(); _data_ptr = cast(_srv_100, POINTER(BYTE)); and pass it as : (_data_ptr), as one of the parameters. This doesn't work, since the API apperently sees the ... |