summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2006-09-16 10:46:27 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2006-09-16 10:46:27 +0000
commitef2aa9643016734172847ee2ed95b440994ac64d (patch)
tree84034b3344ea3a1e295b1b8a693aa87c9e56301f /usr.sbin
parent6cd150bc8594fceadd0998082cc4f68e79637f89 (diff)
sync printing w/ sysctl and also add missing sensor types to the conf parser; deraadt@ ok
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/sensorsd/sensorsd.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c
index af7649a0699..ac4dc0d5e5f 100644
--- a/usr.sbin/sensorsd/sensorsd.c
+++ b/usr.sbin/sensorsd/sensorsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sensorsd.c,v 1.23 2006/08/23 11:18:00 mickey Exp $ */
+/* $OpenBSD: sensorsd.c,v 1.24 2006/09/16 10:46:26 mickey Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -317,18 +317,29 @@ print_sensor(enum sensor_type type, int64_t value)
switch (type) {
case SENSOR_TEMP:
- snprintf(fbuf, RFBUFSIZ, "%.2fC/%.2fF",
- (value - 273150000) / 1000000.0,
- (value - 273150000) / 1000000.0 * 9 / 5 + 32);
+ snprintf(fbuf, RFBUFSIZ, "%.2f degC",
+ (value - 273150000) / 1000000.0);
break;
case SENSOR_FANRPM:
snprintf(fbuf, RFBUFSIZ, "%lld RPM", value);
break;
case SENSOR_VOLTS_DC:
- snprintf(fbuf, RFBUFSIZ, "%.2fV", value / 1000.0 / 1000.0);
+ snprintf(fbuf, RFBUFSIZ, "%.2f V DC", value / 1000000.0);
+ break;
+ case SENSOR_AMPS:
+ snprintf(fbuf, RFBUFSIZ, "%.2f A", value / 1000000.0);
+ break;
+ case SENSOR_INDICATOR:
+ snprintf(fbuf, RFBUFSIZ, "%s", value? "On" : "Off");
break;
case SENSOR_INTEGER:
- snprintf(fbuf, RFBUFSIZ, "%lld", value);
+ snprintf(fbuf, RFBUFSIZ, "%lld raw", value);
+ break;
+ case SENSOR_PERCENT:
+ snprintf(fbuf, RFBUFSIZ, "%.2f%%", value / 1000.0);
+ break;
+ case SENSOR_LUX:
+ snprintf(fbuf, RFBUFSIZ, "%.2f lx", value / 1000000.0);
break;
case SENSOR_DRIVE:
if (0 < value && value < sizeof(drvstat)/sizeof(drvstat[0])) {
@@ -424,9 +435,17 @@ get_val(char *buf, int upper, enum sensor_type type)
errx(1, "unknown unit %s for voltage sensor", p);
rval = val * 1000 * 1000;
break;
+ case SENSOR_PERCENT:
+ rval = val * 1000.0;
+ break;
+ case SENSOR_INDICATOR:
case SENSOR_INTEGER:
+ case SENSOR_DRIVE:
rval = val;
break;
+ case SENSOR_LUX:
+ rval = val * 1000 * 1000;
+ break;
default:
errx(1, "unsupported sensor type");
/* not reached */