got rid of global variable device_status
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 27 Apr 2002 19:24:34 +0000 (19:24 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 27 Apr 2002 19:24:34 +0000 (19:24 +0000)
comedi_calibrate/comedi_calibrate.c
comedi_calibrate/ni.c

index 3df3dc7cdbacc936d2e2f93f3fec9a14dd4ead96..26208b18884e99be6942d581265c77cbe28f9454 100644 (file)
@@ -55,15 +55,13 @@ char *devicename = NULL;
 
 int verbose = 0;
 
-int device_status = STATUS_UNKNOWN;
-
 /* */
 
 
 struct board_struct{
        char *name;
        char *id;
-       void (*setup)(void);
+       int (*setup)(void);
 };
 
 struct board_struct drivers[] = {
@@ -105,6 +103,8 @@ int main(int argc, char *argv[])
        int i;
        struct board_struct *this_board;
        int index;
+       int device_status = STATUS_UNKNOWN;
+
 
        fn = "/dev/comedi0";
        while (1) {
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
        return 1;
 
 ok:
-       this_board->setup();
+       device_status = this_board->setup();
 
        if(device_status<STATUS_DONE){
                printf("Warning: device not fully calibrated due to insufficient information\n");
index 7ab32ccfd6cbf7754d9687ee0a0796704bc2cfcb..f7bd2b9415a83a6af4b7468812ba310edcd90017 100644 (file)
@@ -44,7 +44,7 @@ struct board_struct{
        void (*cal)(void);
 };
 
-void ni_setup_board(void);
+int ni_setup_board(void);
 void ni_setup_observables(void);
 
 void cal_ni_at_mio_16e_2(void);
@@ -117,26 +117,31 @@ enum {
        ni_ao1_reference,
 };
 
-void ni_setup(void)
+int ni_setup(void)
 {
-       ni_setup_board();
+       int status;
+       
+       status = ni_setup_board();
        ni_setup_observables();
        setup_caldacs();
+
+       return status;
 }
 
-void ni_setup_board(void)
+int ni_setup_board(void)
 {
        int i;
+       int device_status = STATUS_UNKNOWN;
 
        for(i=0;i<n_boards;i++){
                if(!strcmp(devicename,boards[i].name)){
                        device_status = boards[i].status;
                        do_cal = boards[i].cal;
-                       return;
+                       break;
                }
        }
-       //device_status = STATUS_UNKNOWN;
        //do_cal = cal_ni_unknown;
+       return device_status;
 }
 
 void ni_setup_observables(void)