Hi jcarbonell
Thankyou for giving me hand
I have put a copy of my example code here I am using PCI-DIOHS card under linux
(I am using a altered verison the Red Hat Installation under Slackware 10.2)
by a crash I mean that the appilcation is hanging and I need to reboot before I can use the DIO Card again
Many Thanks
Jonathan Smith
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int32 error=0;
TaskHandle taskHandle=0;
uInt32 data[1000];
int32 sampsRead,totalRead;
char errBuff[2048]={'\0'};
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateDIChan(taskHandle,"Dev1/port0,Dev1/port1","",DAQmx_Val_ChanForAllLines));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"/Dev1/PFI6",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,10000));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
/*********************************************/
// DAQmx Read Code
/*********************************************/
printf("Acquiring samples continuously. Press Ctrl+C to interrupt\n");
printf("TaskHandle %d\n",taskHandle);
while( totalRead< 1000 ) {
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk (DAQmxReadDigitalU32(taskHandle,1,10.0,DAQmx_Val_GroupByScanNumber,data,1,&sampsRead,NULL));
if( sampsRead>0 ) {
totalRead += sampsRead;
printf("Acquired %d samples. Total %d\r",sampsRead,totalRead);
fflush(stdout);
}
}
printf("\n Stopped has Acquired %d total samples.\n",totalRead);
printf("TaskHandle %d\n",taskHandle);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
printf("stoping task ...\n");
DAQmxErrChk (DAQmxStopTask(taskHandle));
printf("is clearing up task ...\n");
DAQmxErrChk (DAQmxClearTask(taskHandle));
}
printf("exiting ...\n");
exit(0);
return 0;
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}