pci1730 data read problem

Hi to all

I have a problem since I cannot read data with the
card advantech pci 1730 but if I can have exit of
data.

somebody can help me?

#include <stdio.h>
#include <malloc.h>
#include <string.h>

#include <comedilib.h>

#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>

const int NBITS = 8;

int main(int argc, char **argv){
	comedi_t *comedi;
	comedi_insn cmd;
	lsampl_t bits[NBITS];
	int ret, channel, range, subdev, aref, i;

	/* Limpiamos los valores de bits */
	memset(bits, 0, sizeof(lsampl_t) * NBITS);

	/* Abrimos el device del comedi*/ 
	comedi = comedi_open("/dev/comedi0");

	if (comedi == NULL){
		printf("No se pudo abrir /dev/comedi0\n");
		return 0;
	}
	
	/* Seleccionamos Canal y rango */
	channel = 0;
	range = 0;
	aref = AREF_GROUND;
	subdev = 0;

	/* Banderas, INSN_BITS es para modo digital. */
	cmd.insn = INSN_BITS | INSN_READ;
	cmd.n = NBITS;			/* Numero de elementos a leer */
	cmd.data = (void*)bits;	/* Apuntador a los datos */
	cmd.subdev = subdev;		/* Cambiar! */

	/* Empaqueta los datos de adquisicion, canal, rango y
aref*/
	cmd.chanspec = CR_PACK(channel, range, aref);	/*
Cambiar! */
	
	/*ret = comedi_dio_config(comedi, subdev, channel,
INSN_CONFIG_DIO_INPUT);*/

	if (ret == -1)
		printf("Error configurando el canal de entrada\n");

	ret = comedi_do_insn(comedi, &cmd);

	printf("Muestras tomadas: %i\n", ret);

	for (i = 0; i < NBITS; i++){
		if (bits[i]){
			printf("Bit %i: 1\n", i);
		}else{
			printf("Bit %i: 0\n", i);
		}
	}

	comedi_close(comedi);

	return 0;
}



      ____________________________________________________________________________________
¡Sé un mejor fotógrafo!
Perfecciona tu técnica y encuentra las mejores fotos.                       
http://telemundo.yahoo.com/promos/mejorfotografo.html

Received on 2007-10-15Z03:18:12