fixed some bad behaviour when using default calibration file path
This commit is contained in:
parent
8a9e9861f1
commit
c3199c93c8
2 changed files with 4 additions and 24 deletions
|
@ -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)
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue