On Sun, Aug 24, 2008 at 10:16:08PM +0000, Paul Goyette wrote: [...] > I've been tasked with getting sysmon_envsys(9) back under control. I'd > appreciate any specific examples of this "bloat", or suggestions about > what's wrong with, or lacking in, the current implementation. Hopefully, > what I come up with will be more useable without any of the excess > baggage. I've just spent a couple hours writing a driver for a HID report id on a Bluetooth keyboard I have, which exposes its battery charge. One thing is blatantly wrong with the current design of envsys regarding batteries (and probably temperature sensors, too), although it doesn't mean it has to be re-done of course. So here I am with that wireless keyboard exposing a battery sensor; I can't use the SME_CLASS_BATTERY class because sysmon_envsys will consider that sensor to apply to the whole machine. That means we need to introduce one way or another the concept of power management domains. Somehow it has to be tied to the power management framework, too. Another thing that is wrong, but I guess it's just a bug, is that the dictionary is created once, and a bunch of data is happily thrown out if the sensor is initially in the ENVSYS_SINVALID state (which is the case for this driver because all the bluetooth devices attach before the physical devices is actually connected, so my sensor only becomes ENVSYS_SVALID when the device actually starts sending reports). In this case, value_min and value_max are lost even though they're known. I remember Juan having trouble with the idea a sensor could be valid and yet have no value. sysmon_envsys doesn't make it easy to distinguish between "The sensor is fine but has no value" and "There was an issue getting a value from the sensor". One last disappointing thing: I have information about the range of values in which my sensor lives, and I'd like to take advantage of it, but envstat(1) will simply ignore want-percentage and value-max if the type is Integer... Also, the percentage calculation always assume 0 is the minimal value, and therefore happily ignore value-min. Do you want me to fill PRs for all that? -- Quentin Garnier - cube%cubidou.net@localhost - cube%NetBSD.org@localhost "See the look on my face from staying too long in one place [...] every time the morning breaks I know I'm closer to falling" KT Tunstall, Saving My Face, Drastic Fantastic, 2007.
Description: PGP signature