Module Name: src Committed By: thorpej Date: Sun May 27 01:39:00 UTC 2018
Modified Files: src/sys/dev/sysmon: sysmon_envsys_tables.c src/sys/sys: envsys.h src/usr.sbin/envstat: envstat.c Log Message: Add support for light sensors that report Illuminance in lux. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/sysmon/sysmon_envsys_tables.c cvs rdiff -u -r1.36 -r1.37 src/sys/sys/envsys.h cvs rdiff -u -r1.95 -r1.96 src/usr.sbin/envstat/envstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/sysmon/sysmon_envsys_tables.c diff -u src/sys/dev/sysmon/sysmon_envsys_tables.c:1.12 src/sys/dev/sysmon/sysmon_envsys_tables.c:1.13 --- src/sys/dev/sysmon/sysmon_envsys_tables.c:1.12 Sun May 18 11:46:23 2014 +++ src/sys/dev/sysmon/sysmon_envsys_tables.c Sun May 27 01:39:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: sysmon_envsys_tables.c,v 1.12 2014/05/18 11:46:23 kardel Exp $ */ +/* $NetBSD: sysmon_envsys_tables.c,v 1.13 2018/05/27 01:39:00 thorpej Exp $ */ /*- * Copyright (c) 2007 Juan Romero Pardines. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_tables.c,v 1.12 2014/05/18 11:46:23 kardel Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_tables.c,v 1.13 2018/05/27 01:39:00 thorpej Exp $"); #include <sys/types.h> @@ -52,6 +52,7 @@ static const struct sme_descr_entry sme_ { ENVSYS_BATTERY_CAPACITY, PENVSYS_TYPE_BATTERY,"Battery capacity" }, { ENVSYS_BATTERY_CHARGE, -1, "Battery charge" }, { ENVSYS_SRELHUMIDITY, -1, "relative Humidity" }, + { ENVSYS_LUX, -1, "Illuminance" }, { -1, -1, "unknown" } }; Index: src/sys/sys/envsys.h diff -u src/sys/sys/envsys.h:1.36 src/sys/sys/envsys.h:1.37 --- src/sys/sys/envsys.h:1.36 Sat Jan 23 01:26:14 2016 +++ src/sys/sys/envsys.h Sun May 27 01:39:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: envsys.h,v 1.36 2016/01/23 01:26:14 dholland Exp $ */ +/* $NetBSD: envsys.h,v 1.37 2018/05/27 01:39:00 thorpej Exp $ */ /*- * Copyright (c) 1999, 2007, 2014 The NetBSD Foundation, Inc. @@ -64,6 +64,7 @@ enum envsys_units { ENVSYS_BATTERY_CAPACITY, /* Battery capacity */ ENVSYS_BATTERY_CHARGE, /* Battery charging/discharging */ ENVSYS_SRELHUMIDITY, /* relative humidity */ + ENVSYS_LUX, /* illumanice in lux */ ENVSYS_NSENSORS }; @@ -162,7 +163,7 @@ typedef struct envsys_tre_data envsys_tr #ifdef ENVSYSUNITNAMES static const char * const envsysunitnames[] = { "degC", "RPM", "VAC", "V", "Ohms", "W", - "A", "Wh", "Ah", "bool", "integer", "drive", "%rH", "Unk" + "A", "Wh", "Ah", "bool", "integer", "drive", "%rH", "lux", "Unk" }; static const char * const envsysdrivestatus[] = { "unknown", "empty", "ready", "powering up", "online", "idle", "active", Index: src/usr.sbin/envstat/envstat.c diff -u src/usr.sbin/envstat/envstat.c:1.95 src/usr.sbin/envstat/envstat.c:1.96 --- src/usr.sbin/envstat/envstat.c:1.95 Sun May 18 11:46:24 2014 +++ src/usr.sbin/envstat/envstat.c Sun May 27 01:39:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: envstat.c,v 1.95 2014/05/18 11:46:24 kardel Exp $ */ +/* $NetBSD: envstat.c,v 1.96 2018/05/27 01:39:00 thorpej Exp $ */ /*- * Copyright (c) 2007, 2008 Juan Romero Pardines. @@ -27,7 +27,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: envstat.c,v 1.95 2014/05/18 11:46:24 kardel Exp $"); +__RCSID("$NetBSD: envstat.c,v 1.96 2018/05/27 01:39:00 thorpej Exp $"); #endif /* not lint */ #include <stdio.h> @@ -959,6 +959,52 @@ do { \ (void)printf(":%10s", sensor->battcap); + /* Illuminance */ + } else if (strcmp(sensor->type, "Illuminance") == 0) { + + stype = "lux"; + + (void)printf(":%10u ", sensor->cur_value); + + ilen = 8; + if (statistics) { + /* show statistics if flag set */ + (void)printf("%8u %8u %8u ", + stats->max, stats->min, stats->avg); + ilen += 2; + } else { + if (sensor->critmax_value) { + (void)printf("%*u ", (int)ilen, + sensor->critmax_value); + ilen = 8; + } else + ilen += 9; + + if (sensor->warnmax_value) { + (void)printf("%*u ", (int)ilen, + sensor->warnmax_value); + ilen = 8; + } else + ilen += 9; + + if (sensor->warnmin_value) { + (void)printf("%*u ", (int)ilen, + sensor->warnmin_value); + ilen = 8; + } else + ilen += 9; + + if (sensor->critmin_value) { + (void)printf( "%*u ", (int)ilen, + sensor->critmin_value); + ilen = 8; + } else + ilen += 9; + + } + + (void)printf("%*s", (int)ilen - 3, stype); + /* everything else */ } else { if (strcmp(sensor->type, "Voltage DC") == 0)