RFC: HCS-L

Discussions regarding the HCS Home Control System

RFC: HCS-L

Postby ncherry » Sun Aug 20, 2006 11:53 am

Introduction

The HCS-L (Home Control System - Linux based) is an expandable, network based (IP, RS485, Onewire, etc.), supervisory control system (central processor controlled distributed processing). The HCS-L incorporates direct and remote digital IO, analog IO, near real-time boolean decision event triggering, PLC communications (such as X10, Insteon and/or UPB), remote displays, telephone line interface and text-to-speech functions.

The HCS-L system architecture consists of a central supervisory controller, the HCS-L (or SC), connected up to other functional modules (called comm-links) via a network.

Requirements:
  • Single Board Computer
  • Single purpose network appliance
  • Low power
  • No moving parts to fail
  • flash file system (SD, Compact Flash, etc).
  • Hardware watchdog
  • minimal visual indicators
  • No direct video necessary
  • Accessible via RS232 (Console), telnet/SSH and HTTP (IP network)
  • Comm-link support for 9.6 baud via an RS485, half duplex communication
  • Full IP network (IPV4 and/or IPv6) - this includes DHCP client, name resolution, etc.
  • Dynamic load support for XPRESS
  • API for software development
  • (opt) Ability to have soft comm-links (network daemons to interface to USB attached X10 controllers, for instance)
  • (opt) IP networked comm-links
Those who want to use a PC running Linux instead of a SBC can but there is no intention of designing applications that require the huge resources that a full PC can supply. There is no intention to run a mail server or Asterisk PBX on the HCS-L. It's sole purpose is Home Automation.

The user interfaces to the HCS-L will be like that of a modern day firewall/router. There will be support for telnet, ftp, sftp, SSH, HTTP, SNMP (?) and network daemon support. SNMP is currently a question as it may require a large amount of resources to implement. Those daemons not required can be disabled. In addition support for port/IP blocking will be provided by iptables.

Because this is Linux rebooting will not be necessary unless the kernel has been modified. Linux already supports dynamic device drivers and applications can be stopped and restarted as needed. Support for automatic start-up of applications is provided.

Currently there should be no need to place limits on the number of digital, analog or other devices supported by XPRESS. I think I'd like to call it XPRESS32. It will be an interpreter for the XPRESS code. Initially it will support the current XPRESS code. Additional features will be needed to support multiple serial ports, software comm-links, remote serial comm-links and IP comm-links. Also I want to see an API to what's running under XPRESS so that outside programs can access the information from the HTTP daemon (maybe for an AJAX Host application). Even applications outside the HCS-L.

Initially I'd like to see an HCS-L (fully functional with Linux) talk to one of the current comm-links, then two comm-links, then bring up XPRESS and run some simple XPRESS code to communicate to those comm-links. Once that goal has been reached the next step will be decided.

For those not familiar with network daemons, think of it as being like telnet or directl accesing a serial port to communicate with a modem. The code is simple to write and you can use ASCII to communicate so you can test by using telnet and manually typing the commands.
Linux Home Automation
http://www.linuxha.com/
http://hcs.sourceforge.net/
Author; Linux Smart Homes For Dummies
ncherry
 
Posts: 182
Joined: Fri Sep 12, 2003 10:08 am
Location: NJ

Postby ncherry » Thu Aug 31, 2006 9:20 am

The TS7200 has arrived, the one I ordered has a real time clock, temperature chip, 1 - RS232, 1 - RS485 half duplex/RS232 port, 16M Flash, 32M RAM and a CF socket. Total cost $236 (w/S+H). It already has Redboot and Linux loaded. It can load an OS from Flash or over the Ethernet (a net boot). I have found ECOS on the web site (Technologic Systems) so I may be able to work with that if I can net boot it (to experiment with). My initial work will be with Linux built with uclib (no MMU, which means no swap). The net boot is not for production. It's a means of testing an OS (and Apps) without burning it to flash. The HCS-L is meant to be stand alone like the HCS II. So far I haven't started the board up. More to follow.
Linux Home Automation
http://www.linuxha.com/
http://hcs.sourceforge.net/
Author; Linux Smart Homes For Dummies
ncherry
 
