PyDAQmx icon indicating copy to clipboard operation
PyDAQmx copied to clipboard

Segmentation fault at cleanup

Open pjaneck opened this issue 10 years ago • 1 comments

Hi,

first, thanks for the module I love python and this helps me a lot. I'm using PyDAQmx with openSuse and DAQmxbase 14.0.0. It works great with the basic functionality, however when I use the Task() class there is always an error message when calling the class destructor:

LabVIEW caught fatal signal 12.0.1f5 - Received SIGSEGV Reason: address not mapped to object Attempt to reference address: 0x0xb5c3a500 Segmentation fault

The data acquisition works by the way.

pjaneck avatar Aug 05 '15 13:08 pjaneck

@pjaneck Hard to say what was the exact error without your code. But, I had the same error executing this code:

import numpy as np
import PyDAQmx

button_port = [(2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (0, 2)]
line_names = ', '.join(['Dev1/port{}/line{}'.format(port, line)
                        for port, line in button_port])

data = np.zeros(1, dtype=np.uint32)
read = PyDAQmx.int32()
task = PyDAQmx.Task()
task.CreateDIChan(line_names, "", PyDAQmx.DAQmx_Val_ChanForAllLines)
task.StartTask()
task.ReadDigitalU32(-1, 1, PyDAQmx.DAQmx_Val_GroupByChannel,
                    data, 1000, PyDAQmx.byref(read), None)
task.StopTask()
task.ClearTask()
print('done!')

I was using a array (data) of length 1, but I was indicating it had a length of 1000. The acquisition would go well, return correct readings, but Python would crash at exit. Correcting the line with:

task.ReadDigitalU32(-1, 1, PyDAQmx.DAQmx_Val_GroupByChannel,
                    data, len(data), PyDAQmx.byref(read), None)

fixed the problem. Hope it helps.

benureau avatar Dec 08 '16 14:12 benureau