<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Things Of Some Value, Hopefully</title>
	<atom:link href="http://mattgwwalker.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattgwwalker.wordpress.com</link>
	<description>Notes on things I would like to remember</description>
	<lastBuildDate>Fri, 04 Nov 2011 12:26:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mattgwwalker.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Things Of Some Value, Hopefully</title>
		<link>http://mattgwwalker.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mattgwwalker.wordpress.com/osd.xml" title="Things Of Some Value, Hopefully" />
	<atom:link rel='hub' href='http://mattgwwalker.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Using ntpd to set system time</title>
		<link>http://mattgwwalker.wordpress.com/2011/11/04/using-ntpd-to-set-system-time/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/11/04/using-ntpd-to-set-system-time/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 12:26:30 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=264</guid>
		<description><![CDATA[After installing the Network Time Protocol Daemon (ntpd), you can set the time using the command ntpd -q -g. The -q mimics the old ntpdate program and just sets the clock and exits. The -g allows the time change to be large.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=264&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After installing the Network Time Protocol Daemon (ntpd), you can set the time using the command <code>ntpd -q -g</code>.  The <code>-q</code> mimics the old <code>ntpdate</code> program and just sets the clock and exits.  The <code>-g</code> allows the time change to be large.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/264/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=264&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/11/04/using-ntpd-to-set-system-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
		<item>
		<title>Omnima Embedded Controller: tun device</title>
		<link>http://mattgwwalker.wordpress.com/2011/11/04/omnima-embedded-controller-tun-device/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/11/04/omnima-embedded-controller-tun-device/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 11:52:10 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=258</guid>
		<description><![CDATA[After installing OpenVPN, I was getting the error &#8220;Cannot open TUN/TAP device&#8221;: OpenVPN 2.0.9 mipsel-linux [SSL] [LZO] built on Aug 28 2008 IMPORTANT: OpenVPN's default port number is now 1194, based on an official port number assignment by IANA. OpenVPN 2.0-beta16 and earlier used 5000 as the default port. Note: Cannot open TUN/TAP dev /dev/net/tun: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=258&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After installing OpenVPN, I was getting the error &#8220;Cannot open TUN/TAP device&#8221;:</p>
<pre>
OpenVPN 2.0.9 mipsel-linux [SSL] [LZO] built on Aug 28 2008
IMPORTANT: OpenVPN's default port number is now 1194, based on an official port number assignment by IANA.  OpenVPN 2.0-beta16 and earlier used 5000 as the default port.
Note: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)
Note: Attempting fallback to kernel 2.2 TUN/TAP interface
Cannot allocate TUN/TAP dev dynamically
Exiting
</pre>
<p>The only solution I&#8217;ve found for this problem has been in <a href="https://forum.openwrt.org/viewtopic.php?id=15979">a message in the OpenWRT forum</a>:</p>
<pre>
insmod tun
mkdir /dev/net
mknod /dev/net/tun c 10 200
</pre>
<p>However sometimes this seems to cause OpenVPN to seg-fault.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/258/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=258&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/11/04/omnima-embedded-controller-tun-device/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
		<item>
		<title>Omnima Embedded Controller: /etc/init.d/network</title>
		<link>http://mattgwwalker.wordpress.com/2011/09/29/omnima-embedded-controller-etcinit-dnetwork/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/09/29/omnima-embedded-controller-etcinit-dnetwork/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 23:14:43 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=255</guid>
		<description><![CDATA[For the life of me I couldn&#8217;t work out how to follow the instructions to turn the box into a switch (that is after all what the chip is intended for!). It really stumpped me as to why things would sometimes work but that the next time I tried the same idea, it wouldn&#8217;t work [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=255&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For the life of me I couldn&#8217;t work out how to follow the instructions to turn the box into a switch (that is after all what the chip is intended for!).  It really stumpped me as to why things would sometimes work but that the next time I tried the same idea, it wouldn&#8217;t work at all.  Finally this came to a head when I <strong>needed</strong> two ports to at least function.</p>
<p>What was the problem?  Have a look at the script <code>/etc/init.d/network</code>, specifically tell me about the &#8220;restart&#8221; function.  I was surprised to see that it wasn&#8217;t deliberately stopping the interfaces.  Why is that?  I understood that <a href="http://www.unix.com/unix-dummies-questions-answers/130108-stop-start-vs-restart.html">there isn&#8217;t a difference between restart versus start/stop</a>.</p>
<p>I modified the restart function so that it explicitly called stop and start:</p>
<pre>
restart() {
        stop

        setup_switch() { return 0; }
        include /lib/network
        setup_switch

        start
}
</pre>
<p>Now, the networking side of things seems to behave a lot better.  However I haven&#8217;t re-tried my attempts to get the switch working.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/255/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=255&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/09/29/omnima-embedded-controller-etcinit-dnetwork/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
		<item>
		<title>Omnima Embedded Controller: Serial Connection under Windows</title>
		<link>http://mattgwwalker.wordpress.com/2011/09/21/omnima-embedded-controller-serial-connection-under-windows/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/09/21/omnima-embedded-controller-serial-connection-under-windows/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 01:35:08 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cable]]></category>
		<category><![CDATA[drivers]]></category>
		<category><![CDATA[Embedded controller]]></category>
		<category><![CDATA[usb-to-serial]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=247</guid>
		<description><![CDATA[The USB-to-serial cable that I got from Omnima with their Embedded Controller didn&#8217;t come with drivers for Windows. When I plugged it into a Linux machine it told me the cable was from Prolific Technology Inc. It appears this is the same chipset that Omnima have been using since at least 2008. Prolific&#8217;s website offers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=247&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The USB-to-serial cable that I got from Omnima with their Embedded Controller didn&#8217;t come with drivers for Windows.  When I plugged it into a Linux machine it told me the cable was from Prolific Technology Inc.  It appears this is the same chipset that Omnima have been using since at least <a href="http://www.omnima.co.uk/forums/index.php?showtopic=19">2008</a>.  <a href="http://www.prolific.com.tw">Prolific&#8217;s website</a> offers a Windows driver for the chipset that&#8217;s in the Omnima cable.  The file <a href="http://www.prolific.com.tw/eng/downloads.asp?id=31">PL2303_Prolific_DriverInstaller_v1417.zip</a> worked well.  (It was just necessary to run the installer as Administrator under Windows 7).</p>
<p>Windows 7 no longer comes with HyperTerminal.  Fortunately, <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">putty</a> does serial communications.  The only thing I had to enter was the COM port and the baud rate.  Running Device Manager told me the USB-to-serial cable had been allocated COM3 (see the Ports section) and <a href="http://www.omnima.co.uk/forums/index.php?showtopic=19">the baud rate is 115,200</a>.</p>
<p>The connection worked first time.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/247/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=247&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/09/21/omnima-embedded-controller-serial-connection-under-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
		<item>
		<title>Omnima Embedded Controller: Activating the Ethernet Ports</title>
		<link>http://mattgwwalker.wordpress.com/2011/09/08/omnima-embedded-controller-activating-the-ethernet-ports/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/09/08/omnima-embedded-controller-activating-the-ethernet-ports/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 22:57:07 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[activate]]></category>
		<category><![CDATA[Embedded controller]]></category>
		<category><![CDATA[ifconfig]]></category>
		<category><![CDATA[inactive]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[Omnima]]></category>
		<category><![CDATA[ping]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=242</guid>
		<description><![CDATA[I have no idea why but the Ethernet ports on the controller are, by default, inactive. After a few days of fighting with the Internet to give me something useful, I gave up and telephoned Omnima. The guy who answered the phone was seriously knowledgeable and apologised for begin &#8220;rusty&#8221; as he hadn&#8217;t used one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=242&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have no idea why but the Ethernet ports on the controller are, by default, inactive.  After a few days of fighting with the Internet to give me something useful, I gave up and telephoned Omnima.  The guy who answered the phone was seriously knowledgeable and apologised for begin &#8220;rusty&#8221; as he hadn&#8217;t used one of the boxes in the last 6&#8211;12 months.  Believe me when I say he didn&#8217;t need to apologise.</p>
<p>When the box has just booted up ifconfig returns nothing whatsoever and pinging 127.0.0.1 results in an error:</p>
<pre>
OmnimaEMB USB root fs v1.8 (info@omnima.co.uk)

root@(none):/# ifconfig
root@(none):/# ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
ping: sendto: Network is unreachable
</pre>
<p>To modify the configuration of the ports edit the file <code>/etc/config/network</code>.  Documentation for the file can be found at the <a href="http://wiki.openwrt.org/doc/uci/network">OpenWrt site</a>.  The default initial configuration is:</p>
<pre>
# Copyright (C) 2006 OpenWrt.org

config interface loopback
	option ifname	lo
	option proto	static
	option ipaddr	127.0.0.1
	option netmask	255.0.0.0

config interface lan
	option ifname	eth0
	option type 	bridge
	option proto	static
	option ipaddr	192.168.1.1
	option netmask	255.255.255.0
</pre>
<p>To activate the ports execute <code>/etc/init.d/network restart</code></p>
<pre>
root@(none):/# /etc/init.d/network restart
root@(none):/# ifconfig
eth0      Link encap:Ethernet  HWaddr 22:DA:E2:A8:86:2A
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:1043 (1.0 KiB)
          Interrupt:17 

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)

root@(none):/# ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=2.032 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=1.292 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=1.287 ms
64 bytes from 127.0.0.1: seq=3 ttl=64 time=1.465 ms
64 bytes from 127.0.0.1: seq=4 ttl=64 time=1.284 ms
^C
--- 127.0.0.1 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 1.284/1.472/2.032 ms
</pre>
<p>For me this activated the port labelled &#8220;WAN&#8221;, but I understand that this too is configurable.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/242/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/242/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/242/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=242&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/09/08/omnima-embedded-controller-activating-the-ethernet-ports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
		<item>
		<title>Omnima Embedded Controller: Day 1</title>
		<link>http://mattgwwalker.wordpress.com/2011/08/26/omnima-embedded-controller-day-1/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/08/26/omnima-embedded-controller-day-1/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 05:16:25 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Embedded controller]]></category>
		<category><![CDATA[mini-computer]]></category>
		<category><![CDATA[Omnima]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=234</guid>
		<description><![CDATA[The box I&#8217;ve been waiting for finally arrived today. The postal system lost the first one, but I am the very happy owner of an Omnima Embedded Controller. (I have since learned that there is an open source system that is very similar: the Arduino.) Having put it together&#8212;and I really loved the lack of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=234&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The box I&#8217;ve been waiting for finally arrived today.  The postal system lost the first one, but I am the very happy owner of an <a href="http://www.omnima.co.uk/">Omnima</a> <a href="http://www.omnima.co.uk/store/catalog/Embedded-controller-p-16140.html">Embedded Controller</a>.</p>
<p>(I have since learned that there is an open source system that is very similar: the <a href="http://arduino.cc/en/">Arduino</a>.)</p>
<p>Having put it together&#8212;and I really loved the lack of instructions&#8212;I have just started to learn how these things work.  Here is a summary of things I wish had been clear from the start:</p>
<ul>
<li>It&#8217;s important to buy the flash drive as an option, otherwise the system is not set up to boot from a USB disk.</li>
<li>It&#8217;s important to buy the USB-to-serial cable or you&#8217;d never know what was going on.</li>
<li>To use the serial cable: plug it in on its own (i.e. not connected to the embedded controller).  Type <code>dmesg | tail</code> to get some seriously useful information:
<pre>
[99127.316231] usb 6-2: Product: USB-Serial Controller
[99127.316233] usb 6-2: Manufacturer: Prolific Technology Inc.
[99127.321238] pl2303 6-2:1.0: pl2303 converter detected
[99127.333254] usb 6-2: pl2303 converter now attached to ttyUSB0
</pre>
<li>Now that we know what the serial port is called we can test communications.  (No need to plug in the embedded controller yet.)  Type <code>picocom -b 115200 /dev/ttyUSB0</code> which sets the <a href="http://www.omnima.co.uk/forums/index.php?s=c3cc466c5596ef6840199ab3d60c5ebb&amp;showtopic=19">specifications required for communication</a>.</li>
<p>  If it works, great, if not (a) you might need to install picocom, and (b) you might need to fix permissions or ignore all security issues and just run as root.</li>
<li>Now, unplug the USB end of the serial cable from the computer.  Plug in the other end with the engraved dot at pin 1.  Plug in the power supply.  Plug in the USB end of the serial cable.  Start picocom with the line <code>picocom -b 115200 /dev/ttyUSB0</code>.  You should now be able to watch it boot.  If you weren&#8217;t fast enough: no stress, just hit the enter key and you&#8217;ll be greeted with a command line interface.</li>
<li>You can <a href="http://squidge.sourceforge.net/gpio/">play with the LEDs</a>.  Try issuing these commands at the embedded controller&#8217;s command line:
<pre>
echo 21 &gt; /sys/class/gpio/
echo out &gt; /sys/class/gpio/gpio21/direction
echo 1 &gt; /sys/class/gpio/gpio21/value    # did that turn the LED on?
echo 0 &gt; /sys/class/gpio/gpio21/value    # what did that do?
</pre>
</ul>
<p>Cool.  Good start.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/234/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/234/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/234/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=234&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/08/26/omnima-embedded-controller-day-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
		<item>
		<title>Earthquake Load Combinations in AutoPIPE</title>
		<link>http://mattgwwalker.wordpress.com/2011/08/16/earthquake-load-combinations-in-autopipe/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/08/16/earthquake-load-combinations-in-autopipe/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 21:49:17 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AutoPIPE]]></category>
		<category><![CDATA[Earthquakes]]></category>
		<category><![CDATA[load cases]]></category>
		<category><![CDATA[modelling]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=231</guid>
		<description><![CDATA[Software that deletes stuff you&#8217;re interested in&#8212;and without warning! Oh, the joys of AutoPIPE&#8230; It is clear how to go about changing the earthquake loads in AutoPIPE (Load &#62; Static Earthquake). Ignoring the henious user-interface, it&#8217;s at least clear how to change the values per earthquake case. What is not clear are the consequences. If [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=231&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Software that deletes stuff you&#8217;re interested in&#8212;and without warning!  Oh, the joys of AutoPIPE&#8230;</p>
<p>It is clear how to go about changing the earthquake loads in AutoPIPE (Load &gt; Static Earthquake).  Ignoring the henious user-interface, it&#8217;s at least clear how to change the values per earthquake case.  What is not clear are the consequences.</p>
<p>If you add to the number of earthquake cases then you must also modify the &#8220;analysis sets&#8221; (Load &gt; Static Analysis Sets).  Select the analysis set and click Modify.  Tick the new earthquake cases for inclusion.</p>
<p>But wait there&#8217;s more!  AutoPIPE doesn&#8217;t tell you that it&#8217;s possibly just deleted a whole lot of load combinations!  Go to Tools &gt; Combinations and make sure all that you&#8217;re interested in is still there.  In my case I discovered that eight non-code combinations had been automatically deleted without warning.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/231/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=231&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/08/16/earthquake-load-combinations-in-autopipe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
		<item>
		<title>Corrosion Allowance in AutoPIPE</title>
		<link>http://mattgwwalker.wordpress.com/2011/08/14/corrosion-allowance-in-autopipe/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/08/14/corrosion-allowance-in-autopipe/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 03:48:43 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AutoPIPE]]></category>
		<category><![CDATA[corrosion allowance]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=226</guid>
		<description><![CDATA[Man, AutoPIPE has to be some of the most user-unfriendly software ever. To modify a pipe&#8217;s corrosion allowance: Modify &#62; Properties of Pipe Identifier &#62; (select identifier) &#62; Ok &#62; modify Corrosion Allow &#62; Ok. Do not try to select the pipe beforehand. If you select pipes of different sizes and use &#8220;Modify Pipe Properties [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=226&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Man, AutoPIPE has to be some of the most user-unfriendly software ever.</p>
<p>To modify a pipe&#8217;s corrosion allowance: Modify &gt; Properties of Pipe Identifier &gt; (select identifier) &gt; Ok &gt; modify Corrosion Allow &gt; Ok.</p>
<p>Do not try to select the pipe beforehand.  If you select pipes of different sizes and use &#8220;Modify Pipe Properties over Range&#8221; you&#8217;ll just get an error that won&#8217;t go away and thus you are blocked from modifying the corrosion allowance.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/226/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/226/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/226/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=226&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/08/14/corrosion-allowance-in-autopipe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
		<item>
		<title>How to join two tuples in Python</title>
		<link>http://mattgwwalker.wordpress.com/2011/02/11/how-to-join-two-tuples-in-python/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/02/11/how-to-join-two-tuples-in-python/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 21:10:24 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Programming/Development]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[join]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tuples]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=221</guid>
		<description><![CDATA[I was struggling with how to join two tuples for ages, tried searching for it, read countless tutorials on tuples in python, and then I just randomly I tried this: x+y Yup, that&#8217;s all. &#62;&#62;&#62; x = (1,2) &#62;&#62;&#62; y = (3,4) &#62;&#62;&#62; x+y (1, 2, 3, 4)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=221&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was struggling with how to join two tuples for ages, tried searching for it, read countless tutorials on tuples in python, and then I just randomly I tried this:</p>
<p><code>x+y</code></p>
<p>Yup, that&#8217;s all.<br />
<code><br />
&gt;&gt;&gt; x = (1,2)<br />
&gt;&gt;&gt; y = (3,4)<br />
&gt;&gt;&gt; x+y<br />
(1, 2, 3, 4)</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/221/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=221&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/02/11/how-to-join-two-tuples-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
		<item>
		<title>Progress bars in Python&#8217;s PyGTK</title>
		<link>http://mattgwwalker.wordpress.com/2011/02/08/progress-bars-in-pythons-pygtk/</link>
		<comments>http://mattgwwalker.wordpress.com/2011/02/08/progress-bars-in-pythons-pygtk/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 16:57:59 +0000</pubDate>
		<dc:creator>Matthew Walker</dc:creator>
				<category><![CDATA[Programming/Development]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[multi-processing]]></category>
		<category><![CDATA[multi-threading]]></category>
		<category><![CDATA[multiprocessing]]></category>
		<category><![CDATA[multithreading]]></category>
		<category><![CDATA[progress bar]]></category>
		<category><![CDATA[progressbar]]></category>
		<category><![CDATA[pygtk]]></category>

		<guid isPermaLink="false">http://mattgwwalker.wordpress.com/?p=211</guid>
		<description><![CDATA[My objective was to produce a progress bar in Python&#8217;s GTK. I found this interesting because, in my eyes, it&#8217;s not like the rest of GTK, where the best path is fairly clearly laid out. A progress bar is tricky because it immediately introduces the idea that something is going to take a long time. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=211&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My objective was to produce a progress bar in Python&#8217;s GTK.  I found this interesting because, in my eyes, it&#8217;s not like the rest of GTK, where the best path is fairly clearly laid out.  </p>
<p>A progress bar is tricky because it immediately introduces the idea that something is going to take a long time.  If this thing were to be run as a standard on-click-do-this type of function, the interface would freeze up.  That wouldn&#8217;t be ok.  How is this fixed?  By using either multi-threading or multi-processing.</p>
<p>(Ok, so there&#8217;s another option, but the idea of doing little bits of work and returning control to the interface, and then going back to doing more work&#8230; it&#8217;s just not attractive to me.  One reason is that it binds the program&#8217;s functionality to the program&#8217;s interface, and that&#8217;s just not a good thing.)</p>
<p>For the work I&#8217;m doing, I prefer the multi-processing option.  The Art of Unix Programming gives a good summary of the differences [1].  Multi-processing in Python has been made really easy thanks to the multiprocessing library.  Unfortunately however, I still found it necessary to use multi-threading as well, in order to watch for when data arrives from the worker process.</p>
<p>To summarise the system:</p>
<ul>
<li>The main work is done within a separate process.  Updates are shared with the calling process via a multiprocessing.Queue.  A fraction is placed on the queue to indicate how much of the work has been complete.  Further messages can be placed on the queue to indicate what will be done next or what has just been done.</li>
<li>The calling process creates a thread to listen for any data being placed on the queue.  When a fraction is read from the queue, the observing thread emits an &#8220;updated&#8221; signal.  Depending on the queue data, the observer may also emit message_event, finished, or errored signals.</li>
<li>A ProgressBar is attached to an Observer to allow graphical feedback of progress.</li>
<li>And when all that is set up, we start the observer thread and the worker process</li>
<li>There is also a CombinedObserver that summarises multiple Observers</li>
</ul>
<p>To use the system to create one worker whose progress is monitored:<br />
<pre class="brush: python;">
worker1 = WorkerExample() 
process1 = Process(worker1.go, ())
observer1 = process1.getObserver()
window1 = ProgressBarWindow(observer1, &quot;Workers One's progress&quot;)
process1.start()
gtk.main()
process1.join()
</pre></p>
<p>Finally, any comments or recommendations you may have would be gratefully received.</p>
<p>Update: <a href="http://aruiz.typepad.com/siliconisland/2006/04/threads_on_pygt.html">Threads on PyGTK</a> discusses progress bars and I&#8217;ve learnt that my approach has a flaw in that I should call gtk.threads_enter() and gtk.threads_leave() before changing the progress bar.  I also found a <a href="http://blogs.operationaldynamics.com/andrew/software/gnome-desktop/gtk-thread-awareness.html">nice explanation of why</a>.</p>
<p>The system, including test and example code:<br />
<pre class="brush: python;">
#!/usr/bin/env python

import sys #exit
import gobject
import pygtk
pygtk.require('2.0')
import gtk
import multiprocessing
import threading
import time

gtk.gdk.threads_init()


# Any time you connect to any of these signals, they should be
# protected with a threading.Lock or similar.
class ObserverBase(gobject.GObject):
    __gsignals__ = {
        'message_event' : (gobject.SIGNAL_RUN_LAST,
                           gobject.TYPE_NONE,
                           (gobject.TYPE_STRING,)),
        'updated' : (gobject.SIGNAL_RUN_LAST,
                     gobject.TYPE_NONE,
                     (gobject.TYPE_FLOAT,)),
        'finished': (gobject.SIGNAL_RUN_LAST,
                     gobject.TYPE_NONE,
                     ()),
        'errored': (gobject.SIGNAL_RUN_LAST,
                     gobject.TYPE_NONE,
                     ())
        }

    def __init__(self):
        gobject.GObject.__init__(self)

gobject.type_register(ObserverBase)

class Observer(ObserverBase):
    def __init__(self, queue):
        ObserverBase.__init__(self)
        self.queue = queue

    def start(self):
        # Create new thread to do the listening
        self.thread = threading.Thread(target=self.listen, args=())
        self.thread.start()

    def join(self):
        self.thread.join()

    def listen(self):
        while True:
            # Listen for results on the queue and process them accordingly
            print &quot;Observer is waiting for data&quot;
            data = self.queue.get()
            print &quot;Observer received: &quot;,data
            dataType = type(data).__name__
            if dataType==&quot;bool&quot; and data==True:
                self.emit('finished')
                return
            if dataType==&quot;bool&quot; and data==False:
                self.emit('errored')
                return
            elif dataType==&quot;str&quot;:
                self.emit('message_event', data)
            elif dataType==&quot;float&quot;:
                self.emit('updated', data)
            else:
                raise RuntimeError(&quot;Queue had an unknown data type ('&quot;+dataType+&quot;') with value '&quot;+str(data)+&quot;'&quot;)

gobject.type_register(Observer)

        
class Process(gobject.GObject):
    __gsignals__ = {
        'starting': (gobject.SIGNAL_RUN_LAST,
                     gobject.TYPE_NONE,
                     ()),
        'joined': (gobject.SIGNAL_RUN_LAST,
                     gobject.TYPE_NONE,
                     ())
        }

    def __init__(self, function, arguments):
        gobject.GObject.__init__(self)
        # Create queue
        self.queue = multiprocessing.Queue()

        # Create process
        if arguments==(): arguments=(self.queue,)
        self.process = multiprocessing.Process(target=function, args=arguments)

        # Create observer
        self.observer = Observer(self.queue)


    def getObserver(self):
        return self.observer

    def start(self):
        # Starting observer
        self.emit(&quot;starting&quot;)
        print &quot;starting observer&quot;
        self.observer.start()
        # Start process
        print &quot;starting process&quot;
        self.process.start()

    def join(self):
        # Clean up after process
        print &quot;cleaning up after process&quot;
        self.process.join()
        self.emit(&quot;joined&quot;)
        # Clean up after observer
        print &quot;cleaning up after observer&quot;
        self.queue.put(False) # If the false is ever read, it's an error
        self.observer.join()
        # Clean up queue
        #self.queue.close()
        

gobject.type_register(Process)




class CombinedObserver(ObserverBase):
    def __init__(self, observers, weights=None):
        ObserverBase.__init__(self)
        self.observers = observers
        numObservers = len(observers)
        if weights==None:
            self.weights = [1 for i in range(numObservers)]
        else:
            self.weights = weights
            
        sum_weights = sum(self.weights)
        self.weights = [float(w)/sum_weights for w in self.weights]
        print &quot;weights = &quot;,self.weights

        index = 0
        for observer in self.observers:
            #observer.connect(&quot;message_event&quot;, onMessageReceived, index)
            observer.connect(&quot;updated&quot;, self.onUpdate, index)
            observer.connect(&quot;finished&quot;, self.onFinished, index)
            observer.connect(&quot;errored&quot;, self.onErrored, index)
            index = index+1

        self.fractions = [0 for i in range(numObservers)]
        self.finished = [False for i in range(numObservers)]
        self.errored = [False for i in range(numObservers)]
        self.lock = threading.RLock()

    def onUpdate(self, widget, fraction, index):
        self.lock.acquire()
        self.fractions[index] = fraction * self.weights[index]
        self.emit(&quot;updated&quot;, sum(self.fractions))
        self.lock.release()
                                   
    def onFinished(self, widget, index):
        self.lock.acquire()
        self.finished[index] = True
        if all(self.finished):
            self.emit(&quot;finished&quot;)
        self.lock.release()

    def onErrored(self, widget, index):
        self.lock.acquire()
        self.errored[index] = True
        self.emit(&quot;errored&quot;)
        self.lock.release()
        


gobject.type_register(CombinedObserver)


# A ProgressWorker is responsible for (a) getting the job done and (b)
# reporting progress.  Progress is reported via the queue.  Fractions
# (from 0 to 1) indicate the proportion of the job that is finished.
# Strings may indicate what has been done or what is about to be done.
# The boolean 'True' is placed on the queue when the job is finished.
class ProgressWorker():
    def getResult(self):
        return None

    def setQueue(self, queue):
        self.queue = queue

    def go(self):
        raise RuntimeError(&quot;Worker.go() has not been overridden&quot;)


class WorkerExample(ProgressWorker):
    def __init__(self):
        #Worker.__init__(self)
        manager = multiprocessing.Manager()
        self.result = manager.list()

    def getResult(self):
        return self.result

    def go(self, queue):
        self.setQueue(queue)
        print &quot;The worker has started doing some work (counting from 0 to 9)&quot;
        for i in range(10):
            self.queue.put(&quot;working on step &quot;+str(i)+&quot;...&quot;)
            proportion = (float(i)+1)/10
            time.sleep(0.75)
            self.queue.put(proportion)
        self.queue.put(&quot;done.&quot;)
        self.queue.put(1.0)
        self.queue.put(True)
        print &quot;The worker has finished.&quot;
        self.result.append(&quot;The the work has been finished and the result isn't 42.&quot;)




class ProgressBar(gobject.GObject):
    __gsignals__ = {
        'updated' : (gobject.SIGNAL_RUN_LAST,
                     gobject.TYPE_NONE,
                     (gobject.TYPE_FLOAT,)),
        'finished': (gobject.SIGNAL_RUN_LAST,
                     gobject.TYPE_NONE,
                     ())
        }

    def __init__(self, observer):
        gobject.GObject.__init__(self)
        self.observer = observer
        self.observer.connect(&quot;updated&quot;,self.displayUpdate)
        self.observer.connect(&quot;message_event&quot;,self.displayMessage)
        self.observer.connect(&quot;finished&quot;,self.finish)
        self.progress = gtk.ProgressBar()
        self.progress.connect(&quot;destroy&quot;, self.destroy)
        self.process=None
        self.lock = threading.RLock()

    def displayUpdate(self, obj, fraction):
        self.lock.acquire()
        self.progress.set_fraction(fraction)
        self.emit(&quot;updated&quot;, fraction)
        self.lock.release()

    def displayMessage(self, obj, text):
        self.lock.acquire()
        self.progress.set_text(text)
        self.lock.release()

    def finish(self, obj, data=None):
        self.emit(&quot;finished&quot;)

    def destroy(self, widget, data=None):
        print &quot;Destroying&quot;
        if self.process==None:
            return
        self.queue.put(&quot;finished&quot;)
        self.process.join()
        self.thread.join()

        

gobject.type_register(ProgressBar)


class ProgressBarWindow:
    def __init__(self, observer, title):
        self.progressBar = ProgressBar(observer)
        self.progressBar.connect(&quot;finished&quot;, self.done)
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_border_width(10)
        window.set_title(title)
        window.add(self.progressBar.progress)
        window.show_all()
        window.connect(&quot;destroy&quot;, self.destroy)

    def main(self):
        gtk.main()

    def done(self, widget, data=None):
        #self.destroy()
        print &quot;FINISHED!&quot;

    def destroy(self, widget=None, data=None):
        gtk.main_quit()



# Test
if __name__ == '__main__':
    # Three workers
    worker1 = WorkerExample()
    process1 = Process(worker1.go, ())
    observer1 = process1.getObserver()

    worker2 = WorkerExample()
    process2 = Process(worker2.go, ())
    observer2 = process2.getObserver()

    worker3 = WorkerExample()
    process3 = Process(worker3.go, ())
    observer3 = process3.getObserver()

    combo = CombinedObserver([observer1, observer2, observer3])

    window0 = ProgressBarWindow(combo, &quot;Workers' progress&quot;)
    window1 = ProgressBarWindow(observer1, &quot;Workers One's progress&quot;)
    window2 = ProgressBarWindow(observer2, &quot;Workers Two's progress&quot;)
    window3 = ProgressBarWindow(observer3, &quot;Workers Three's progress&quot;)

    process1.start()
    #time.sleep(0.1)
    process2.start()
    #time.sleep(0.1)
    process3.start()
    gtk.main()
    process1.join()
    process2.join()
    process3.join()
    print &quot;finished&quot;
    sys.exit()

    # Two workers
    worker1 = WorkerExample()
    process1 = Process(worker1.go, ())
    observer1 = process1.getObserver()

    worker2 = WorkerExample()
    process2 = Process(worker2.go, ())
    observer2 = process2.getObserver()

    combo = CombinedObserver([observer1, observer2])

    window0 = ProgressBarWindow(combo, &quot;Workers' progress&quot;)
    window1 = ProgressBarWindow(observer1, &quot;Workers One's progress&quot;)
    window2 = ProgressBarWindow(observer2, &quot;Workers Two's progress&quot;)

    process1.start()
    time.sleep(0.1)
    process2.start()
    gtk.main()
    process1.join()
    process2.join()
    print &quot;finished&quot;
    sys.exit()

    # One worker
    print &quot;creating worker1&quot;
    worker1 = WorkerExample() # The task to do, carefully constructed to give feedback via a queue
    print &quot;creating process1&quot;
    process1 = Process(worker1.go, ()) # Responsible for looking after the worker: supplying the queue, setting up the observer, starting process
    observer1 = process1.getObserver() # An observer of the worker's progress that listens to the queue
    window1 = ProgressBarWindow(observer1, &quot;Workers One's progress&quot;) # A display of the progress, connected to the observer
    process1.start()
    gtk.main()
    process1.join()
    print &quot;result = &quot;, worker1.result
    print &quot;finished&quot;
    sys.exit()
</pre></p>
<p>[1] The Art of Unix Programming.  <a href="http://www.faqs.org/docs/artu/ch07s03.html#id2923889">Section &#8220;Threads: Threat or Menace?&#8221;</a> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgwwalker.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgwwalker.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgwwalker.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgwwalker.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgwwalker.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgwwalker.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgwwalker.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgwwalker.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgwwalker.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgwwalker.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgwwalker.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgwwalker.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgwwalker.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgwwalker.wordpress.com/211/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgwwalker.wordpress.com&amp;blog=9721907&amp;post=211&amp;subd=mattgwwalker&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgwwalker.wordpress.com/2011/02/08/progress-bars-in-pythons-pygtk/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/592327d094bf6815bcea9c4788228c34?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mattgwwalker</media:title>
		</media:content>
	</item>
	</channel>
</rss>
