sensors fun..

Julian Elischer julian at elischer.org
Wed Oct 17 18:20:11 PDT 2007


Poul-Henning Kamp wrote:
> In message <47167145.70705 at elischer.org>, Julian Elischer writes:
>> Poul-Henning Kamp wrote:
>>> In message <47166BA5.1000100 at elischer.org>, Julian Elischer writes:
>>>
>>>>> Having a userland 
>>>>> interface also makes it easier to have backends that are entirely in 
>>>>> userland.
>>>>>
>>>> maybe a loopback filesystem
>>> Just what is it that is so enticing about the kernel ?  Why not simply
>>> pass it to a daemon ?
>> Becuause you can not open and do a directory listing on a process but you can 
>> on something that is presented as a file system.
> 
> But in userland you can do things so much more comprehensively with
> so much more accesible tools.
> 
> We don't browse webpages by saying
> 
> 	cat < /net/tcp/http/www.cnn.com
> 
> And we shouldn't implement our sensor/alert system that way either.
> 
> 
> I know this, because I have spent the last couple of years essentially
> implementing access to all sorts of "sensors" and "actuators".
> 
> The end goal is to make all sorts of stuff, from oddball navigation
> transmitters with RS-232 ports over dry relay contacts to natural
> gas furnaces manageable with a web-browser and SNMP.
> 
> 
> I'm not advocating that my "measured" (http://phk.freebsd.dk/phkrel)
> be imported into FreeBSD, and I don't see it as a competitor to the
> sensors stuff from OpenBSD.
> 
> But I will show a bit about it anyway, so that you can see you why
> I _know_ that whatever we do decide to do, it must live in userland:
> 
> 
>>> 	critter phk> telnet fs 2040
> 	Trying 192.168.60.20...
> 	Connected to fs.freebsd.dk.
> 	Escape character is '^]'.
>>> 	GET /master HTTP/1.1
> 
> 	HTTP/1.1 200 OK
> 	Content-Type: text/html; charset=iso-8859-1
> 	Cache-control: no-cache; no-store;
> 	Pragma: no-cache
> 
>>> 	PATTERN 11.2.1-2   
>>> 	EVENTS
> 	E 011.002.001 P NEW ain
> 	E 011.002.001 P LABEL V12
> 	E 011.002.001 P FORMAT %.3f
> 	E 011.002.001 P UNIT Volt
> 	E 011.002.001 P LOW 11.4
> 	E 011.002.001 P SAG 11.6
> 	E 011.002.001 P TIMEOUT 16
> 	E 011.002.002 P NEW ain
> 	E 011.002.002 P LABEL A12
> 	E 011.002.002 P FORMAT %.3f
> 	E 011.002.002 P UNIT Ampere
> 	E 011.002.002 P RAISE 3.8
> 	E 011.002.002 P HIGH 4
> 	E 011.002.002 P TIMEOUT 16
> 	E 011.002.001 P VALUE 13.501 1192653549.789175094
> 	E 011.002.001 P LIMIT normal 0 0
> 	E 011.002.002 P VALUE 2.893 1192653548.568108390
> 	E 011.002.002 P LIMIT normal 0 0
> 	E 011.002.002 P VALUE 2.891 1192653549.790052019
> 	E 011.002.001 P VALUE 13.485 1192653551.011067241
> 	E 011.002.002 P VALUE 2.899 1192653551.011921611
> 	E 011.002.001 P VALUE 13.468 1192653552.231962722
> 	E 011.002.002 P VALUE 2.903 1192653552.232819425
> 	E 011.002.001 P VALUE 13.507 1192653553.454879387
> 	E 011.002.002 P VALUE 2.876 1192653553.455751091
> 	E 011.002.001 P VALUE 13.478 1192653554.676769905
> 	E 011.002.002 P VALUE 2.902 1192653554.677682053
> 	...
> 
> As you can guess from the first couple of lines, measured will also
> answer as a HTTP server, so you can just point your browser at it,
> and see what all the sensors record or manipulate actuators.
> 
> The protocol you see above, is trivally implemented in any language.
> 
> Creating a graphical "control panel" for stuff in for instance Tk
> is trival.
> 

actually I did almost EXACTLY that for Vicor, with tcl/tk and 
mbmon which can do something similar to what you showed above. 
Every machine had mbmon listening on port XXX and tcl/tk scanned 
them all and showed them 64 machines to the page.

When any parameter on any machine went out of bounds, that machine's 
button turned red and if you clicked on it you got all the values.. etc.etc.

> I also have an SNMP agent that talks this protocol.
> 
> But the _really_ important thing about measured, is that integrating
> new "stuff" is a small matter of programming.

I agree. The aim of a framework is to make it easy to add support for new
modules, without having to redo everything else. (e.g. netgraph, but that had to be
in the kernel for BSD. You might have been able to do it in userland for MACH
I think.).

> 
>   A 3-axis magnetometer with a RS232 interface:  121 lines of code.
>   Soekris NET4801 enviromental sensors: 195 lines.
>   A VOR transmitter with a particular nasty RS232 protocol: 542 lines.
>   TCP protocol to a radiolink alert proxy: 557 lines.
> 
> And sensors can be implemented in separate processes and even on
> other machines.

On the other hand some sensors may be best reachable from the kernel
(e.g. being integrated with some other device).
so an approach that allows both would be the best.




More information about the freebsd-arch mailing list