From c3199c93c823b851f87c05674201c7a57c539983 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Wed, 7 May 2003 00:13:00 +0000 Subject: [PATCH] fixed some bad behaviour when using default calibration file path --- comedi_calibrate/comedi_calibrate.c | 4 +++- comedi_calibrate/save_cal.c | 24 +----------------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/comedi_calibrate/comedi_calibrate.c b/comedi_calibrate/comedi_calibrate.c index ae79c84..26c6bff 100644 --- a/comedi_calibrate/comedi_calibrate.c +++ b/comedi_calibrate/comedi_calibrate.c @@ -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) diff --git a/comedi_calibrate/save_cal.c b/comedi_calibrate/save_cal.c index 1671b7a..ac472d7 100644 --- a/comedi_calibrate/save_cal.c +++ b/comedi_calibrate/save_cal.c @@ -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 ) {