Posts: 182
Joined: Fri Sep 12, 2003 10:08 am
Location: NJ

Postby ncherry » Fri Sep 01, 2006 1:47 pm

I now have the ARM board up and running with Linux. In it's default state it looks pretty good:
Code: Select all
$ uname -a
Linux ts7200 2.4.26-ts11 #215 Thu Jun 8 14:30:17 MST 2006 armv4l unknown
$ free
              total         used         free       shared      buffers
  Mem:        28572         5948        22624            0            0
Swap:            0            0            0
Total:        28572         5948        22624
$ df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                14.0M      4.3M      9.7M  31% /

The above means it's running Linux kernel 2.4.26-ts11 (a custom kernel). It has 32M of ram, ~6M used by applications, 22M free and 4M used by the Linux kernel. The file system (16M of flash) has 4M used by redboot, 4.3 used by the default apps and 9.7M available. That's pretty good. I don't have the CF chip mounted because it doesn't have a file system on it. I'll have to format it later and then mount it. Currently it give the system fits if it's inserted when the system starts up as it tries to boot off the CF.
Here are the running apps:
Code: Select all
$ ps ax
  PID  Uid     VmSize Stat Command
    1 root        468 S   init [3]
    2 root            SW  [keventd]
    3 root            SWN [ksoftirqd_CPU0]
    4 root            SW  [kswapd]
    5 root            SW  [bdflush]
    6 root            SW  [kupdated]
    7 root            SW  [mtdblockd]
    8 root            SWN [jffs2_gcd_mtd1]
   57 1           448 S   /sbin/portmap
   62 root        680 S   /usr/sbin/inetd
   67 root        480 S   /usr/sbin/telnetd
   76 root       1080 S   /www/apache/bin/httpd
   83 root        536 S   /sbin/getty -L 115200 ttyAM1
   84 nobody     1068 S   /www/apache/bin/httpd
   85 nobody     1068 S   /www/apache/bin/httpd
   86 nobody     1068 S   /www/apache/bin/httpd
   87 nobody     1068 S   /www/apache/bin/httpd
   88 nobody     1068 S   /www/apache/bin/httpd
  153 root        572 S   /sbin/udhcpc -H ts7200 -b -i eth0
  168 root        536 S   /sbin/getty -L 115200 ttyAM0
  170 root        684 S   -sh
  172 root        592 R   ps ax
I'll work on getting httpd (Apache) down to 1 process. I doubt we need more than one. Usually 1 process serves about 100 users (I think).
Code: Select all
$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:D0:69:40:52:2E
          inet addr:192.168.24.134  Bcast:192.168.24.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:185 errors:0 dropped:0 overruns:0 frame:0
          TX packets:83 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:39

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

The above network setup is as a DHCP client. I setup my dhcp server/dns box to handle delivering the IP address to the HCS-L. In my network it makes network admin easy to do. The HCS-L can also act as dhcp server. I haven't looked at the startup scripts yet to figure out how to turn that off. It's also quite easy to setup as static IP address for the HCS-L so that's not a problem. The above information was obtained via a telnet session. The console also works and I'll have to figure out how to let XPRESS use the console and a method to allow access via the console so when the network is down you can still access everything. I want the HCS-L to behave like a Cisco router from the command line perspective.

As usual more to follow ...

PS - I forgot the version of busy box that this board is running:
Code: Select all
$ busybox
BusyBox v1.00-rc2 (2004.08.05-21:44+0000) multi-call binary

Usage: busybox [function] [arguments]...
   or: [function] [arguments]...

        BusyBox is a multi-call binary that combines many common Unix
        utilities into a single executable.  Most people will create a
        link to busybox for each function they wish to use, and BusyBox
        will act like whatever it was invoked as.

