Python wrapper throwing "invalid pointer"

Post general discussions on using our drivers to write your own software here
Post Reply
woutergins
Newbie
Posts: 0
Joined: Fri Feb 26, 2021 4:58 pm

Python wrapper throwing "invalid pointer"

Post by woutergins »

Hi,

I've just taken a PicoScope of the 2000a series into use with a raspberry pi, using the python wrappers to also generate an EPICS server. However, after some time of the scope being in use, it throws either a segmentation fault error, or an "invalid pointer" error. Restarting the scope works perfectly fine, but this behaviour is quite annoying. It occurs while nothing is being actively changed, so the only code running is this part of my custom class:

Code: Select all

    def fetchData(self):
        self.status["runBlock"] = ps.ps2000aRunBlock(self.chandle, self.preTriggerSamples, self.postTriggerSamples, self.timebase, 0, None, 0, None, None)

        # Check for data collection to finish using ps2000aIsReady
        ready = ctypes.c_int16(0)
        while not ready.value:
            self.status["isReady"] = ps.ps2000aIsReady(self.chandle, ctypes.byref(ready))

        # Create buffers ready for assigning pointers for data collection
        buffer = [(ctypes.c_int16 * self.maxSamples)() for _ in self.fetchChannels]
        for i, channel in enumerate(self.fetchChannels):
            returnvalue = ps.ps2000aSetDataBuffer(self.chandle, self.sources[channel], ctypes.byref(buffer[i]), self.maxSamples, 0, 0)
            assert_pico_ok(returnvalue)

        # create overflow location
        overflow = ctypes.c_int16()
        # create converted type maxSamples
        cmaxSamples = ctypes.c_int32(self.maxSamples)

        self.status["getValues"] = ps.ps2000aGetValues(self.chandle, 0, ctypes.byref(cmaxSamples), 1, 0, 0, ctypes.byref(overflow))
        assert_pico_ok(self.status["getValues"])

        self.data = [np.array(adc2mV(b, self.ranges[r], self.maxADC))*1e-3 for b, r in zip(buffer, self.selectedranges)]
        while len(self.data) < 4:
            self.data.append(np.zeros(self.maxSamples))
I can't see where any invalid pointer would be created, or an array would go out of bounds. Even so, I would expect it to run into this problem immediately, rather than after some hours.

Any idea where this might go wrong?

Post Reply