tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Pressure sensors



Hi,

i'd like to have the functionality given by the diff below, before
cleaning up another diff making use of it.

with "# envstat -Td bmx280temp0 -i 1" i get output like:

               Current      Max      Min      Avg   Unit
	       temperature:    25.070   25.070   25.060   25.067    degC
	          pressure:   100.860  100.867  100.856  100.861     kPa

and with "# envstat -d bmx280temp0":

               Current  CritMax  WarnMax  WarnMin  CritMin  Unit
	       temperature:    25.080                                      degC
	          pressure:   100.865                                       kPa

my sensor does fill ->value_cur with mPa, so pressure does fit into the
"everything else"-else{} with ->cur_value / 1000000.0 for printout in kPa.

did i miss anything?

-Artturi


diff --git a/sys/dev/sysmon/sysmon_envsys_tables.c b/sys/dev/sysmon/sysmon_envsys_tables.c
index 75fed669892a..ceec07b8e93a 100644
--- a/sys/dev/sysmon/sysmon_envsys_tables.c
+++ b/sys/dev/sysmon/sysmon_envsys_tables.c
@@ -53,6 +53,7 @@ static const struct sme_descr_entry sme_units_description[] = {
 	{ ENVSYS_BATTERY_CHARGE, -1,			"Battery charge" },
 	{ ENVSYS_SRELHUMIDITY,	-1,			"relative Humidity" },
 	{ ENVSYS_LUX,		-1,			"Illuminance" },
+	{ ENVSYS_SPRESSURE,	-1,			"Pressure" },
 	{ -1,			-1,			"unknown" }
 };
 
diff --git a/sys/sys/envsys.h b/sys/sys/envsys.h
index b3f2e7662b2b..2bd8df824990 100644
--- a/sys/sys/envsys.h
+++ b/sys/sys/envsys.h
@@ -65,6 +65,7 @@ enum envsys_units {
 	ENVSYS_BATTERY_CHARGE,		/* Battery charging/discharging */
 	ENVSYS_SRELHUMIDITY,		/* relative humidity */
 	ENVSYS_LUX,			/* illuminance in lux */
+	ENVSYS_SPRESSURE,		/* Pressure in mPa */
 	ENVSYS_NSENSORS
 };
 
@@ -163,7 +164,7 @@ typedef struct envsys_tre_data envsys_tre_data_t;
 #ifdef ENVSYSUNITNAMES
 static const char * const envsysunitnames[] = {
     "degC", "RPM", "VAC", "V", "Ohms", "W",
-    "A", "Wh", "Ah", "bool", "integer", "drive", "%rH", "lux", "Unk"
+    "A", "Wh", "Ah", "bool", "integer", "drive", "%rH", "lux", "kPa", "Unk"
 };
 static const char * const envsysdrivestatus[] = {
     "unknown", "empty", "ready", "powering up", "online", "idle", "active",
diff --git a/usr.sbin/envstat/envstat.8 b/usr.sbin/envstat/envstat.8
index b6f5f402ef0a..e023969153eb 100644
--- a/usr.sbin/envstat/envstat.8
+++ b/usr.sbin/envstat/envstat.8
@@ -168,6 +168,8 @@ Watts
 Watt-hours
 .It %rH
 relative Humidity
+.It kPa
+Pressure in kilopascals
 .El
 .Sh EXAMPLES
 To display the
diff --git a/usr.sbin/envstat/envstat.c b/usr.sbin/envstat/envstat.c
index f5a7422917b0..8d33fcc8304f 100644
--- a/usr.sbin/envstat/envstat.c
+++ b/usr.sbin/envstat/envstat.c
@@ -1023,6 +1023,8 @@ do {									\
 				stype = "Ah";
 			else if (strcmp(sensor->type, "relative Humidity") == 0)
 				stype = "%rH";
+			else if (strcmp(sensor->type, "Pressure") == 0)
+				stype = "kPa";
 			else
 				stype = "?";
 



Home | Main Index | Thread Index | Old Index