Currently defined functions:
        . : alias bg break cd chdir continue eval exec exit export false
        fg hash help jobs kill let local pwd read readonly return set
        shift times trap true type ulimit umask unalias unset wait [
        addgroup adduser adjtimex ar ash awk basename bunzip2 busybox
        bzcat cat chgrp chmod chown chroot chvt clear cmp cp crond cut
        date dc dd deallocvt delgroup deluser devfsd df dirname dmesg
        dpkg dpkg-deb du dumpleases echo egrep env expr false fbset fdisk
        fgrep find free ftpget ftpput getty grep gunzip gzip halt hdparm
        head hostid hostname hwclock id ifconfig ifdown ifup inetd insmod
        install kill killall klogd ln logger login logread ls lsmod makedevs
        md5sum mkdir mknod mkswap mktemp modprobe more mount mv openvt
        passwd pidof ping pivot_root poweroff ps pwd reboot reset rm
        rmdir rmmod route sed sh sleep sort start-stop-daemon strings
        su sulogin swapoff swapon sync syslogd tail tar tee telnet telnetd
        test tftp time touch tr traceroute true tty udhcpc udhcpd umount
        uname uncompress uniq unzip uptime usleep vi wc wget which whoami
        xargs yes zcat

It seems to have support for quite a few commands.
Linux Home Automation
http://www.linuxha.com/
http://hcs.sourceforge.net/
Author; Linux Smart Homes For Dummies
ncherry
 
Posts: 182
Joined: Fri Sep 12, 2003 10:08 am
Location: NJ

Postby dyarker » Sat Sep 02, 2006 12:28 am

You should be able to get Apache down to 2 processes; one owned by root ("core" program), the other owned by nobody (the server that network side clients actually "connect" to). Doing it this way prevents everyone on the Internet from having root access to the machine.

Part of my httpd.conf file:
#
# Server-pool size regulation. Rather than making you guess how many
# server processes you need, Apache dynamically adapts to the load it
# sees --- that is, it tries to maintain enough server processes to
# handle the current load, plus a few spare servers to handle transient
# load spikes (e.g., multiple simultaneous requests from a single
# Netscape browser).
#
# It does this by periodically checking how many servers are waiting
# for a request. If there are fewer than MinSpareServers, it creates
# a new spare. If there are more than MaxSpareServers, some of the
# spares die off. The default values are probably OK for most sites.
#
MinSpareServers 3
MaxSpareServers 10

#
# Number of servers to start initially --- should be a reasonable ballpark
# figure.
#
StartServers 4

#
# Limit on total number of servers running, i.e., limit on the number
# of clients who can simultaneously connect --- if this limit is ever
# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW.
# It is intended mainly as a brake to keep a runaway server from taking
# the system with it as it spirals down...
#
MaxClients 150

#
# MaxRequestsPerChild: the number of requests each child process is
# allowed to process before the child dies. The child will exit so
# as to avoid problems after prolonged use when Apache (and maybe the
# libraries it uses) leak memory or other resources. On most systems, this
# isn't really needed, but a few (such as Solaris) do have notable leaks
# in the libraries. For these platforms, set to something like 10000
# or so; a setting of 0 means unlimited.
#
# NOTE: This value does not include keepalive requests after the initial
# request per connection. For example, if a child process handles
# an initial request and 10 subsequent "keptalive" requests, it
# would only count as 1 request towards this limit.
#
MaxRequestsPerChild 10000


For this application try:
MinSpareServers 1
MaxSpareServers 2
StartServers 1
MaxClients 10
MaxRequestsPerChild 100

The "StartServers 1" will give you one process owned by nobody. Maybe "MaxSpareServers" can also be set to 1, setting "MaxClients" to less than 2 is probably a bad idea.

C U L,
Dale
dyarker
 
Posts: 128
Joined: Wed Sep 10, 2003 10:29 pm

Postby ncherry » Sat Sep 02, 2006 1:19 am

Thanks Dale! Here's what I tried (and it seems to work so far):
Code: Select all
#
# Server-pool size regulation.  Rather than making you guess how many
# server processes you need, Apache dynamically adapts to the load it
# sees --- that is, it tries to maintain enough server processes to
# handle the current load, plus a few spare servers to handle transient
# load spikes (e.g., multiple simultaneous requests from a single
# Netscape browser).
#
# It does this by periodically checking how many servers are waiting
# for a request.  If there are fewer than MinSpareServers, it creates
# a new spare.  If there are more than MaxSpareServers, some of the
# spares die off.  The default values are probably OK for most sites.
#
MinSpareServers 0
MaxSpareServers 1

#
# Number of servers to start initially --- should be a reasonable ballpark
# figure.
#
StartServers 1

#
# Limit on total number of servers running, i.e., limit on the number
# of clients who can simultaneously connect --- if this limit is ever
# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW.
# It is intended mainly as a brake to keep a runaway server from taking
# the system with it as it spirals down...
#
MaxClients 150

#
# MaxRequestsPerChild: the number of requests each child process is
# allowed to process before the child dies.  The child will exit so
# as to avoid problems after prolonged use when Apache (and maybe the
# libraries it uses) leak memory or other resources.  On most systems, this
# isn't really needed, but a few (such as Solaris) do have notable leaks
# in the libraries. For these platforms, set to something like 10000
# or so; a setting of 0 means unlimited.
#
# NOTE: This value does not include keepalive requests after the initial
#       request per connection. For example, if a child process handles
#       an initial request and 10 subsequent "keptalive" requests, it
#       would only count as 1 request towards this limit.
#
MaxRequestsPerChild 0

I see the first httpd it's owned by root while the second is owned by nobody. Thanks for pointing that out. I do worry about security.
Linux Home Automation
http://www.linuxha.com/
http://hcs.sourceforge.net/
Author; Linux Smart Homes For Dummies
ncherry
 
Posts: 182
Joined: Fri Sep 12, 2003 10:08 am
Location: NJ

Re: RFC: HCS-L

Postby pcombs1 » Mon Oct 16, 2006 11:26 am

ncherry wrote:Introduction

The HCS-L (Home Control System - Linux based) is an expandable, network based (IP, RS485, Onewire, etc.), supervisory control system (central processor controlled distributed processing). The HCS-L incorporates direct and remote digital IO, analog IO, near real-time boolean decision event triggering, PLC communications (such as X10, Insteon and/or UPB), remote displays, telephone line interface and text-to-speech functions.


Neil--

This sounds like just the thing to replace my faithful (but aged) HCSII. I was a bit concerned on first reading that my add-on speech synth boards and phone interface boards wouldn't work, but I suppose they won't be needed, will they? :)
pcombs1
 
