- From: Askar Ibragimov <askar.ibragimov_at_gmail.com>
- Date: Mon, 15 Oct 2007 11:42:54 +0300
Hi,
why not to use comedi_data_read () ?
2007/10/15, José Alejandro López Corella <corella91_at_yahoo.com>:
> 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
>
--
ICQ 19576333 Cellular +358 45 6386080
Received on 2007-10-15Z07:42:54