diff --git a/demo/cmd.c b/demo/cmd.c index 2934341..cd574e0 100644 --- a/demo/cmd.c +++ b/demo/cmd.c @@ -62,6 +62,7 @@ int main(int argc, char *argv[]) struct parsed_options options; init_parsed_options(&options); + options.subdevice = -1; parse_options(&options, argc, argv); /* The following variables used in this demo @@ -84,6 +85,17 @@ int main(int argc, char *argv[]) exit(1); } + if(options.subdevice < 0) { + /* Subdevice not set on command line. */ + /* Default to the 'read' subdevice (if any). */ + options.subdevice = comedi_get_read_subdevice(dev); + if(options.subdevice < 0) { + /* No 'read' subdevice, so default to 0 instead. */ + options.subdevice = 0; + } + fprintf(stderr, "defaulted to subdevice %d\n", options.subdevice); + } + // Print numbers for clipped inputs comedi_set_global_oor_behavior(COMEDI_OOR_NUMBER);