From: Frank Mori Hess Date: Sun, 20 Jul 2003 03:20:50 +0000 (+0000) Subject: don't save multiple values for the same caldac channel X-Git-Tag: r0_7_21~33 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5c505d7b573965348cd47a6b7f365fbed30791c7;p=comedilib.git don't save multiple values for the same caldac channel --- diff --git a/comedi_calibrate/save_cal.c b/comedi_calibrate/save_cal.c index 521f0a3..60ee087 100644 --- a/comedi_calibrate/save_cal.c +++ b/comedi_calibrate/save_cal.c @@ -157,6 +157,20 @@ comedi_calibration_setting_t* sc_alloc_calibration_setting( calibration_setup_t void sc_push_caldac( comedi_calibration_setting_t *saved_cal, caldac_t caldac ) { + int i; + + /* check if caldac is already listed, in which case we just update */ + for( i = 0; i < saved_cal->num_caldacs; i++ ) + { + if( saved_cal->caldacs[ i ].subdevice != caldac.subdev ) continue; + if( saved_cal->caldacs[ i ].channel != caldac.chan ) continue; + break; + } + if( i < saved_cal->num_caldacs ) + { + saved_cal->caldacs[ i ].value = caldac.current; + return; + } saved_cal->caldacs = realloc( saved_cal->caldacs, ( saved_cal->num_caldacs + 1 ) * sizeof( caldac_t ) ); if( saved_cal->caldacs == NULL )