mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-06 15:51:34 +00:00
sensors: json: Fix print of sensors without values
When the sensor does not provide a value something bogus is printed, print a NaN instead. Also update the output counting to also print a comman for NaNs.
This commit is contained in:
1 parent
6fa5cba2e3
commit
b4ab3652af
1 file changed
+5
-6
@@ -97,7 +97,7 @@ void print_chip_json(const sensors_chip_name *name)
|
||||
"%s!\n", feature->name);
|
||||
continue;
|
||||
}
|
||||
if (cnt > 0)
|
||||
if (cnt++)
|
||||
printf(",\n");
|
||||
printf(" \"%s\":{\n", label);
|
||||
|
||||
@@ -114,22 +114,21 @@ void print_chip_json(const sensors_chip_name *name)
|
||||
sub->name,
|
||||
sensors_strerror(err));
|
||||
} else {
|
||||
if (subCnt > 0)
|
||||
if (subCnt++)
|
||||
printf(",\n");
|
||||
if (is_temp && fahrenheit)
|
||||
val = deg_ctof(val);
|
||||
printf(" \"%s\": %.3f", sub->name, val);
|
||||
subCnt++;
|
||||
}
|
||||
|
||||
} else {
|
||||
printf("(%s)", label);
|
||||
subCnt++;
|
||||
if (subCnt++)
|
||||
printf(",\n");
|
||||
printf(" \"%s\": NaN", sub->name);
|
||||
}
|
||||
}
|
||||
free(label);
|
||||
printf("\n }");
|
||||
cnt++;
|
||||
}
|
||||
if (cnt > 0)
|
||||
printf("\n");
|
||||
|
||||
Reference in new issue
Block a user