Fixed strange unreproducible behavior with insn barfing. Turns out
authorDavid Schleef <ds@schleef.org>
Tue, 22 Jan 2002 09:32:28 +0000 (09:32 +0000)
committerDavid Schleef <ds@schleef.org>
Tue, 22 Jan 2002 09:32:28 +0000 (09:32 +0000)
that -5 is not really equal to -5.

comedi_calibrate/comedi_calibrate.c

index a2a4357c436934ff5ff88e03a33b3e20f205f14f..384983a62ec5bd265a73b732f7125fea4c453580 100644 (file)
@@ -651,7 +651,8 @@ int get_bipolar_lowgain(comedi_t *dev,int subdev)
 
        for(i=0;i<n_ranges;i++){
                range = comedi_get_range(dev,subdev,0,i);
-               if(range->min != -range->max)continue;
+               /* This method is better than a direct test, which might fail */
+               if((range->min+range->max)>(range->max*0.0001))continue;
                if(range->max>max){
                        ret = i;
                        max=range->max;
@@ -671,7 +672,8 @@ int get_bipolar_highgain(comedi_t *dev,int subdev)
 
        for(i=0;i<n_ranges;i++){
                range = comedi_get_range(dev,subdev,0,i);
-               if(range->min != -range->max)continue;
+               /* This method is better than a direct test, which might fail */
+               if((range->min+range->max)>(range->max*0.0001))continue;
                if(range->max<min){
                        ret = i;
                        min=range->max;
@@ -796,6 +798,8 @@ int comedi_data_read_n(comedi_t *it,unsigned int subdev,unsigned int chan,
        printf("insn barfed: subdev=%d, chan=%d, range=%d, aref=%d, "
                "n=%d, ret=%d, %s\n",subdev,chan,range,aref,n,ret,
                strerror(errno));
+       printf("please report this error\n");
+       exit(1);
 
        return ret;
 }