RTXI 1.3
comedilib/demo/tut1.c
Go to the documentation of this file.
00001 /*
00002  * Tutorial example #1
00003  * Part of Comedilib
00004  *
00005  * Copyright (c) 1999,2000 David A. Schleef <ds@schleef.org>
00006  *
00007  * This file may be freely modified, distributed, and combined with
00008  * other software, as long as proper attribution is given in the
00009  * source code.
00010  */
00011 
00012 #include <stdio.h>      /* for printf() */
00013 #include <comedilib.h>
00014 
00015 int subdev = 0;         /* change this to your input subdevice */
00016 int chan = 0;           /* change this to your channel */
00017 int range = 0;          /* more on this later */
00018 int aref = AREF_GROUND; /* more on this later */
00019 
00020 int main(int argc,char *argv[])
00021 {
00022         comedi_t *it;
00023         int chan = 0;
00024         lsampl_t data;
00025         int retval;
00026 
00027         it = comedi_open("/dev/comedi0");
00028         if(it == NULL)
00029         {
00030                 comedi_perror("comedi_open");
00031                 return -1;
00032         }
00033 
00034         retval = comedi_data_read(it, subdev, chan, range, aref, &data);
00035         if(retval < 0)
00036         {
00037                 comedi_perror("comedi_data_read");
00038                 return -1;
00039         }
00040 
00041         printf("%d\n", data);
00042 
00043         return 0;
00044 }
00045 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines