<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="nl">
	<id>https://bitlair.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pietdv</id>
	<title>Hackerspace Bitlair - Gebruikersbijdragen [nl]</title>
	<link rel="self" type="application/atom+xml" href="https://bitlair.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pietdv"/>
	<link rel="alternate" type="text/html" href="https://bitlair.nl/Speciaal:Bijdragen/Pietdv"/>
	<updated>2026-04-17T18:22:05Z</updated>
	<subtitle>Gebruikersbijdragen</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1921</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1921"/>
		<updated>2012-07-28T20:16:22Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=User:Pietdv&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
===Update 28/07/12===&lt;br /&gt;
We made a new relay board so we can control the two light independently, When the raspi is booting both lights are now off.&lt;br /&gt;
&lt;br /&gt;
===Update 28/07/12 nr2 ===&lt;br /&gt;
We ported the code to Python. When there is only a limited amount of package loss, the lights now blinks.&lt;br /&gt;
&lt;br /&gt;
== People who helped ==&lt;br /&gt;
* [[User:Pietdv|Pietdv]]&lt;br /&gt;
* gmc&lt;br /&gt;
* [[User:Zarya|Zarya]]&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
Image:netlightSchematic2.jpg|The schematic of the relay board&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
 #!/usr/bin/env python&lt;br /&gt;
  &lt;br /&gt;
 &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     A pure python ping implementation using raw socket.&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
     Note that ICMP messages can only be sent from processes running as root.&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
     Derived from ping.c distributed in Linux&#039;s netkit. That code is&lt;br /&gt;
     copyright (c) 1989 by The Regents of the University of California.&lt;br /&gt;
     That code is in turn derived from code written by Mike Muuss of the&lt;br /&gt;
     US Army Ballistic Research Laboratory in December, 1983 and&lt;br /&gt;
     placed in the public domain. They have my thanks.&lt;br /&gt;
  &lt;br /&gt;
     Bugs are naturally mine. I&#039;d be glad to hear about them. There are&lt;br /&gt;
     certainly word - size dependenceies here.&lt;br /&gt;
  &lt;br /&gt;
     Copyright (c) Matthew Dixon Cowles, &amp;lt;http://www.visi.com/~mdc/&amp;gt;.&lt;br /&gt;
     Distributable under the terms of the GNU General Public License&lt;br /&gt;
     version 2. Provided with no warranties of any sort.&lt;br /&gt;
  &lt;br /&gt;
     Original Version from Matthew Dixon Cowles:&lt;br /&gt;
       -&amp;gt; ftp://ftp.visi.com/users/mdc/ping.py&lt;br /&gt;
  &lt;br /&gt;
     Rewrite by Jens Diemer:&lt;br /&gt;
       -&amp;gt; http://www.python-forum.de/post-69122.html#69122&lt;br /&gt;
  &lt;br /&gt;
     Rewrite by George Notaras:&lt;br /&gt;
       -&amp;gt; http://www.g-loaded.eu/2009/10/30/python-ping/&lt;br /&gt;
  &lt;br /&gt;
     Revision history&lt;br /&gt;
     22:16, 28 July 2012 (CEST)22:16, 28 July 2012 (CEST)22:16, 28 July 2012 (CEST)~&lt;br /&gt;
  &lt;br /&gt;
     November 8, 2009&lt;br /&gt;
     ----------------&lt;br /&gt;
     Improved compatibility with GNU/Linux systems.&lt;br /&gt;
  &lt;br /&gt;
     Fixes by:&lt;br /&gt;
      * George Notaras -- http://www.g-loaded.eu&lt;br /&gt;
     Reported by:&lt;br /&gt;
      * Chris Hallman -- http://cdhallman.blogspot.com&lt;br /&gt;
  &lt;br /&gt;
     Changes in this release:&lt;br /&gt;
      - Re-use time.time() instead of time.clock(). The 2007 implementation&lt;br /&gt;
        worked only under Microsoft Windows. Failed on GNU/Linux.&lt;br /&gt;
        time.clock() behaves differently under the two OSes[1].&lt;br /&gt;
  &lt;br /&gt;
     [1] http://docs.python.org/library/time.html#time.clock&lt;br /&gt;
  &lt;br /&gt;
     May 30, 2007&lt;br /&gt;
     ------------&lt;br /&gt;
     little rewrite by Jens Diemer:&lt;br /&gt;
      -  change socket asterisk import to a normal import&lt;br /&gt;
      -  replace time.time() with time.clock()&lt;br /&gt;
      -  delete &amp;quot;return None&amp;quot; (or change to &amp;quot;return&amp;quot; only)&lt;br /&gt;
      -  in checksum() rename &amp;quot;str&amp;quot; to &amp;quot;source_string&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
     November 22, 1997&lt;br /&gt;
     -----------------&lt;br /&gt;
     Initial hack. Doesn&#039;t do much, but rather than try to guess&lt;br /&gt;
     what features I (or others) will want in the future, I&#039;ve only&lt;br /&gt;
     put in what I need now.&lt;br /&gt;
  &lt;br /&gt;
     December 16, 1997&lt;br /&gt;
     -----------------&lt;br /&gt;
     For some reason, the checksum bytes are in the wrong order when&lt;br /&gt;
     this is run under Solaris 2.X for SPARC but it works right under&lt;br /&gt;
     Linux x86. Since I don&#039;t know just what&#039;s wrong, I&#039;ll swap the&lt;br /&gt;
     bytes always and then do an htons().&lt;br /&gt;
  &lt;br /&gt;
     December 4, 2000&lt;br /&gt;
     ----------------&lt;br /&gt;
     Changed the struct.pack() calls to pack the checksum and ID as&lt;br /&gt;
     unsigned. My thanks to Jerome Poincheval for the fix.&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
     Last commit info:&lt;br /&gt;
     22:16, 28 July 2012 (CEST)22:16, 28 July 2012 (CEST)22:16, 28 July 2012 (CEST)~~&lt;br /&gt;
     $LastChangedDate: $&lt;br /&gt;
     $Rev: $&lt;br /&gt;
     $Author: $&lt;br /&gt;
 &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 import os, sys, socket, struct, select, time&lt;br /&gt;
  &lt;br /&gt;
 # From /usr/include/linux/icmp.h; your milage may vary.&lt;br /&gt;
 ICMP_ECHO_REQUEST = 8 # Seems to be the same on Solaris.&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=0.4&lt;br /&gt;
 GREENPIN=24&lt;br /&gt;
 REDPIN=23&lt;br /&gt;
 HISTORY=10&lt;br /&gt;
  &lt;br /&gt;
 def checksum(source_string):&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     I&#039;m not too confident that this is right but testing seems&lt;br /&gt;
     to suggest that it gives the same answers as in_cksum in ping.c&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     sum = 0&lt;br /&gt;
     countTo = (len(source_string)/2)*2&lt;br /&gt;
     count = 0&lt;br /&gt;
     while count&amp;lt;countTo:&lt;br /&gt;
         thisVal = ord(source_string[count + 1])*256 + ord(source_string[count])&lt;br /&gt;
         sum = sum + thisVal&lt;br /&gt;
         sum = sum &amp;amp; 0xffffffff # Necessary?&lt;br /&gt;
         count = count + 2&lt;br /&gt;
  &lt;br /&gt;
     if countTo&amp;lt;len(source_string):&lt;br /&gt;
         sum = sum + ord(source_string[len(source_string) - 1])&lt;br /&gt;
         sum = sum &amp;amp; 0xffffffff # Necessary?&lt;br /&gt;
  &lt;br /&gt;
     sum = (sum &amp;gt;&amp;gt; 16)  +  (sum &amp;amp; 0xffff)&lt;br /&gt;
     sum = sum + (sum &amp;gt;&amp;gt; 16)&lt;br /&gt;
     answer = ~sum&lt;br /&gt;
     answer = answer &amp;amp; 0xffff&lt;br /&gt;
  &lt;br /&gt;
     # Swap bytes. Bugger me if I know why.&lt;br /&gt;
     answer = answer &amp;gt;&amp;gt; 8 | (answer &amp;lt;&amp;lt; 8 &amp;amp; 0xff00)&lt;br /&gt;
  &lt;br /&gt;
     return answer&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
 def receive_one_ping(my_socket, ID, timeout):&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     receive the ping from the socket.&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     timeLeft = timeout&lt;br /&gt;
     while True:&lt;br /&gt;
         startedSelect = time.time()&lt;br /&gt;
         whatReady = select.select([my_socket], [], [], timeLeft)&lt;br /&gt;
         howLongInSelect = (time.time() - startedSelect)&lt;br /&gt;
         if whatReady[0] == []: # Timeout&lt;br /&gt;
             return&lt;br /&gt;
  &lt;br /&gt;
         timeReceived = time.time()&lt;br /&gt;
         recPacket, addr = my_socket.recvfrom(1024)&lt;br /&gt;
         icmpHeader = recPacket[20:28]&lt;br /&gt;
         type, code, checksum, packetID, sequence = struct.unpack(&lt;br /&gt;
             &amp;quot;bbHHh&amp;quot;, icmpHeader&lt;br /&gt;
         )&lt;br /&gt;
         if packetID == ID:&lt;br /&gt;
             bytesInDouble = struct.calcsize(&amp;quot;d&amp;quot;)&lt;br /&gt;
             timeSent = struct.unpack(&amp;quot;d&amp;quot;, recPacket[28:28 + bytesInDouble])[0]&lt;br /&gt;
             return timeReceived - timeSent&lt;br /&gt;
  &lt;br /&gt;
         timeLeft = timeLeft - howLongInSelect&lt;br /&gt;
         if timeLeft &amp;lt;= 0:&lt;br /&gt;
             return&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
 def send_one_ping(my_socket, dest_addr, ID):&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     Send one ping to the given &amp;gt;dest_addr&amp;lt;.&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     dest_addr  =  socket.gethostbyname(dest_addr)&lt;br /&gt;
  &lt;br /&gt;
     # Header is type (8), code (8), checksum (16), id (16), sequence (16)&lt;br /&gt;
     my_checksum = 0&lt;br /&gt;
  &lt;br /&gt;
     # Make a dummy heder with a 0 checksum.&lt;br /&gt;
     header = struct.pack(&amp;quot;bbHHh&amp;quot;, ICMP_ECHO_REQUEST, 0, my_checksum, ID, 1)&lt;br /&gt;
     bytesInDouble = struct.calcsize(&amp;quot;d&amp;quot;)&lt;br /&gt;
     data = (192 - bytesInDouble) * &amp;quot;Q&amp;quot;&lt;br /&gt;
     data = struct.pack(&amp;quot;d&amp;quot;, time.time()) + data&lt;br /&gt;
  &lt;br /&gt;
     # Calculate the checksum on the data and the dummy header.&lt;br /&gt;
     my_checksum = checksum(header + data)&lt;br /&gt;
  &lt;br /&gt;
     # Now that we have the right checksum, we put that in. It&#039;s just easier&lt;br /&gt;
     # to make up a new header than to stuff it into the dummy.&lt;br /&gt;
     header = struct.pack(&lt;br /&gt;
         &amp;quot;bbHHh&amp;quot;, ICMP_ECHO_REQUEST, 0, socket.htons(my_checksum), ID, 1&lt;br /&gt;
     )&lt;br /&gt;
     packet = header + data&lt;br /&gt;
     my_socket.sendto(packet, (dest_addr, 1)) # Don&#039;t know about the 1&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
 def do_one(dest_addr, timeout):&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     Returns either the delay (in seconds) or none on timeout.&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     icmp = socket.getprotobyname(&amp;quot;icmp&amp;quot;)&lt;br /&gt;
     try:&lt;br /&gt;
         my_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)&lt;br /&gt;
     except socket.error, (errno, msg):&lt;br /&gt;
         if errno == 1:&lt;br /&gt;
             # Operation not permitted&lt;br /&gt;
             msg = msg + (&lt;br /&gt;
                 &amp;quot; - Note that ICMP messages can only be sent from processes&amp;quot;&lt;br /&gt;
                 &amp;quot; running as root.&amp;quot;&lt;br /&gt;
             )&lt;br /&gt;
             raise socket.error(msg)&lt;br /&gt;
         raise # raise the original error&lt;br /&gt;
  &lt;br /&gt;
     my_ID = os.getpid() &amp;amp; 0xFFFF&lt;br /&gt;
  &lt;br /&gt;
     send_one_ping(my_socket, dest_addr, my_ID)&lt;br /&gt;
     delay = receive_one_ping(my_socket, my_ID, timeout)&lt;br /&gt;
  &lt;br /&gt;
     my_socket.close()&lt;br /&gt;
     return delay&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
 def verbose_ping(dest_addr, timeout = 2, count = 4):&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     Send &amp;gt;count&amp;lt; ping to &amp;gt;dest_addr&amp;lt; with the given &amp;gt;timeout&amp;lt; and display&lt;br /&gt;
     the result.&lt;br /&gt;
     &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
     for i in xrange(count):&lt;br /&gt;
         print &amp;quot;ping %s...&amp;quot; % dest_addr,&lt;br /&gt;
         try:&lt;br /&gt;
             delay  =  do_one(dest_addr, timeout)&lt;br /&gt;
         except socket.gaierror, e:&lt;br /&gt;
             print &amp;quot;failed. (socket error: &#039;%s&#039;)&amp;quot; % e[1]&lt;br /&gt;
             break&lt;br /&gt;
  &lt;br /&gt;
         if delay  ==  None:&lt;br /&gt;
             print &amp;quot;failed. (timeout within %ssec.)&amp;quot; % timeout&lt;br /&gt;
         else:&lt;br /&gt;
             delay  =  delay * 1000&lt;br /&gt;
             print &amp;quot;get ping in %0.4fms&amp;quot; % delay&lt;br /&gt;
     print&lt;br /&gt;
 &lt;br /&gt;
 def set_pin(pin,value):&lt;br /&gt;
     file(&#039;/sys/class/gpio/gpio&#039;+str(pin)+&#039;/value&#039;,&#039;w&#039;).write(str(value))&lt;br /&gt;
 &lt;br /&gt;
 def blink_pin(pin,f):&lt;br /&gt;
     t=time.time()&lt;br /&gt;
     t=t-int(t)&lt;br /&gt;
     if t &amp;lt; 0.5:&lt;br /&gt;
       set_pin(pin,1)&lt;br /&gt;
     else:&lt;br /&gt;
       set_pin(pin,0)&lt;br /&gt;
 &lt;br /&gt;
 def init_pin(pin):&lt;br /&gt;
   file(&#039;/sys/class/gpio/export&#039;,&#039;w&#039;).write(str(pin))&lt;br /&gt;
   file(&#039;/sys/class/gpio/gpio&#039;+str(pin)+&#039;/direction&#039;,&#039;w&#039;).write(&#039;out&#039;)&lt;br /&gt;
 &lt;br /&gt;
 if __name__ == &#039;__main__&#039;:&lt;br /&gt;
     count=0&lt;br /&gt;
     loss=0&lt;br /&gt;
 &lt;br /&gt;
     init_pin(REDPIN);&lt;br /&gt;
     init_pin(GREENPIN);&lt;br /&gt;
   &lt;br /&gt;
     while 1 == 1:&lt;br /&gt;
         lasttime=time.time() &lt;br /&gt;
         print time.time()&lt;br /&gt;
         if count&amp;gt;(HISTORY-1):&lt;br /&gt;
             count=count-1&lt;br /&gt;
             if loss&amp;gt;(HISTORY-1):&lt;br /&gt;
               loss=loss-1&lt;br /&gt;
         ping = None&lt;br /&gt;
         try:&lt;br /&gt;
           ping = do_one(IP,TIMEOUT)&lt;br /&gt;
         except:&lt;br /&gt;
           pass&lt;br /&gt;
         count=count+1&lt;br /&gt;
         if ping == None:&lt;br /&gt;
             loss=loss+1&lt;br /&gt;
         elif loss&amp;gt;0:&lt;br /&gt;
             loss=loss-1&lt;br /&gt;
         &lt;br /&gt;
         print &amp;quot;ping &amp;quot;+str(count)+&amp;quot;, loss &amp;quot;+str(loss)&lt;br /&gt;
         if loss==0:&lt;br /&gt;
             set_pin(REDPIN,0)&lt;br /&gt;
             set_pin(GREENPIN,1)&lt;br /&gt;
         elif loss==count:&lt;br /&gt;
             set_pin(GREENPIN,0)&lt;br /&gt;
             set_pin(REDPIN,1)&lt;br /&gt;
         else:&lt;br /&gt;
             set_pin(GREENPIN,1)&lt;br /&gt;
             blink_pin(REDPIN,0.2+((1.0-(float(loss)/float(count)))/2.0))&lt;br /&gt;
         wait = lasttime+1 - time.time()&lt;br /&gt;
         print wait&lt;br /&gt;
         if loss==0 and wait:&lt;br /&gt;
            time.sleep(wait)&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1920</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1920"/>
		<updated>2012-07-28T20:12:26Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=User:Pietdv&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
===Update 28/07/12===&lt;br /&gt;
We made a new relay board so we can control the two light independently, When the raspi is booting both lights are now off.&lt;br /&gt;
&lt;br /&gt;
===Update 28/07/12 nr2 ===&lt;br /&gt;
We ported the code to Python. When there is only a limited amount of package loss, the lights now blinks.&lt;br /&gt;
&lt;br /&gt;
== People who helped ==&lt;br /&gt;
* [[User:Pietdv|Pietdv]]&lt;br /&gt;
* gmc&lt;br /&gt;
* [[User:Zarya|Zarya]]&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
Image:netlightSchematic2.jpg|The schematic of the relay board&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
 &lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    A pure python ping implementation using raw socket.&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    Note that ICMP messages can only be sent from processes running as root.&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    Derived from ping.c distributed in Linux&#039;s netkit. That code is&lt;br /&gt;
    copyright (c) 1989 by The Regents of the University of California.&lt;br /&gt;
    That code is in turn derived from code written by Mike Muuss of the&lt;br /&gt;
    US Army Ballistic Research Laboratory in December, 1983 and&lt;br /&gt;
    placed in the public domain. They have my thanks.&lt;br /&gt;
 &lt;br /&gt;
    Bugs are naturally mine. I&#039;d be glad to hear about them. There are&lt;br /&gt;
    certainly word - size dependenceies here.&lt;br /&gt;
 &lt;br /&gt;
    Copyright (c) Matthew Dixon Cowles, &amp;lt;http://www.visi.com/~mdc/&amp;gt;.&lt;br /&gt;
    Distributable under the terms of the GNU General Public License&lt;br /&gt;
    version 2. Provided with no warranties of any sort.&lt;br /&gt;
 &lt;br /&gt;
    Original Version from Matthew Dixon Cowles:&lt;br /&gt;
      -&amp;gt; ftp://ftp.visi.com/users/mdc/ping.py&lt;br /&gt;
 &lt;br /&gt;
    Rewrite by Jens Diemer:&lt;br /&gt;
      -&amp;gt; http://www.python-forum.de/post-69122.html#69122&lt;br /&gt;
 &lt;br /&gt;
    Rewrite by George Notaras:&lt;br /&gt;
      -&amp;gt; http://www.g-loaded.eu/2009/10/30/python-ping/&lt;br /&gt;
 &lt;br /&gt;
    Revision history&lt;br /&gt;
    22:12, 28 July 2012 (CEST)22:12, 28 July 2012 (CEST)22:12, 28 July 2012 (CEST)~&lt;br /&gt;
 &lt;br /&gt;
    November 8, 2009&lt;br /&gt;
    ----------------&lt;br /&gt;
    Improved compatibility with GNU/Linux systems.&lt;br /&gt;
 &lt;br /&gt;
    Fixes by:&lt;br /&gt;
     * George Notaras -- http://www.g-loaded.eu&lt;br /&gt;
    Reported by:&lt;br /&gt;
     * Chris Hallman -- http://cdhallman.blogspot.com&lt;br /&gt;
 &lt;br /&gt;
    Changes in this release:&lt;br /&gt;
     - Re-use time.time() instead of time.clock(). The 2007 implementation&lt;br /&gt;
       worked only under Microsoft Windows. Failed on GNU/Linux.&lt;br /&gt;
       time.clock() behaves differently under the two OSes[1].&lt;br /&gt;
 &lt;br /&gt;
    [1] http://docs.python.org/library/time.html#time.clock&lt;br /&gt;
 &lt;br /&gt;
    May 30, 2007&lt;br /&gt;
    ------------&lt;br /&gt;
    little rewrite by Jens Diemer:&lt;br /&gt;
     -  change socket asterisk import to a normal import&lt;br /&gt;
     -  replace time.time() with time.clock()&lt;br /&gt;
     -  delete &amp;quot;return None&amp;quot; (or change to &amp;quot;return&amp;quot; only)&lt;br /&gt;
     -  in checksum() rename &amp;quot;str&amp;quot; to &amp;quot;source_string&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
    November 22, 1997&lt;br /&gt;
    -----------------&lt;br /&gt;
    Initial hack. Doesn&#039;t do much, but rather than try to guess&lt;br /&gt;
    what features I (or others) will want in the future, I&#039;ve only&lt;br /&gt;
    put in what I need now.&lt;br /&gt;
 &lt;br /&gt;
    December 16, 1997&lt;br /&gt;
    -----------------&lt;br /&gt;
    For some reason, the checksum bytes are in the wrong order when&lt;br /&gt;
    this is run under Solaris 2.X for SPARC but it works right under&lt;br /&gt;
    Linux x86. Since I don&#039;t know just what&#039;s wrong, I&#039;ll swap the&lt;br /&gt;
    bytes always and then do an htons().&lt;br /&gt;
 &lt;br /&gt;
    December 4, 2000&lt;br /&gt;
    ----------------&lt;br /&gt;
    Changed the struct.pack() calls to pack the checksum and ID as&lt;br /&gt;
    unsigned. My thanks to Jerome Poincheval for the fix.&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
    Last commit info:&lt;br /&gt;
    22:12, 28 July 2012 (CEST)22:12, 28 July 2012 (CEST)22:12, 28 July 2012 (CEST)~~&lt;br /&gt;
    $LastChangedDate: $&lt;br /&gt;
    $Rev: $&lt;br /&gt;
    $Author: $&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
import os, sys, socket, struct, select, time&lt;br /&gt;
 &lt;br /&gt;
# From /usr/include/linux/icmp.h; your milage may vary.&lt;br /&gt;
ICMP_ECHO_REQUEST = 8 # Seems to be the same on Solaris.&lt;br /&gt;
&lt;br /&gt;
IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
TIMEOUT=0.4&lt;br /&gt;
GREENPIN=24&lt;br /&gt;
REDPIN=23&lt;br /&gt;
HISTORY=10&lt;br /&gt;
 &lt;br /&gt;
def checksum(source_string):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    I&#039;m not too confident that this is right but testing seems&lt;br /&gt;
    to suggest that it gives the same answers as in_cksum in ping.c&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    sum = 0&lt;br /&gt;
    countTo = (len(source_string)/2)*2&lt;br /&gt;
    count = 0&lt;br /&gt;
    while count&amp;lt;countTo:&lt;br /&gt;
        thisVal = ord(source_string[count + 1])*256 + ord(source_string[count])&lt;br /&gt;
        sum = sum + thisVal&lt;br /&gt;
        sum = sum &amp;amp; 0xffffffff # Necessary?&lt;br /&gt;
        count = count + 2&lt;br /&gt;
 &lt;br /&gt;
    if countTo&amp;lt;len(source_string):&lt;br /&gt;
        sum = sum + ord(source_string[len(source_string) - 1])&lt;br /&gt;
        sum = sum &amp;amp; 0xffffffff # Necessary?&lt;br /&gt;
 &lt;br /&gt;
    sum = (sum &amp;gt;&amp;gt; 16)  +  (sum &amp;amp; 0xffff)&lt;br /&gt;
    sum = sum + (sum &amp;gt;&amp;gt; 16)&lt;br /&gt;
    answer = ~sum&lt;br /&gt;
    answer = answer &amp;amp; 0xffff&lt;br /&gt;
 &lt;br /&gt;
    # Swap bytes. Bugger me if I know why.&lt;br /&gt;
    answer = answer &amp;gt;&amp;gt; 8 | (answer &amp;lt;&amp;lt; 8 &amp;amp; 0xff00)&lt;br /&gt;
 &lt;br /&gt;
    return answer&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
def receive_one_ping(my_socket, ID, timeout):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    receive the ping from the socket.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    timeLeft = timeout&lt;br /&gt;
    while True:&lt;br /&gt;
        startedSelect = time.time()&lt;br /&gt;
        whatReady = select.select([my_socket], [], [], timeLeft)&lt;br /&gt;
        howLongInSelect = (time.time() - startedSelect)&lt;br /&gt;
        if whatReady[0] == []: # Timeout&lt;br /&gt;
            return&lt;br /&gt;
 &lt;br /&gt;
        timeReceived = time.time()&lt;br /&gt;
        recPacket, addr = my_socket.recvfrom(1024)&lt;br /&gt;
        icmpHeader = recPacket[20:28]&lt;br /&gt;
        type, code, checksum, packetID, sequence = struct.unpack(&lt;br /&gt;
            &amp;quot;bbHHh&amp;quot;, icmpHeader&lt;br /&gt;
        )&lt;br /&gt;
        if packetID == ID:&lt;br /&gt;
            bytesInDouble = struct.calcsize(&amp;quot;d&amp;quot;)&lt;br /&gt;
            timeSent = struct.unpack(&amp;quot;d&amp;quot;, recPacket[28:28 + bytesInDouble])[0]&lt;br /&gt;
            return timeReceived - timeSent&lt;br /&gt;
 &lt;br /&gt;
        timeLeft = timeLeft - howLongInSelect&lt;br /&gt;
        if timeLeft &amp;lt;= 0:&lt;br /&gt;
            return&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
def send_one_ping(my_socket, dest_addr, ID):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Send one ping to the given &amp;gt;dest_addr&amp;lt;.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    dest_addr  =  socket.gethostbyname(dest_addr)&lt;br /&gt;
 &lt;br /&gt;
    # Header is type (8), code (8), checksum (16), id (16), sequence (16)&lt;br /&gt;
    my_checksum = 0&lt;br /&gt;
 &lt;br /&gt;
    # Make a dummy heder with a 0 checksum.&lt;br /&gt;
    header = struct.pack(&amp;quot;bbHHh&amp;quot;, ICMP_ECHO_REQUEST, 0, my_checksum, ID, 1)&lt;br /&gt;
    bytesInDouble = struct.calcsize(&amp;quot;d&amp;quot;)&lt;br /&gt;
    data = (192 - bytesInDouble) * &amp;quot;Q&amp;quot;&lt;br /&gt;
    data = struct.pack(&amp;quot;d&amp;quot;, time.time()) + data&lt;br /&gt;
 &lt;br /&gt;
    # Calculate the checksum on the data and the dummy header.&lt;br /&gt;
    my_checksum = checksum(header + data)&lt;br /&gt;
 &lt;br /&gt;
    # Now that we have the right checksum, we put that in. It&#039;s just easier&lt;br /&gt;
    # to make up a new header than to stuff it into the dummy.&lt;br /&gt;
    header = struct.pack(&lt;br /&gt;
        &amp;quot;bbHHh&amp;quot;, ICMP_ECHO_REQUEST, 0, socket.htons(my_checksum), ID, 1&lt;br /&gt;
    )&lt;br /&gt;
    packet = header + data&lt;br /&gt;
    my_socket.sendto(packet, (dest_addr, 1)) # Don&#039;t know about the 1&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
def do_one(dest_addr, timeout):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Returns either the delay (in seconds) or none on timeout.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    icmp = socket.getprotobyname(&amp;quot;icmp&amp;quot;)&lt;br /&gt;
    try:&lt;br /&gt;
        my_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)&lt;br /&gt;
    except socket.error, (errno, msg):&lt;br /&gt;
        if errno == 1:&lt;br /&gt;
            # Operation not permitted&lt;br /&gt;
            msg = msg + (&lt;br /&gt;
                &amp;quot; - Note that ICMP messages can only be sent from processes&amp;quot;&lt;br /&gt;
                &amp;quot; running as root.&amp;quot;&lt;br /&gt;
            )&lt;br /&gt;
            raise socket.error(msg)&lt;br /&gt;
        raise # raise the original error&lt;br /&gt;
 &lt;br /&gt;
    my_ID = os.getpid() &amp;amp; 0xFFFF&lt;br /&gt;
 &lt;br /&gt;
    send_one_ping(my_socket, dest_addr, my_ID)&lt;br /&gt;
    delay = receive_one_ping(my_socket, my_ID, timeout)&lt;br /&gt;
 &lt;br /&gt;
    my_socket.close()&lt;br /&gt;
    return delay&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
def verbose_ping(dest_addr, timeout = 2, count = 4):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Send &amp;gt;count&amp;lt; ping to &amp;gt;dest_addr&amp;lt; with the given &amp;gt;timeout&amp;lt; and display&lt;br /&gt;
    the result.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    for i in xrange(count):&lt;br /&gt;
        print &amp;quot;ping %s...&amp;quot; % dest_addr,&lt;br /&gt;
        try:&lt;br /&gt;
            delay  =  do_one(dest_addr, timeout)&lt;br /&gt;
        except socket.gaierror, e:&lt;br /&gt;
            print &amp;quot;failed. (socket error: &#039;%s&#039;)&amp;quot; % e[1]&lt;br /&gt;
            break&lt;br /&gt;
 &lt;br /&gt;
        if delay  ==  None:&lt;br /&gt;
            print &amp;quot;failed. (timeout within %ssec.)&amp;quot; % timeout&lt;br /&gt;
        else:&lt;br /&gt;
            delay  =  delay * 1000&lt;br /&gt;
            print &amp;quot;get ping in %0.4fms&amp;quot; % delay&lt;br /&gt;
    print&lt;br /&gt;
&lt;br /&gt;
def set_pin(pin,value):&lt;br /&gt;
    file(&#039;/sys/class/gpio/gpio&#039;+str(pin)+&#039;/value&#039;,&#039;w&#039;).write(str(value))&lt;br /&gt;
&lt;br /&gt;
def blink_pin(pin,f):&lt;br /&gt;
    t=time.time()&lt;br /&gt;
    t=t-int(t)&lt;br /&gt;
    if t &amp;lt; 0.5:&lt;br /&gt;
      set_pin(pin,1)&lt;br /&gt;
    else:&lt;br /&gt;
      set_pin(pin,0)&lt;br /&gt;
&lt;br /&gt;
def init_pin(pin):&lt;br /&gt;
  file(&#039;/sys/class/gpio/export&#039;,&#039;w&#039;).write(str(pin))&lt;br /&gt;
  file(&#039;/sys/class/gpio/gpio&#039;+str(pin)+&#039;/direction&#039;,&#039;w&#039;).write(&#039;out&#039;)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    count=0&lt;br /&gt;
    loss=0&lt;br /&gt;
&lt;br /&gt;
    init_pin(REDPIN);&lt;br /&gt;
    init_pin(GREENPIN);&lt;br /&gt;
  &lt;br /&gt;
    while 1 == 1:&lt;br /&gt;
        lasttime=time.time() &lt;br /&gt;
        print time.time()&lt;br /&gt;
        if count&amp;gt;(HISTORY-1):&lt;br /&gt;
            count=count-1&lt;br /&gt;
            if loss&amp;gt;(HISTORY-1):&lt;br /&gt;
              loss=loss-1&lt;br /&gt;
        ping = None&lt;br /&gt;
        try:&lt;br /&gt;
          ping = do_one(IP,TIMEOUT)&lt;br /&gt;
        except:&lt;br /&gt;
          pass&lt;br /&gt;
        count=count+1&lt;br /&gt;
        if ping == None:&lt;br /&gt;
            loss=loss+1&lt;br /&gt;
        elif loss&amp;gt;0:&lt;br /&gt;
            loss=loss-1&lt;br /&gt;
        &lt;br /&gt;
        print &amp;quot;ping &amp;quot;+str(count)+&amp;quot;, loss &amp;quot;+str(loss)&lt;br /&gt;
        if loss==0:&lt;br /&gt;
            set_pin(REDPIN,0)&lt;br /&gt;
            set_pin(GREENPIN,1)&lt;br /&gt;
        elif loss==count:&lt;br /&gt;
            set_pin(GREENPIN,0)&lt;br /&gt;
            set_pin(REDPIN,1)&lt;br /&gt;
        else:&lt;br /&gt;
            set_pin(GREENPIN,1)&lt;br /&gt;
            blink_pin(REDPIN,0.2+((1.0-(float(loss)/float(count)))/2.0))&lt;br /&gt;
        wait = lasttime+1 - time.time()&lt;br /&gt;
        print wait&lt;br /&gt;
        if loss==0 and wait:&lt;br /&gt;
           time.sleep(wait)&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1916</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1916"/>
		<updated>2012-07-28T15:40:39Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=User:Pietdv&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
===Update 28/07/12===&lt;br /&gt;
We made a new relay board so we can control the two light independently, When the raspi is booting both lights are now off.&lt;br /&gt;
&lt;br /&gt;
== People who helped ==&lt;br /&gt;
* [[User:Pietdv|Pietdv]]&lt;br /&gt;
* gmc&lt;br /&gt;
* [[User:Zarya|Zarya]]&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
Image:netlightSchematic2.jpg|The schematic of the relay board&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;24&amp;quot;&lt;br /&gt;
 THRESHOLD=&amp;quot;2&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 &lt;br /&gt;
 COUNT=0&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     COUNT=0&lt;br /&gt;
   else&lt;br /&gt;
     COUNT=`expr ${COUNT} + 1`&lt;br /&gt;
   fi&lt;br /&gt;
 &lt;br /&gt;
   if [ ${COUNT} -ge ${THRESHOLD} ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1915</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1915"/>
		<updated>2012-07-28T15:03:27Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=User:Pietdv&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== People who helped ==&lt;br /&gt;
* [[User:Pietdv|Pietdv]]&lt;br /&gt;
* gmc&lt;br /&gt;
* [[User:Zarya|Zarya]]&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
Image:netlightSchematic2.jpg|The schematic of the relay board&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;24&amp;quot;&lt;br /&gt;
 THRESHOLD=&amp;quot;2&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 &lt;br /&gt;
 COUNT=0&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     COUNT=0&lt;br /&gt;
   else&lt;br /&gt;
     COUNT=`expr ${COUNT} + 1`&lt;br /&gt;
   fi&lt;br /&gt;
 &lt;br /&gt;
   if [ ${COUNT} -ge ${THRESHOLD} ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Bestand:NetlightSchematic2.jpg&amp;diff=1914</id>
		<title>Bestand:NetlightSchematic2.jpg</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Bestand:NetlightSchematic2.jpg&amp;diff=1914"/>
		<updated>2012-07-28T15:00:36Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1912</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1912"/>
		<updated>2012-07-27T15:47:20Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=User:Pietdv&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== People who helped ==&lt;br /&gt;
* [[User:Pietdv|Pietdv]]&lt;br /&gt;
* gmc&lt;br /&gt;
* [[User:Zarya|Zarya]]&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
Image:Netlight_schematic.jpg|The schematic of the relay board&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
Note: The script was written to control the green and red light separately, But we designed the relay board so that it can be done with one pin — and one relay. The script still controls a seconds gpi pin, but we just don&#039;t use it.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;24&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 &lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1910</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1910"/>
		<updated>2012-07-27T14:21:38Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=User:Pietdv&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== People who helped ==&lt;br /&gt;
* [[User:Pietdv|Pietdv]]&lt;br /&gt;
* gmc&lt;br /&gt;
* Zarya&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
Image:Netlight_schematic.jpg|The schematic of the relay board&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;24&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 &lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Bestand:Netlight_schematic.jpg&amp;diff=1908</id>
		<title>Bestand:Netlight schematic.jpg</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Bestand:Netlight_schematic.jpg&amp;diff=1908"/>
		<updated>2012-07-27T14:20:43Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: schematic.jpg for Netlight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;schematic.jpg for [[Netlight]]&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1905</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1905"/>
		<updated>2012-07-27T14:16:11Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=User:Pietdv&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== People who helpt ==&lt;br /&gt;
* [[User:Pietdv|Pietdv]]&lt;br /&gt;
* gmc&lt;br /&gt;
* Zarya&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;24&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 &lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1904</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1904"/>
		<updated>2012-07-27T14:15:47Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=User:Pietdv&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== People who helpt ==&lt;br /&gt;
* User:Pietdv&lt;br /&gt;
* gmc&lt;br /&gt;
* Zarya&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;24&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 &lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1903</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1903"/>
		<updated>2012-07-27T14:15:39Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=User:Pietdv&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== People who helpt ==&lt;br /&gt;
* Piet&lt;br /&gt;
* gmc&lt;br /&gt;
* Zarya&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;24&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 &lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Gebruiker:Pietdv&amp;diff=1902</id>
		<title>Gebruiker:Pietdv</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Gebruiker:Pietdv&amp;diff=1902"/>
		<updated>2012-07-27T14:14:58Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Member&lt;br /&gt;
|foto=image:BBC_awards.jpeg&lt;br /&gt;
|positie=Geen lid&lt;br /&gt;
|naam=Piet De Vaere&lt;br /&gt;
|nick=Pietdv&lt;br /&gt;
|locatie=Brugge, be&lt;br /&gt;
|bio=piet@devae.re&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Gebruiker:Pietdv&amp;diff=1901</id>
		<title>Gebruiker:Pietdv</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Gebruiker:Pietdv&amp;diff=1901"/>
		<updated>2012-07-27T14:13:55Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Member&lt;br /&gt;
|foto=BBC awards.jpeg&lt;br /&gt;
|positie=Geen lid&lt;br /&gt;
|naam=Piet De Vaere&lt;br /&gt;
|nick=Pietdv&lt;br /&gt;
|locatie=Brugge, be&lt;br /&gt;
|bio=piet@devae.re&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Bestand:BBC_awards.jpeg&amp;diff=1900</id>
		<title>Bestand:BBC awards.jpeg</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Bestand:BBC_awards.jpeg&amp;diff=1900"/>
		<updated>2012-07-27T14:13:50Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Gebruiker:Pietdv&amp;diff=1897</id>
		<title>Gebruiker:Pietdv</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Gebruiker:Pietdv&amp;diff=1897"/>
		<updated>2012-07-27T14:12:55Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: Created page with &amp;quot;{{Member |positie=Geen lid |naam=Piet De Vaere |nick=Pietdv |locatie=Brugge, be }} ==Contact== piet@devae.re&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Member&lt;br /&gt;
|positie=Geen lid&lt;br /&gt;
|naam=Piet De Vaere&lt;br /&gt;
|nick=Pietdv&lt;br /&gt;
|locatie=Brugge, be&lt;br /&gt;
}}&lt;br /&gt;
==Contact==&lt;br /&gt;
piet@devae.re&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1893</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1893"/>
		<updated>2012-07-27T14:08:22Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=Piet&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to let the raspi control the traffic light, and wrote a shell script to check if there was an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;24&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 &lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1892</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1892"/>
		<updated>2012-07-27T14:06:33Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=Piet&lt;br /&gt;
|start=2012-07-27&lt;br /&gt;
|end=2012-07-29&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Because of a faulty switch the network at haxogreen 2012 was quite buggy for a while. After a couple of hours we were sick of opening up a terminal and starting a ping to check if the internet was up. We had a raspi and a traffic light available, so we started hacking. We made a little relay board to make the raspi control the traffic light, and wrote a shell script to check if there is an internet connection and set the traffic light to green if there was, to red if there wasn&#039;t.&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;24&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 &lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1883</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1883"/>
		<updated>2012-07-27T13:53:22Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: /* Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=Piet&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 &lt;br /&gt;
 IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
 TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
 GPIO_GREEN=&amp;quot;23&amp;quot;&lt;br /&gt;
 GPIO_RED=&amp;quot;24&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # no user-servicable parts below&lt;br /&gt;
 &lt;br /&gt;
 echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
 echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
 echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
 &lt;br /&gt;
 while [ 1 ]; do&lt;br /&gt;
   ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
 &lt;br /&gt;
   ec=$?&lt;br /&gt;
 &lt;br /&gt;
   if [ ${ec} -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     sleep 3&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
     echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
	<entry>
		<id>https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1882</id>
		<title>Projects/Netlight</title>
		<link rel="alternate" type="text/html" href="https://bitlair.nl/index.php?title=Projects/Netlight&amp;diff=1882"/>
		<updated>2012-07-27T13:52:39Z</updated>

		<summary type="html">&lt;p&gt;Pietdv: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Project&lt;br /&gt;
|name=Netlight&lt;br /&gt;
|contact=Piet&lt;br /&gt;
|info=The network traffic light at haxogreen&lt;br /&gt;
|status=Production&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
http://www.youtube.com/watch?v=uxdJv-h0Fks&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
IP=&amp;quot;8.8.8.8&amp;quot;&lt;br /&gt;
TIMEOUT=&amp;quot;2&amp;quot;&lt;br /&gt;
GPIO_GREEN=&amp;quot;23&amp;quot;&lt;br /&gt;
GPIO_RED=&amp;quot;24&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# no user-servicable parts below&lt;br /&gt;
&lt;br /&gt;
echo ${GPIO_GREEN} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/direction&lt;br /&gt;
echo ${GPIO_RED} &amp;gt; /sys/class/gpio/export&lt;br /&gt;
echo &amp;quot;out&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/direction&lt;br /&gt;
&lt;br /&gt;
while [ 1 ]; do&lt;br /&gt;
  ping -c 1 -W 2 -qq ${IP} &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
&lt;br /&gt;
  ec=$?&lt;br /&gt;
&lt;br /&gt;
  if [ ${ec} -eq 0 ]; then&lt;br /&gt;
    echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
    sleep 3&lt;br /&gt;
    echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
  else&lt;br /&gt;
    echo &amp;quot;0&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_GREEN}/value&lt;br /&gt;
    echo &amp;quot;1&amp;quot; &amp;gt; /sys/class/gpio/gpio${GPIO_RED}/value&lt;br /&gt;
  fi&lt;br /&gt;
done &lt;br /&gt;
&lt;br /&gt;
== Gallery ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Zarya_15776.jpg|&lt;br /&gt;
Image:Zarya_15775.jpg|Raspberry PI with a relay board connected to it&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pietdv</name></author>
	</entry>
</feed>