Posts: 13
Joined: Sun Apr 04, 2004 6:26 pm

Postby ncherry » Mon Oct 16, 2006 8:52 pm

Right now I don't know what's going on. I'm just getting over a server and drive crash. I had no HA for 2 weeks (I still haven't restored my Asterisk PBX yet). Diagnosing the exact problem was difficult, it took 2 weeks to finally determine that the problem was with both the drive and the IDE interface. What this taught me is that I really need to move off the main HA of the PC based server. I can still use the PC based server for Mr. House but that the main HA functionality would be moved to a small, low powered, SBC. The way I had my network setup was that the main server (with Mr. House) also had my DNS (I use names not IP addresses in my network), DHCP (all devices except the main server), Samba (SMB file sharing), CUPs (network printing) etc. Way too much on one box. I'll move the HA off that server. I need to figure out how to move the PBX off that server also. I may be able to move it to a Linksys NSLU2. That may not be powerful enough to handle my needs. OK, so that's a lot of babble but not much progress.
Linux Home Automation
http://www.linuxha.com/
http://hcs.sourceforge.net/
Author; Linux Smart Homes For Dummies
ncherry
 
Posts: 182
Joined: Fri Sep 12, 2003 10:08 am
Location: NJ


Return to HCS

Who is online

Users browsing this forum: MSN [Bot] and 1 guest

cron