From: Ian Abbott Date: Thu, 13 Aug 2009 11:16:04 +0000 (+0000) Subject: Check subdevice type. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=becded6ae0d7f72268a80acfceccf0d0a8534ab2;p=comedilib.git Check subdevice type. --- diff --git a/demo/gpct_pulse_generator.c b/demo/gpct_pulse_generator.c index 94bdb7c..7c85ae9 100644 --- a/demo/gpct_pulse_generator.c +++ b/demo/gpct_pulse_generator.c @@ -102,6 +102,7 @@ int main(int argc, char *argv[]) unsigned up_time; unsigned period_ns; int retval; + int subdevice_type; struct parsed_options options; init_parsed_options(&options); @@ -125,7 +126,18 @@ int main(int argc, char *argv[]) comedi_perror(options.filename); exit(-1); } - /*FIXME: check that device is counter */ + subdevice_type = comedi_get_subdevice_type(device, options.subdevice); + if(subdevice_type < 0) + { + comedi_perror("comedi_get_subdevice_type()"); + return -1; + } + if(subdevice_type != COMEDI_SUBD_COUNTER) + { + fprintf(stderr, "Subdevice is not a counter (type %i), but of type %i.\n", + COMEDI_SUBD_COUNTER, subdevice_type); + return -1; + } printf("Generating pulse train on subdevice %d.\n", options.subdevice); printf("Period = %d ns.\n", period_ns); printf("Up Time = %d ns.\n", up_time);