Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Oct 2007 20:59:29 +0000
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Julian Elischer <julian@elischer.org>
Cc:        arch@freebsd.org, "Constantine A. Murenin" <cnst@freebsd.org>
Subject:   Re: sensors fun.. 
Message-ID:  <52434.1192654769@critter.freebsd.dk>
In-Reply-To: Your message of "Wed, 17 Oct 2007 13:32:05 MST." <47167145.70705@elischer.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <47167145.70705@elischer.org>, Julian Elischer writes:
>Poul-Henning Kamp wrote:
>> In message <47166BA5.1000100@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.

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.

  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.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?52434.1192654769>