Added help() and --help flag
authorDavid Schleef <ds@schleef.org>
Wed, 25 Sep 2002 01:02:57 +0000 (01:02 +0000)
committerDavid Schleef <ds@schleef.org>
Wed, 25 Sep 2002 01:02:57 +0000 (01:02 +0000)
comedi_calibrate/comedi_calibrate.c

index dc2a2fd99dd0e6c28f84d2b9c6e065d0ead10792..eb8905fc88c50347d46d1ce41ed7dc6299aee03a 100644 (file)
@@ -69,6 +69,7 @@ struct option options[] = {
        { "verbose", 0, 0, 'v' },
        { "quiet", 0, 0, 'q' },
        { "file", 1, 0, 'f' },
+       { "help", 0, 0, 'h' },
        { "driver-name", 1, 0, 0x1000 },
        { "device-name", 1, 0, 0x1001 },
        { "reset", 0, &do_reset, 1 },
@@ -84,6 +85,22 @@ struct option options[] = {
        { 0 },
 };
 
+void help(void)
+{
+       printf("comedi_calibrate [options] - autocalibrates a Comedi device\n");
+       printf("  --verbose, -v  \n");
+       printf("  --quiet, -q  \n");
+       printf("  --help, -h  \n");
+       printf("  --file, -f [/dev/comediN] \n");
+       printf("  --driver-name [driver]  \n");
+       printf("  --device-name [device]  \n");
+       printf("  --[no-]reset  \n");
+       printf("  --[no-]calibrate  \n");
+       printf("  --[no-]dump  \n");
+       printf("  --[no-]results  \n");
+       printf("  --[no-]output  \n");
+}
+
 int main(int argc, char *argv[])
 {
        char *fn = NULL;
@@ -106,6 +123,10 @@ int main(int argc, char *argv[])
                switch (c) {
                case 0:
                        continue;
+               case 'h':
+                       help();
+                       exit(0);
+                       break;
                case 'f':
                        fn = optarg;
                        break;
@@ -122,7 +143,7 @@ int main(int argc, char *argv[])
                        devicename = optarg;
                        break;
                default:
-                       //printf("bad option %d\n",c);
+                       help();
                        exit(1);
                }
        }
@@ -205,6 +226,8 @@ ok:
        if(do_calibrate && setup.do_cal) setup.do_cal( &setup );
        if(do_results) observe( &setup );
 
+       comedi_close(dev);
+
        return 0;
 }