/usr/share/doc/libcomedi-dev/demo/tut1.c is in libcomedi-dev 0.10.1-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /*
* Tutorial example #1
* Part of Comedilib
*
* Copyright (c) 1999,2000 David A. Schleef <ds@schleef.org>
*
* This file may be freely modified, distributed, and combined with
* other software, as long as proper attribution is given in the
* source code.
*/
#include <stdio.h> /* for printf() */
#include <comedilib.h>
int subdev = 0; /* change this to your input subdevice */
int chan = 0; /* change this to your channel */
int range = 0; /* more on this later */
int aref = AREF_GROUND; /* more on this later */
int main(int argc,char *argv[])
{
comedi_t *it;
int chan = 0;
lsampl_t data;
int retval;
it = comedi_open("/dev/comedi0");
if(it == NULL)
{
comedi_perror("comedi_open");
return -1;
}
retval = comedi_data_read(it, subdev, chan, range, aref, &data);
if(retval < 0)
{
comedi_perror("comedi_data_read");
return -1;
}
printf("%d\n", data);
return 0;
}
|