Subject: Re: envstat -s sensor -d device
To: Juan RP <juan@xtrarom.org>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-userlevel
Date: 09/24/2007 22:05:32
On Mon, 24 Sep 2007, Juan RP wrote:
> $ ./envstat -I
> [aiboost0]
> CPU Temperature: 35.000 degC max: 70.000 degC min: 15.000 degC
> MB Temperature: 40.000 degC max: 50.000 degC min: 15.000 degC
> Vcore Voltage: 1.264 V max: 1.350 V min: 1.150 V
> +3.3 Voltage: 3.264 V max: 3.500 V min: 3.000 V
> +5 Voltage: 4.992 V max: 5.600 V min: 4.500 V
> +12 Voltage: 11.985 V max: 13.500 V min: 11.200 V
> CPU FAN Speed: 1268 RPM
> Is this ok for you?
seems good to me.
how much trouble is it likely to cause if the acpi* devices were to follow
this scheme and no longer include the device name in the sensor
description as below?
iain
--- /usr/src/sys/dev/acpi/acpi_acad.c 2007-07-20 22:20:53.000000000 +0100
+++ acpi_acad.c 2007-09-24 21:51:09.000000000 +0100
@@ -274,8 +274,7 @@
sc->sc_data[0].sensor = 0;
sc->sc_data[0].state = ENVSYS_SVALID;
sc->sc_data[0].units = ENVSYS_INDICATOR;
- snprintf(sc->sc_data[0].desc, sizeof(sc->sc_data->desc),
- "%s %s", sc->sc_dev.dv_xname, "connected");
+ strlcpy(sc->sc_data[0].desc, "connected", sizeof(sc->sc_data[0].desc));
sc->sc_sysmon.sme_sensor_data = sc->sc_data;
sc->sc_sysmon.sme_name = sc->sc_dev.dv_xname;
--- /usr/src/sys/dev/acpi/acpi_apm.c 2007-07-20 22:20:53.000000000 +0100
+++ acpi_apm.c 2007-09-24 21:48:26.000000000 +0100
@@ -318,31 +318,31 @@
DPRINTF(("%d %s %d %d\n", i, desc, data, flags));
if ((flags & ENVSYS_FCURVALID) == 0)
continue;
- if (strstr(desc, " connected")) {
+ if (strcmp(desc, "connected") == 0) {
pinfo->ac_state = data ? APM_AC_ON : APM_AC_OFF;
- } else if (strstr(desc, " present") && data == 0)
+ } else if (strcmp(desc, "present") == 0 && data == 0)
pinfo->battery_flags |= APM_BATT_FLAG_NO_SYSTEM_BATTERY;
- else if (strstr(desc, " charging") && data)
+ else if (strcmp(desc, "charging") == 0 && data)
pinfo->battery_flags |= APM_BATT_FLAG_CHARGING;
- else if (strstr(desc, " charging") && !data)
+ else if (strcmp(desc, "charging") == 0 && !data)
pinfo->battery_flags &= ~APM_BATT_FLAG_CHARGING;
- else if (strstr(desc, " warn cap"))
+ else if (strcmp(desc, "warn cap") == 0)
warncap = data / 1000;
- else if (strstr(desc, " low cap"))
+ else if (strcmp(desc, "low cap") == 0)
lowcap = data / 1000;
- else if (strstr(desc, " last full cap")) {
+ else if (strcmp(desc, "last full cap") == 0) {
lastcap += data / 1000;
lastcap_valid = 1;
}
- else if (strstr(desc, " design cap"))
+ else if (strcmp(desc, "design cap") == 0)
descap = data / 1000;
- else if (strstr(desc, " charge") &&
- strstr(desc, " charge rate") == NULL) {
+ else if (strcmp(desc, "charge") == 0 &&
+ strcmp(desc, "charge rate")) {
cap += data / 1000;
cap_valid = 1;
pinfo->nbattery++;
}
- else if (strstr(desc, " discharge rate")) {
+ else if (strcmp(desc, "discharge rate") == 0) {
discharge += data / 1000;
discharge_valid = 1;
}
--- /usr/src/sys/dev/acpi/acpi_bat.c 2007-09-05 22:23:26.000000000 +0100
+++ acpi_bat.c 2007-09-24 21:49:53.000000000 +0100
@@ -684,8 +684,8 @@
sc->sc_data[index].sensor = index; \
sc->sc_data[index].units = unit; \
sc->sc_data[index].state = ENVSYS_SVALID; \
- snprintf(sc->sc_data[index].desc, sizeof(sc->sc_data->desc), \
- "%s %s", sc->sc_dev.dv_xname, string); \
+ strlcpy(sc->sc_data[index].desc, string, \
+ sizeof(sc->sc_data[index].desc));
INITDATA(ACPIBAT_PRESENT, ENVSYS_INDICATOR, "present");
INITDATA(ACPIBAT_DCAPACITY, capunit, "design cap");
--- /usr/src/sys/dev/acpi/acpi_tz.c 2007-07-20 22:20:57.000000000 +0100
+++ acpi_tz.c 2007-09-24 21:41:33.000000000 +0100
@@ -590,8 +590,8 @@
}
#define INITDATA(index, unit, string) \
sc->sc_data[index].units = unit; \
- snprintf(sc->sc_data[index].desc, sizeof(sc->sc_data[index].desc), \
- "%s %s", sc->sc_dev.dv_xname, string);
+ strlcpy(sc->sc_data[index].desc, string, \
+ sizeof(sc->sc_data[index].desc));
INITDATA(ATZ_SENSOR_TEMP, ENVSYS_STEMP, "temperature");