In [1]:
from PyDAQmx import *
import numpy

In [29]:
# Declaration of variable passed by reference
taskHandle = TaskHandle()
data = numpy.zeros((1000,), dtype=numpy.float64)

dev, port, line = 1,0,4

grabChan = "Dev%s/port%s/line%s" % (dev,port,line)
risingEdgeChan = grabChan
fallingEdgeChan = grabChan
samplesPerRead = 1
numLines = c_int(1)

try:
    # DAQmx Configure Code
    DAQmxCreateTask("",byref(taskHandle))
    DAQmxCreateDIChan(taskHandle,grabChan,"",DAQmx_Val_ChanPerLine)
    DAQmxCfgChangeDetectionTiming(taskHandle,risingEdgeChan,fallingEdgeChan,DAQmx_Val_FiniteSamps,samplesPerRead);
    DAQmxGetTaskAttribute(taskHandle,DAQmx_Task_NumChans,byref(numLines));
    

    # DAQmx Start Code
    DAQmxStartTask(taskHandle)

    # DAQmx Read Code
    DAQmxReadDigitalLines(taskHandle,samplesPerRead,10.0,DAQmx_Val_GroupByScanNumber,data,samplesPerRead*numLines,byref(numRead),byref(bytesPerSamp),NULL);

    print "Acquired %d points"%read.value
except DAQError as err:
    print "DAQmx Error: %s"%err
finally:
    if taskHandle:
        # DAQmx Stop Code
        DAQmxStopTask(taskHandle)
        DAQmxClearTask(taskHandle)


DAQmx Error: Device not available in NI-DAQmx. It is possible that the device is being used by Traditional NI-DAQ or that the device is being reset.

After using a device in Traditional NI-DAQ, you must reset the device before using it in NI-DAQmx. For SCXI devices, you must reset the communicator DAQ device. Call the Traditional NI-DAQ Device Reset VI or the Init_DA_Brds function. To reset all devices in Traditional NI-DAQ, right-click the Traditional NI-DAQ Devices folder in MAX and select Reset Driver for Traditional NI-DAQ. If you are resetting the device, wait for the reset to complete.
Task Name: _unnamedTask<B>

Status Code: -200324
 in function DAQmxStartTask

In [38]:
DAQmx_Sys_DevNames


Out[38]:
6459

In [30]:
devicenames = ctypes.create_string_buffer(256)
DAQmxGetSystemInfoAttribute(DAQmx_Sys_DevNames,byref(devicenames))


Out[30]:
0

In [39]:
devicenames.raw


Out[39]:
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

In [5]:
p = ctypes.create_unicode_buffer(256)

In [6]:
p.value


Out[6]:
u''