From 5c505d7b573965348cd47a6b7f365fbed30791c7 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sun, 20 Jul 2003 03:20:50 +0000 Subject: [PATCH] don't save multiple values for the same caldac channel --- comedi_calibrate/save_cal.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 ) -- 2.26.2