PCSU200 saving data with dll

Hey,

I’m working on doing measurements with the PCSU200 in python but struggling with saving the data via

ReadCh1(Buffer: Pointer)

I’m not that into ctypes. Maybe someone has a solution for me?
Currently I have something like

cresult = (ctypes.c_ulong * 5000)()
data_1=PCSU200dll.ReadCh1(cresult)

But yeah, that doesn’t work :frowning:

Indeed, not very easy in Python…
I got finally this working:

print("Read Ch1 values")
arrayType = ctypes.c_long * 5000
ch1 = arrayType()
PCSU200dll.ReadCh1(ctypes.byref(ch1))

print("Print 10 first Ch1 values")
for x in range(10):
    print(x,"=",ch1[x])

2 Likes

Also this seems to work fine.
Here the only difference with your original code is the added “ctypes.byref”.

ch1 = (ctypes.c_ulong * 5000)()
PCSU200dll.ReadCh1(ctypes.byref(ch1))
2 Likes

Thank you so much!
You don’t happen to know how to save DataReady from the dll as a proper boolean in python? :smiley:

The function DataReady() seems to return ‘0’ (False) or ‘1’ (True):
You can use bool() method to convert it to boolean:

b = bool(PCSU200dll.DataReady())
print ("Data ready =", b)
2 Likes