Added some checking of return values for errors
This commit is contained in:
parent
6639f730fc
commit
9a472f9f4a
1 changed files with 19 additions and 8 deletions
27
demo/tut1.c
27
demo/tut1.c
|
@ -20,15 +20,26 @@ int aref = AREF_GROUND; /* more on this later */
|
|||
int main(int argc,char *argv[])
|
||||
{
|
||||
comedi_t *it;
|
||||
int chan=0;
|
||||
int chan = 0;
|
||||
lsampl_t data;
|
||||
|
||||
it=comedi_open("/dev/comedi0");
|
||||
|
||||
comedi_data_read(it,subdev,chan,range,aref,&data);
|
||||
|
||||
printf("%d\n",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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue