I'm trying to use a sensor by Senis through my own Python code by using ctypes with the company's provided dll.
The manual descirbes the function declaration for getting the sensor measurement as follows:
typedef struct {
int dimSize;
int elt[x];
} TD2;
typedef TD2 **TD2Hdl;
int get_sensor_values (int* device_number, unsigned long* timestamp, TD2Hdl values )
I have tried to use this dll declaration with my own code:
from ctypes import *
class TD2Hdl(Structure):
_fields_ = [("dimSize", c_int),
("elt", POINTER(c_int))]
if __name__ == '__main__':
senDLL = cdll.LoadLibrary("3mtslib.dll")
num = c_int(0)
ts = c_ulong(0)
td = TD2Hdl(0, None)
senDLL.open_device(byref(c_int(0)))
senDLL.get_sensor_values(byref(c_int(num)), byref(ts), td)
I have also tried allocating different sizes of int arrays for the 'elt' variable through such instances as
td = TD2Hdl(0, (c_int*8)(*arr))
With different array sizes. However, I get an access violation reading with anything I try.
I will highly appreciate any help in understanding what I'm missing with how to allocate memory for structs passed to ctypes functions.
I validated the function name with dumpbin and to be clear, the rest of the functions work well.
Thank you!