Hello! I am trying to call this method:

long _stdcall AIBurst(long *idnum,
                         long demo,
                         long stateIOin,
                         long updateIO,
                         long ledOn,
                         long numChannels,
                         long *channels,
                         long *gains,
                         float *scanRate,
                         long disableCal,
                         long triggerIO,
                         long triggerState,
                         long numScans,
                         long timeout,
                         float (*voltages)[4],
                         long *stateIOout,
                         long *overVoltage,
                         long transferMode);

I am having some problems with that  float (*voltages)[4]. Here is
what I tried:

def aiBurst(self, channels, scanRate, numScans, idNum=None, demo=0,
stateIOin=[0, 0, 0, 0], updateIO=0, ledOn=0, gains=[0, 0, 0, 0],
disableCal=0, triggerIO=0, triggerState=0, timeout=1, transferMode=0):

        if idNum is None:
            idNum = self.id

        idNum = ctypes.c_long(idNum)

        numChannels = len(channels)

        stateIOArray = listToCArray(stateIOin, ctypes.c_long)
        channelsArray = listToCArray(channels, ctypes.c_long)
        gainsArray = listToCArray(gains, ctypes.c_long)
        scanRate = ctypes.c_float(scanRate)
        pointerArray = (ctypes.c_void_p * 4)
        voltages = pointerArray(ctypes.cast(ctypes.pointer
((ctypes.c_long * 4096)()), ctypes.c_void_p), ctypes.cast
(ctypes.pointer((ctypes.c_long * 4096)()), ctypes.c_void_p),
ctypes.cast(ctypes.pointer((ctypes.c_long * 4096)()),
ctypes.c_void_p), ctypes.cast(ctypes.pointer((ctypes.c_long * 4096)
()), ctypes.c_void_p))
        stateIOout = (ctypes.c_long * 4096)()
        overVoltage = ctypes.c_long(999)

        staticLib.AIBurst(ctypes.byref(idNum), demo, stateIOArray,
updateIO, ledOn, numChannels, ctypes.byref(channelsArray), ctypes.byref
(gainsArray), ctypes.byref(scanRate), disableCal, triggerIO,
triggerState, numScans, timeout, ctypes.byref(voltages), ctypes.byref
(stateIOout), ctypes.byref(overVoltage), transferMode)

The program runs but the values that come back in the array are not
right. However, I am not sure if I am passing the array or if I am
just not reading them well afterwards. What is the best way to put
this in and what is the best way to cast it and read it back?

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to