comedi_board_info: improve display of external ranges.
authorIan Abbott <abbotti@mev.co.uk>
Mon, 15 Oct 2012 15:18:47 +0000 (16:18 +0100)
committerIan Abbott <abbotti@mev.co.uk>
Mon, 15 Oct 2012 15:18:47 +0000 (16:18 +0100)
The units for a range with internal unit code `RF_EXTERNAL | UNIT_volt` is currently
displayed as " (unknown unit 256)", for example an external bipolar
voltage range -1 to 1 is displayed as:

[-1 (unknown unit 256),1 (unknown unit 256)]

Change it to be displayed as:

[-1*EXT V,1*EXT V]

comedi_board_info/comedi_board_info.c

index 26c5426882d51421e7aa54044fc713c34d1b3dd2..ef058f1cf19cff21d8d59f48ab541bea03ad3c71 100644 (file)
@@ -78,11 +78,15 @@ void explain_subdevice_flags(char* padding,unsigned int sf) {
 }
 
 void unit_to_desc(char *udesc,int unit) {
-       switch(unit) {
-       case UNIT_volt: strcpy(udesc," V"); break;
-       case UNIT_mA: strcpy(udesc," mA"); break;
-       case UNIT_none: strcpy(udesc,""); break; 
-       default: sprintf(udesc," (unknown unit %d)",
+       if ((unit & RF_EXTERNAL) != 0)
+               strcpy(udesc, "*EXT");
+       else
+               udesc[0] = '\0';
+       switch(RF_UNIT(unit)) {
+       case UNIT_volt: strcat(udesc," V"); break;
+       case UNIT_mA: strcat(udesc," mA"); break;
+       case UNIT_none: strcat(udesc,""); break; 
+       default: sprintf(udesc + strlen(udesc)," (unknown unit %d)",
                         unit);
        }
 }