Forum Italiano sui Prodotti NI

annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

problema con liberia per la funzione `DAQmxResetDevice'

Salve. Stò usando la scheda di acquisizione NI PCI6229 e mentre compilo il codice fornito da voi negli esempi ho un problema:

/*********************************************************************
*
* ANSI C Example program:
*    acquire1Scan.c
*
* Example Category:
*    AI
*
* Description:
*    This example demonstrates how to take a single Measurement
*    (Sample) from an Analog Input Channel.
*
* Instructions for Running:
*    1. Select the Physical Channel to correspond to where your
*       signal is input on the DAQ device.
*    2. Enter the Minimum and Maximum Voltage Ranges.
*    Note: For better accuracy try to match the Input Ranges to the
*          expected voltage level of the measured signal.
*    Note: Use the voltUpdate example to provide a signal on
*          your DAQ device to measure.
*
* Steps:
*    1. Create a task.
*    2. Create an Analog Input Voltage Channel.
*    3. Use the Read function to Measure 1 Sample from 1 Channel on
*       the Data Acquistion Card. Set a timeout so an error is
*       returned if the sample is not returned in the specified time
*       limit.
*    4. Display an error if any.
*
* I/O Connections Overview:
*    Make sure your signal input terminal matches the Physical
*    Channel I/O Control.
*
* Recommended Use:
*    Call the Read function.
*
*********************************************************************/

#include "NIDAQmxBase.h"
#include <stdio.h>

#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }

int main(int argc, char *argv[])
{
    // Task parameters
    int32       error = 0;
    TaskHandle  taskHandle = 0;
    char        errBuff[2048]={'\0'};

    // Channel parameters
    char        chan[] = "dev1/ai0";
    float64     min = -10.0;
    float64     max = 10.0;

    // Timing parameters
    uInt64      samplesPerChan = 1;

    // Data read parameters
    float64     data;
    int32       pointsToRead = 1;
    int32       pointsRead;
    float64     timeout = 10.0;

    DAQmxErrChk (DAQmxResetDevice("dev1"));
    DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
    DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,&data,samplesPerChan,&pointsRead,NULL));

    printf ("Acquired reading: %f\n", data);

Error:
    if( DAQmxFailed(error) )
        DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
    if( taskHandle!=0 ) {
        DAQmxBaseStopTask(taskHandle);
        DAQmxBaseClearTask(taskHandle);
    }
    if( DAQmxFailed(error) )
        printf("DAQmxBase Error: %s\n",errBuff);
    return 0;
}


Rispetto all'originale ho aggiunto solo la riga: DAQmxErrChk (DAQmxResetDevice("dev1")); . La cosa strana è che senza compila, mentre con tale riga c'è l'errore:

root@nanny:/usr/local/natinst/nidaqmxbase/examples/ai# make
gcc -I../../include -O2 acquire1Scan.c -lnidaqmxbase -llvrtdark -o acquire1Scan
/tmp/ccK0zNNV.o(.text+0x57): In function `main':
: undefined reference to `DAQmxResetDevice'
collect2: ld returned 1 exit status
make: *** [acquire1Scan] Error 1

Cosa può essere?
Grazie,

Massimo
0 Kudos
Messaggio 1 di 5
4.692Visualizzazioni

Ritengo che il problema sia nel pacchetto daqmx installato: il sorgente risulta preso dalla libreria di esempi del DAQMx Base, mentre evidentemente il comando ResetDevice appartiene al pacchetto DAQMx completo. Secondo la pagina di download del DAQMx Base, questo prodotto contiene solo una parte delle funzioni DAQMx. Dovresti trovare nel tuo computer un readme con le differenze fra la versione base e quella completa.

In ogni caso la versione completa del DAQMx dovrebbe essere sui CD della tua scheda o comunque si può scaricare dal sito (certo, sono più di 500 MB... Smiley Sorpreso)



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Messaggio 2 di 5
4.677Visualizzazioni
Che Sistema Operativo stai usando? Ciao Giuseppe
0 Kudos
Messaggio 3 di 5
4.646Visualizzazioni
Uso Linux.
Ciao.
0 Kudos
Messaggio 4 di 5
4.641Visualizzazioni
Scusa, intendevo quale distribuzione di Linux. ciao
0 Kudos
Messaggio 5 di 5
4.640Visualizzazioni