insn demo
authorDavid Schleef <ds@schleef.org>
Wed, 9 Aug 2000 21:11:29 +0000 (21:11 +0000)
committerDavid Schleef <ds@schleef.org>
Wed, 9 Aug 2000 21:11:29 +0000 (21:11 +0000)
demo/insn.c [new file with mode: 0644]

diff --git a/demo/insn.c b/demo/insn.c
new file mode 100644 (file)
index 0000000..bce46f3
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+   A little input demo
+ */
+
+#include <stdio.h>
+#include <comedilib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ctype.h>
+
+extern int verbose_flag;
+extern int subdevice;
+extern int range;
+extern int channel;
+extern int aref;
+extern char *filename;
+
+comedi_t *device;
+
+
+int main(int argc, char *argv[])
+{
+       int ret;
+       comedi_insn insn;
+       comedi_insnlist il;
+       lsampl_t data;
+
+       parse_options(argc,argv);
+
+       device=comedi_open(filename);
+       if(!device){
+               comedi_perror(filename);
+               exit(0);
+       }
+
+       if(verbose_flag){
+               printf("measuring device=%s subdevice=%d channel=%d range=%d analog reference=%d\n",
+                       filename,subdevice,channel,range,aref);
+       }
+
+       il.n_insns=1;
+       il.insns=&insn;
+
+       insn.insn=INSN_READ;
+       insn.n=1;
+       insn.data=&data;
+       insn.subdev=subdevice;
+       insn.chanspec=CR_PACK(channel,range,aref);
+
+       ret=ioctl(comedi_fileno(device),COMEDI_INSNLIST,&il);
+       //ret=comedi_data_read(device,subdevice,channel,range,aref,&data);
+       if(ret<0){
+               comedi_perror(filename);
+               exit(0);
+       }
+
+       printf("%d\n",data);
+
+       return 0;
+}
+