Capturing WebBrick UDP events

Capturing WebBrick UDP events
Originally Posted on Saturday, March 19 @ GMT Standard Time
Its been a busy busy first six months for O2M8, I'm off for a short break so John will be looking after the site for a while. Just before I go, here's a hopefully useful article.
Whilst putting together the demos for the SmartHome show, I brushed up a program I've been using for a couple of years to track the UDP packets generated by WebBricks under various conditions.

UDP event logging

WebBricks generate different types of UDP packets for different reasons. The most common are:

  • Digital Input triggers
  • Temperature Alarms
  • Analogue Alarms
  • Digital Input Alarms

    Its quite useful to have a simple history of these events to see whats going on in a Network of WebBricks.

    You'll find in the downloads section a zip file of the program and XSL style sheet described here.

    myhttpd.py

    This program has several threads running:

  • HTTPD server on port 8081, chosen to keep out of the way of standard HTTP and Tomcat
  • UDP receiving thread
  • Temperature logging thread --- more of this in a article to come

    Basically this program has to be started in the background, the simplest way to do this is using a nohupcommand:

    nohup python myhttpd.py &

    The ampersand at the end of the command ensures you get the command prompt back!

    The myhttpd.py daemon will serve XML formatted versions of events e.g:

    <?xml version="1.0" encoding="iso-8859-1" ?>
    <?xml-stylesheet type="text/xsl" href="/UDP.xsl" mce_href="/UDP.xsl" ?> <UDPList> <event><no>7</no><time>19 Mar 2005 21:47:33</time><address>10.0.0.28</address><data>Digital Trigger, Node: 28 chn: 1 Operand: Triggered</data></event> <event><no>6</no><time>19 Mar 2005 21:47:31</time><address>10.0.0.28</address><data>Digital Trigger, Node: 28 chn: 7 Operand: Triggered</data></event> <event><no>5</no><time>19 Mar 2005 21:47:18</time><address>10.0.0.28</address><data>Digital Trigger, Node: 28 chn: 1 Operand: Triggered</data></event> <event><no>4</no><time>19 Mar 2005 21:47:14</time><address>10.0.0.28</address><data>Digital Trigger, Node: 28 chn: 2 Operand: Triggered</data></event> <event><no>3</no><time>19 Mar 2005 21:47:04</time><address>10.0.0.28</address><data>Digital Trigger, Node: 28 chn: 5 Operand: Triggered</data></event> <event><no>2</no><time>19 Mar 2005 21:47:02</time><address>10.0.0.28</address><data>Digital Trigger, Node: 28 chn: 5 Operand: Triggered</data></event> <event><no>1</no><time>19 Mar 2005 21:45:34</time><address>10.0.0.19</address><data>Digital Trigger, Node: 0 chn: 2 Operand: Triggered</data></event> </UDPList>

    Notice that the events come in reverse order.

    We can now apply a sytle sheet to the above XML. This is supplied through the file UDP.xsl, which in this case must exist in the directory that myhttpd.py is run from. The XSL gives us a page that looks like:

  • Published 23 July 2007 12:38 by Community.Organiser

    Comments

    No Comments