fixed some bad behaviour when using default calibration file path
authorFrank Mori Hess <fmhess@speakeasy.net>
Wed, 7 May 2003 00:13:00 +0000 (00:13 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Wed, 7 May 2003 00:13:00 +0000 (00:13 +0000)
comedi_calibrate/comedi_calibrate.c
comedi_calibrate/save_cal.c

index ae79c84eb5b857c74fd5db389a3aab8fcb341123..26c6bfff945add3b8ece40fdef525f09ae5dcc58 100644 (file)
@@ -194,7 +194,6 @@ int main(int argc, char *argv[])
        options.do_output = 1;
        options.file_path = "/dev/comedi0";
        parse_options( argc, argv, &options );
-       setup.cal_save_file_path = options.save_file_path;
 
        setup.dev = comedi_open( options.file_path );
        if( setup.dev == NULL ) {
@@ -204,6 +203,8 @@ int main(int argc, char *argv[])
                exit(0);
        }
 
+       if( options.save_file_path == NULL )
+               options.save_file_path = comedi_get_default_calibration_path( setup.dev );
        if(!options.driver_name)
                options.driver_name=comedi_get_driver_name( setup.dev );
        if(!options.device_name)
@@ -281,6 +282,7 @@ ok:
                else options.do_calibrate = 1;
        }
        setup.do_output = options.do_output;
+       setup.cal_save_file_path = options.save_file_path;
 
        if(options.do_dump) observe( &setup );
        if(options.do_calibrate && setup.do_cal)
index 1671b7a0babbba1183ba31a958d9108668606000..ac472d7944ea3adf5aab6188c99d537b1d1ba459 100644 (file)
@@ -118,32 +118,10 @@ int write_calibration_file( calibration_setup_t *setup )
 {
        FILE *file;
        int retval;
-       static const char *save_dir = "/etc/comedi/calibrations";
-       char command[ 100 ];
-       struct stat file_stats;
-       comedi_t *dev = setup->dev;
 
        assert( setup->new_calibration != NULL );
+       assert( setup->cal_save_file_path );
 
-       if( setup->cal_save_file_path == NULL )
-       {
-               if( fstat( comedi_fileno( dev ), &file_stats ) < 0 )
-               {
-                       fprintf( stderr, "failed to get file stats of comedi device file\n" );
-                       return -1;
-               }
-
-               snprintf( command, sizeof( command ), "install -d %s", save_dir );
-               if( system( command ) )
-               {
-                       fprintf( stderr, "failed to create directory %s\n", save_dir );
-                       return -1;
-               }
-
-               asprintf( &setup->cal_save_file_path, "%s/%s_comedi%li",
-                       save_dir, comedi_get_board_name( dev ),
-                       ( unsigned long ) minor( file_stats.st_rdev ) );
-       }
        file = fopen( setup->cal_save_file_path, "w" );
        if( file == NULL )
        {