<?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"
	>

<channel>
	<title>TDI Web Log</title>
	<atom:link href="http://blog.tempusdictum.com/index.php/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.tempusdictum.com</link>
	<description>Cognitive Tools</description>
	<pubDate>Thu, 11 Mar 2010 22:56:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Reprogramming your avr-usb device using atmel&#8217;s built in bootloader</title>
		<link>http://blog.tempusdictum.com/index.php/don/electronics/avr-development/reprogramming-your-avr-usb-device-using-atmels-built-in-bootloader</link>
		<comments>http://blog.tempusdictum.com/index.php/don/electronics/avr-development/reprogramming-your-avr-usb-device-using-atmels-built-in-bootloader#comments</comments>
		<pubDate>Fri, 05 Mar 2010 21:57:14 +0000</pubDate>
		<dc:creator>don</dc:creator>
		
		<category><![CDATA[Avr development]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=75</guid>
		<description><![CDATA[Getting code onto the MidiMonster or Benito device.





Midi Monster Button Locations.




Benito 7g Switch Lcations






Benito 2010 Switch Locations




Benito Without Buttons





All of the code on the Benito and MidiMonster devices is open source and references an open source library called the Lightweight Usb For Avr (lufa). Getting the code compiled and onto the device requires a few [...]]]></description>
			<content:encoded><![CDATA[<h3>Getting code onto the MidiMonster or Benito device.</h3>
<table border="0">
<tbody>
<tr>
<td>
<div class="image"><a href="http://www.flickr.com/photos/7175086@N05/4404887952/"><img src="http://farm3.static.flickr.com/2717/4404887952_d72836dabc_m.jpg" alt="Midi Monster Button Locations." width="240" height="180" /></a></p>
<div>Midi Monster Button Locations.</div>
</div>
</td>
<td>
<div class="image"><a href="http://www.flickr.com/photos/7175086@N05/4404887950/in/photostream/"><img src="http://farm5.static.flickr.com/4068/4404887950_8b951295db_m.jpg" alt="Benito 7g Switch Positions." width="240" height="180" /></a></p>
<div>Benito 7g Switch Lcations</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="image"><a href="http://www.flickr.com/photos/7175086@N05/4404887938/in/photostream/"><img src="http://farm3.static.flickr.com/2752/4404887938_92aa8c439b_m.jpg" alt="Benito 2010 Switch Locations" width="240" height="180" /></a></p>
<div>Benito 2010 Switch Locations</div>
</div>
</td>
<td>
<div class="image"><a href="http://www.flickr.com/photos/7175086@N05/4404887926/in/photostream/"><img title="Benito Without Buttons." src="http://farm5.static.flickr.com/4066/4404887926_a264eca548_m.jpg" alt="Benito Without Buttons." width="240" height="180" /></a></p>
<div>Benito Without Buttons</div>
</div>
</td>
</tr>
</tbody>
</table>
<p>All of the code on the Benito and MidiMonster devices is open source and references an open source library called the Lightweight Usb For Avr (lufa). Getting the code compiled and onto the device requires a few other open source tools.</p>
<h3>AVR-GCC</h3>
<p>The most current and stable release of the toochain for the AVR has untill recently been maintained by Eric Wedddington and released as WinAvr (<a href="http://sourceforge.net/projects/winavr/" target="_blank">http://sourceforge.net/projects/winavr/</a>) Winaver integrates nicely into atmels avr studio <a href="http://" target="_blank">http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=2725</a> and I reccomend that you get both if you are running windows. Each Winavr Release is closely followed by objective developments CrossPack for avr <a href="http://www.obdev.at/products/crosspack/index.html" target="_blank">http://www.obdev.at/products/crosspack/index.html</a> and a <a href="http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;t=42631" target="_blank">script for building the current toolchain on linux</a> which is hosted by AvrFreaks at present there is also a debian package that was put out last month <a href="http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;t=90172" target="_blank">http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;t=90172</a></p>
<h3>HWB? DFU?</h3>
<p>Most Atmel &#8220;atmega&#8221; devices have a pin dedicated to determining whether or not the device goes into the bootloader depending on the devices flag settings. This pin is labled HWB (for hardware boot) on most of  the datasheets. The usb avr family has this mode set up by default. When you hold the hwb pin low and reset the device it goes into the bootloader. On these devices the built in bootloader uses a usb device class called the Device Firmware Uploader (DFU). Atmel provides a tool called flip for programming DFU devices on  windows and linux. There is an open source programmer called dfu-programmer <a href="http://dfu-programmer.sourceforge.net/" target="_blank">http://dfu-programmer.sourceforge.net/</a></p>
<h4>That other guys stuff.</h4>
<p>Those of you who have worked with the teensy boards from paul stoffregon will notice some subtle differences. Paul wrote his own (closed source) bootloader rather than use the bootloader tha comes installed on the chips. Then he uses a hardware trick similar to the auto reset hack to make a single button manipulate both the reset and the hwb pins to put his boards into the bootloader. I didnt feel that either the two button arrangement or the builtin bootloaders were broken so I like most people working with these chips dont fix them.</p>
<h4>Using the dfu-programmer</h4>
<p>All of the programs in Dean Cameras Lightweight Usb for Avr have a &#8220;dfu&#8221; target. Once you have the target into the DFU mode you can simply</p>
<pre>$make dfu</pre>
<p>This will cause the dfu-programmer to erase the flash reprogramm it with a new hex file and restart the chip. You can also do this manually with the following commands</p>
<pre>$dfu-programmer atmega32u2 erase
$dfu-programmer atmega32u2 flash mycode.hex
$dfu-programmer atmega32u2 start</pre>
<p>This will cause the dfu-programmer to erase the flash reprogramm it with a new hex file and restart the chip.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/don/electronics/avr-development/reprogramming-your-avr-usb-device-using-atmels-built-in-bootloader/feed</wfw:commentRss>
		</item>
		<item>
		<title>In Silico Liver port to MASON</title>
		<link>http://blog.tempusdictum.com/index.php/gepr/uncategorized/in-silico-liver-port-to-mason</link>
		<comments>http://blog.tempusdictum.com/index.php/gepr/uncategorized/in-silico-liver-port-to-mason#comments</comments>
		<pubDate>Tue, 23 Feb 2010 18:40:14 +0000</pubDate>
		<dc:creator>gepr</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[modeling and simulation]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=72</guid>
		<description><![CDATA[I set this task aside awhile back.  When I returned to it, we had moved the source repository to a different machine.  I had lots of changes in my local sandbox.  Several of the prerequisite libraries had been upgraded.  Etc.  After doing all the catch-up work and checking it in, [...]]]></description>
			<content:encoded><![CDATA[<p>I set this task aside awhile back.  When I returned to it, we had moved the source repository to a different machine.  I had lots of changes in my local sandbox.  Several of the prerequisite libraries had been upgraded.  Etc.  After doing all the catch-up work and checking it in, however, it compiled and ran right out of the box!  I&#8217;m always surprised when that sort of thing happens.</p>
<p><a href="http://blog.tempusdictum.com/wp-content/uploads/2010/02/screenshot1.png"><img class="aligncenter size-full wp-image-74" title="ISLJ" src="http://blog.tempusdictum.com/wp-content/uploads/2010/02/screenshot1.png" alt="Way early ISL in MASON mock-up." width="500" height="289" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/gepr/uncategorized/in-silico-liver-port-to-mason/feed</wfw:commentRss>
		</item>
		<item>
		<title>Windows Vista using a CUPS PDF printer hosted on Debian</title>
		<link>http://blog.tempusdictum.com/index.php/gepr/uncategorized/windows-vista-using-a-cups-pdf-printer-hosted-on-debian</link>
		<comments>http://blog.tempusdictum.com/index.php/gepr/uncategorized/windows-vista-using-a-cups-pdf-printer-hosted-on-debian#comments</comments>
		<pubDate>Sat, 13 Feb 2010 00:21:51 +0000</pubDate>
		<dc:creator>gepr</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=71</guid>
		<description><![CDATA[So, every time I upgrade my system, it seems like my printers break.  I don&#8217;t know if it&#8217;s bad management of the cups debian packages, the peculiarity of windows, or my own incompetence.  The breaks have wildly varying symptoms.  So, I haven&#8217;t seen a pattern in them that allows me to fix things gracefully.  Sometimes [...]]]></description>
			<content:encoded><![CDATA[<p>So, every time I upgrade my system, it seems like my printers break.  I don&#8217;t know if it&#8217;s bad management of the cups debian packages, the peculiarity of windows, or my own incompetence.  The breaks have wildly varying symptoms.  So, I haven&#8217;t seen a pattern in them that allows me to fix things gracefully.  Sometimes Samba is to blame.  Sometimes CUPS (-PDF) is to blame.  And sometimes Windows is to blame.  Well, when I upgraded from Lenny to Squeeze awhile back, of course it broke my virtual PDF printer that I use to generate electronic invoices.  When I&#8217;d try to connect to the printer (as configured in Lenny), I got the following error:</p>
<pre><strong><span style="background-color: #000000; color: #ff6600;">Windows cannot connect to the printer. Operation
could not be completed (error 0&#215;0000000d).</span></strong></pre>
<p>(No, it wasn&#8217;t in those colors or with that background&#8230; but I figured I&#8217;d try to find a way to make you, dear reader, feel as annoyed as I felt when I saw the error.)  Anyway, with such a wonderfully informative error, I didn&#8217;t know quite where to turn.  The logs (cups, samba, auth.log, syslog, etc.) on the server gave no indication that anyone had tried to connect.  And I could browse the other shares from the vista machine nicely and those connections did show up in the logs.  So, I had a strong indicator that the problem was NOT my upgrade from Lenny to Squeeze.  But, being the stubborn idiot that I am, I started fiddling around with the printer and samba configs anyway&#8230;. which lead nowhere, of course.  The upside is that I am just a smidgeon more familiar with cups and samba. [sigh]</p>
<p>When I finally typed the error into a search engine, I <a href="http://social.technet.microsoft.com/Forums/en-US/itprovistaprinting/thread/d02718d8-cf5d-45de-9206-46714a549ee0/">found the answer provided by some participants of Microsoft TechNet</a>, which I repeat here for posterity:</p>
<pre>
From: AHarsent

I've seen this problem with a few printers now, not
consistantly[sic] between any particular makes or
models. However, I have found a consistant[sic]
fix to connect to any network printer from vista:

Run a command prompt and type the following:

   net use LPT2: \\servername\printer

This sets up a behind-the-scenes connection to
the printer.

Then go through the add printer wizard, choose to
add a local printer, and choose port LPT2&#8230; It will
probably ask for a printer driver, and you can just
choose whatever XP driver you might have been using
before. The printer is then installed without any errors,
and works just fine.
</pre>
<p>Of course, since I&#8217;m using CUPS-PDF, I don&#8217;t have a printer driver.  I just use the Generic MS Publisher Imagesetter, which seems to work nicely.  And now that I&#8217;ve made the right sacrifices to the right gods, I&#8217;m back to being able to generate PDFs from any program on the windows machine.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/gepr/uncategorized/windows-vista-using-a-cups-pdf-printer-hosted-on-debian/feed</wfw:commentRss>
		</item>
		<item>
		<title>Acid Testing Your Time Machine Backups</title>
		<link>http://blog.tempusdictum.com/index.php/don/mac-development/acid-testing-your-time-machine-backups</link>
		<comments>http://blog.tempusdictum.com/index.php/don/mac-development/acid-testing-your-time-machine-backups#comments</comments>
		<pubDate>Thu, 04 Feb 2010 23:31:21 +0000</pubDate>
		<dc:creator>don</dc:creator>
		
		<category><![CDATA[Mac Development]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=70</guid>
		<description><![CDATA[
Disks Die, Laptops break, Bags are Stolen.
It&#8217;s more or less a fact of life,
In the 4 year  process of  transitioning from a noisy sun E-250 in the garage to something that could actually be in the same room with you I arrived at the above network arrangement.
Most of the my data is hosted [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://farm5.static.flickr.com/4020/4331153338_cd3ce93100_o.jpg"><img class="alignnone" src="http://farm5.static.flickr.com/4020/4331153338_cd3ce93100_o.jpg" alt="" width="640" height="480" /></a></p>
<h3>Disks Die, Laptops break, Bags are Stolen.</h3>
<p>It&#8217;s more or less a fact of life,</p>
<p>In the 4 year  process of  transitioning from a noisy sun E-250 in the garage to something that could actually be in the same room with you I arrived at the above network arrangement.</p>
<p>Most of the my data is hosted by a central server and when I had more systems all of the home directories were NFS mounted (<em>which is a major PITA on OSX</em>). In the last hear I have worked primarily on my MacBook, occasionally syncing my projects with the file server. After migrating to leopard I purchased a 1 Terabyte external disk and backed up both the file server and my laptop using &#8220;Time Machine&#8221;. As I worked more and more on the laptop I did less and less syncing of the work to the file server. The thing about time machine is that its thoughtless. Set it up and as long as you get your laptop home and leave it on for a few hours and it<em><strong> should </strong></em>keep your work safe for you.</p>
<h3><strong>Two weeks ago My Bag was stolen.</strong></h3>
<p>On top of the work I had actively been doing I lost two active sketchbooks and in the end this loss is probably the most painful. Since I couldn&#8217;t immediately restore the data using the process described below, I spent much of last week recreating the designs for this months workshops. Once the critical work was done I turned to see what I could recover.  I had used time machine to restore a couple of files I had foobared but I had never had to restore all 270G of data and applications. My Intel Imac did not have enough disk nor did it have most of the software. So I bought a 1T disk from <a href="http://www.otcpdx.com/" target="_blank">Old Town Computers</a> and &#8220;<a href="http://www.bombich.com/" target="_blank">CarbonCopyCloner</a>&#8220;ed a bootable operating system onto it and put it into my Intel Imac (Ernesto).</p>
<h3>WHERE&#8217;S MY BACKUP?!?</h3>
<p>After googling around I found that I was supposed to restore my files using the &#8220;Migration Assistant&#8221; tool. I had used migration assistant to move users and applications to new systems but never to restore files. When I first tried the migration assistant I mounted the disk remotely but I couldn&#8217;t see the backup. So I moved the disk to the target machine. Even then I only saw the option of restoring the server and not my laptop.<br />
Panic set in until I found a file named with my laptops name and a .sparsebundle extension. Right clicking on this lets me open it with the appropriate mounting utility. But&#8230;. Not until it had checked the file system. Walking away and doing something else for a few hours let me come back to the image mounted. When I ran the migration assistant again the option of restoring the laptop was there.</p>
<h3>SUCCESS!</h3>
<p>Starting the restore process and going to sleep I woke to find that it had successfully restored all of my data and applications! I was only out the extra time on the designs and the actual property.</p>
<h3>FAIURE.</h3>
<p>Now all of my active work was on a disk which was large enough to also contain the rest of my images/music/video and web content which had been kept on the file server. Since I could see the fileserver&#8217;s backup and I was so happy with my success I tried then to restore the file server data.</p>
<p>Mounting your home directories on external disks on OSX is a lot like mounting them remotely. It just plain sucks. Half the time if I made any changes in the disks connected to the file server it would mount them in a different place. Then when you logged in it would create a new mount point and empty directory and you could not remount the disk where it was supposed to be until you removed the new directory.</p>
<p>When I restored the file server user I had few options. I could restore the user (giving an estimated size of like 20 meg , not the  &gt;400G I expected) and on the next screen  I could restore the file system at the top level directory. This did not show me enough data to represent the data directory either. I could also have restored the entire system and then re-restored the Intel files over it but I really didn&#8217;t want to deal with the mess.</p>
<h3>So I punted.</h3>
<p>I just plugged the file server disk in and dragged my home folder to the new disk. I will probably test the restore process to the file server with the external disk attached to make sure the data is recoverable on that system. Once this is done I will reformat the time machine disk for future backups and send the file servers external disk to another state. In the mean time I will rest better knowing that my time machine backups actually work transparently while I work.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/don/mac-development/acid-testing-your-time-machine-backups/feed</wfw:commentRss>
		</item>
		<item>
		<title>Dual coordinate plots in R</title>
		<link>http://blog.tempusdictum.com/index.php/gepr/uncategorized/dual-coordinate-plots-in-r</link>
		<comments>http://blog.tempusdictum.com/index.php/gepr/uncategorized/dual-coordinate-plots-in-r#comments</comments>
		<pubDate>Tue, 12 Jan 2010 01:16:41 +0000</pubDate>
		<dc:creator>gepr</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=68</guid>
		<description><![CDATA[The default plot functions in R don&#8217;t seem to facilitate plotting two dependent variables using different scales on the same plot, against the same independent axis.  But it&#8217;s not that difficult, as I learned from: Jim Lemon&#8217;s &#8220;Kickstarting R&#8221;.  But even his example isn&#8217;t simple enough for me.  So, I generated this:

par(mar=c(5,4,4,4))
plot(1:11, [...]]]></description>
			<content:encoded><![CDATA[<p>The default plot functions in R don&#8217;t seem to facilitate plotting two dependent variables using different scales on the same plot, against the same independent axis.  But it&#8217;s not that difficult, as I learned from: <a href="http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_addat.html">Jim Lemon&#8217;s &#8220;Kickstarting R&#8221;</a>.  But even his example isn&#8217;t simple enough for me.  So, I generated this:</p>
<pre>
par(mar=c(5,4,4,4))
plot(1:11, 1:11, ylab="", col="green", axes=F)
axis(1,1:11)
axis(2,1:11, col="green")
par(new=T)
plot(1:11, 5:-5, ylab="", axes=FALSE, pch=3, col="blue")
axis(4, -5:5, col="blue")
par(new=F)
</pre>
<p>which produces this:<br />
<a href='http://blog.tempusdictum.com/wp-content/uploads/2010/01/dual-coordinates.png'><img src="http://blog.tempusdictum.com/wp-content/uploads/2010/01/dual-coordinates-285x300.png" alt="" title="dual-coordinates-in-R" width="285" height="300" class="alignnone size-medium wp-image-69" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/gepr/uncategorized/dual-coordinate-plots-in-r/feed</wfw:commentRss>
		</item>
		<item>
		<title>Postgres + Ruby + OSX=Multi Architectural Hell</title>
		<link>http://blog.tempusdictum.com/index.php/don/mac-development/postgres-ruby-osxmulti-architectural-hell</link>
		<comments>http://blog.tempusdictum.com/index.php/don/mac-development/postgres-ruby-osxmulti-architectural-hell#comments</comments>
		<pubDate>Wed, 30 Dec 2009 02:28:59 +0000</pubDate>
		<dc:creator>don</dc:creator>
		
		<category><![CDATA[Mac Development]]></category>

		<category><![CDATA[osx rails ruby fubar]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=67</guid>
		<description><![CDATA[I was finally able to get my ruby/rails environment setup with my database of choice.
It wasnt easy as postgres will not build with more than one architecture at a time, I  had gone through similar hell the last time I tried to build anything on OSX that had to compile against libraries made for [...]]]></description>
			<content:encoded><![CDATA[<p>I was finally able to get my ruby/rails environment setup with my database of choice.</p>
<p>It wasnt easy as postgres will not build with more than one architecture at a time, I  had gone through similar hell the last time I tried to build anything on OSX that had to compile against libraries made for different architectures. Fortunately the solution was relatively simple.</p>
<p>My database is running 64 bit and I use it for many other applications that are compiled against either multiple architectures including 64bit but also some which are 64 bit only.</p>
<p>Ruby on the other hand is compled for 32 bit which worked flawlessly on mysql and most of the other gems i installed when I got to the postgres it puked in weird ways and when I tried every third solution on the net it was always the same.</p>
<pre style="padding-left: 30px;">Bash-3.2# gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.</pre>
<p>The bottom line from one of the only success stories that I found on the net was that you either built everything 64bit or nothing. <i>Easy enough if you want to build all of your dependencies by yourself.</i> The whole point of gems is to have the tools work for you. I wasnt really able to figure this out in the web full of people beating their heads on the same problem each harder than the other and each reaching the same it doesnt work conclusion but I had the fortune of getting completely away from the web long enough to realize that only the client and libraries needed to match the architecture and since all interaction between rails and the database went through a socket the architecture of the client didn&#8217;t have to be the same as the database.</p>
<p>so going back to my postgres source tree i did a</p>
<pre style="padding-left: 30px;">...postgresql-8.3.6# make distclean</pre>
<p>and then reconfigured the database using the prefix /usr/local32</p>
<pre style="padding-left: 60px;">..postgresql-8.3.6# ARCHFLAGS='-arch i386' ./configure --prefix=/usr/local32/</pre>
<p>Then I just had to tel ruby/gem to  use the 32 bit libraries. Since ruby uses pg_config I made sure that the 32bit version is in the path first.</p>
<pre style="padding-left: 60px;"># PATH=/usr/local32/bin/:$PATH ARCHFLAGS='-arch i386' \
gem install pg  -- --with-pgsql-dir=/usr/local32/</pre>
<p>And we are off but my god what at PITA.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/don/mac-development/postgres-ruby-osxmulti-architectural-hell/feed</wfw:commentRss>
		</item>
		<item>
		<title>p4_error: Could not gethostbyname for host</title>
		<link>http://blog.tempusdictum.com/index.php/gepr/uncategorized/p4_error-could-not-gethostbyname-for-host</link>
		<comments>http://blog.tempusdictum.com/index.php/gepr/uncategorized/p4_error-could-not-gethostbyname-for-host#comments</comments>
		<pubDate>Wed, 02 Dec 2009 00:13:52 +0000</pubDate>
		<dc:creator>gepr</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=66</guid>
		<description><![CDATA[For awhile now, we&#8217;ve been unable to run using the &#8220;-nolocal&#8221; flag to the mpirun command in order to execute our simulation across the slave nodes without also treating the master as a slave.  When I would run with:
$ mpirun -nolocal -np 7 ./simulation 
 I would see an error like the following:
p0_10460: p4_error: [...]]]></description>
			<content:encoded><![CDATA[<p>For awhile now, we&#8217;ve been unable to run using the &#8220;-nolocal&#8221; flag to the mpirun command in order to execute our simulation across the slave nodes without also treating the master as a slave.  When I would run with:</p>
<pre>$ mpirun -nolocal -np 7 ./simulation </pre>
<p> I would see an error like the following:
<pre>p0_10460: p4_error: Could not gethostbyname for host <i>hostname</i>; may be. invalid name</pre>
<p>Being lazy, I spent quite a bit of time trawling the intertubes looking for a canned solution and found many dead-ends talking about the resolver, nsswitch.com, etc/hosts, etc.  So, I finally sighed and reluctantly pulled out my programming hat and wrote the following:</p>
<pre>
#include &lt;netdb.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;unistd.h&gt;
#include &lt;malloc.h&gt;
int main(int argc, char *argv[])
{
  char *user_host = calloc(32, sizeof(char));
  int error = gethostname(user_host,32);
  if (error != 0) {
    printf(&#8221;gethostname failed with error %d\n&#8221;, error);
    return error;
  } else
    printf(&#8221;user_host = %s\n&#8221;, user_host);

  struct addrinfo *res0, hint;
  memset(&#038;hint, 0, sizeof(hint));
  hint.ai_family = PF_UNSPEC;
  hint.ai_flags = AI_CANONNAME;
  error = getaddrinfo(user_host, NULL, &#038;hint, &#038;res0);
  if (error != 0) {
    printf(&#8221;getaddrinfo failed with error %d.\n&#8221;, error);
  }

  struct hostent *he;
  he = gethostbyname(user_host);
  if (!he)
    printf(&#8221;gethostbyname(gethostname()) failed\n&#8221;);
  else
    printf(&#8221;gethostbyname(gethostname()) = %s\n&#8221;, he->h_name);

  free(user_host);
  user_host = &#8220;hostname&#8221;;
  he = gethostbyname(user_host);
  if (!he)
    printf(&#8221;hostname(/*hardcoded*/ \&#8221;hostname\&#8221;) failed\n&#8221;);
  else
    printf(&#8221;hostname(/*hardcoded*/ \&#8221;hostname\&#8221;) = %s\n&#8221;, he->h_name);
  return 0;
}
</pre>
<p></code></p>
<p>And that showed me that the string returned by gethostname() was flawed in some way&#8230; some insidiously evil and occult way that doesn&#8217;t show up on the terminal screen.  Redirecting the output to a file and editing that file with vi showed me that there was a SPACE on the end of the string returned by gethostname().  Ugh.</p>
<p>Other symptoms you might see if you have cruft in your /etc/hostname entry:</p>
<pre>
sudo: unable to resolve host
hostname => <i>hostname</i>
hostname -f => Unknown host
hostname -a => Unknown host
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/gepr/uncategorized/p4_error-could-not-gethostbyname-for-host/feed</wfw:commentRss>
		</item>
		<item>
		<title>Virtualizing the UCSF Cluster.</title>
		<link>http://blog.tempusdictum.com/index.php/don/uncategorized/virtualizing-the-ucsf-cluster</link>
		<comments>http://blog.tempusdictum.com/index.php/don/uncategorized/virtualizing-the-ucsf-cluster#comments</comments>
		<pubDate>Mon, 20 Jul 2009 02:05:11 +0000</pubDate>
		<dc:creator>don</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=64</guid>
		<description><![CDATA[The computing cluster we maintain at uscf is built on a stock ubuntu hardy (desktop) with software added to it either to match the previous configuration or as needed by the experiments which are being conducted on the system. This decision was made as a compromise between the user community which was familiar with Ubuntu [...]]]></description>
			<content:encoded><![CDATA[<p>The computing cluster we maintain at uscf is built on a stock ubuntu hardy (desktop) with software added to it either to match the previous configuration or as needed by the experiments which are being conducted on the system. This decision was made as a compromise between the user community which was familiar with Ubuntu and the need for a stable (LTS) platform from an administration perspective.<em> </em>Since the hardware on the cluster is aging and reinstallation of systems requiring on site administration is expensive. We are evaluating alternatives such as the Amazon Elastic Cloud. This is an overview of an attempt to create a virtual instance of the servers used in the cluster. <em>(The process is actually done twice since the head node is built on intrepid (desktop) because the processor configuration was not compatible with hardy&#8217;s install kernel.)</em></p>
<p>Out of hundreds of prebuilt images avaliable for the &#8220;Elastic Cloud&#8221; there are two sets of ec2 AMIs that closely match the platform that we are running. One is from alestic <a href="http://alestic.com/2009/04/official-ubuntu-ec2" target="_blank">http://alestic.com/2009/04/official-ubuntu-ec2</a> and the other is a relatively new bundle from Ubuntu <a href="http://www.ubuntu.com/products/whatisubuntu/serveredition/features/ec2">http://www.ubuntu.com/products/whatisubuntu/serveredition/features/ec2</a>.</p>
<p>My initial attempt to create a package used the alestic desktop image. On top of taking more than 7 hours to merge the packages installed on the reference platform the result was completely unusable. Some of this was due to my not catching packages which did not work on ec2 such as grub and the kernel which was installed on the reference platform. Unlike VMware&#8217;s virtualization the amazon cloud is pretty particular about a few things. For this reason I found it prudent to start with systems which were native to the cloud and modify them.</p>
<p>The Ubuntu AMI advertises itself as &#8220;server&#8221; which is bare bones to the point of uselessness. Comparing the installed packages on the reference platform to the server left over 500 packages to sort through.<br />
Fortunately the instantiated version allows you to install a set of packages which includes the desktop. This left us a delta of around 100 packages. Eliminating the packages that were not likely to work on the EC2 such as the standard kernel and grub resulted in less than 90 new packages to install.</p>
<p>Once I set up the ec2 tools and environment in accordance with amazons documentation http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/. I created an instance of the Ubuntu AMI (ami-5d59be34)</p>
<pre style="padding-left: 30px;">$ ec2-run-instances ami-5d59be34 -k n01-keypair
$ ec2-describe-instance (...wait until its running)
$ ssh -i id_rsa-furm-keypair ubuntu@ec2-75-101-175-209.compute-1.amazonaws.com</pre>
<p>With the basic instance installed you can  &#8220;sudo tasksel&#8221; and select Ubuntu desktop (in addition to the ssh server and any other appropriate packages). Once it completes the installation you can get a list of the installed packages and compare it to the packages on the reference platform and using aptitude install the additional packages. I use aptitude since it handles dependencies more &#8216;apt&#8217;ly than apt-get.</p>
<pre style="padding-left: 30px;"># dpkg --get-selections|grep install|cut -f1&gt;ubuntu-intrepid-ec2.packages
# exit
$ exit
$ scp -i ~/.ssh/id_rsa-n01-keypair ubuntu@ec2-75-101-175-209.compute-1.amazonaws.com:ubuntu-intrepid-ec2.packages .
$ dpkg --get-selections|grep install |cut -f1 &gt;reference.package
$ diff ubuntu-intrepid-ec2.packages reference.packages |grep \&gt;|sed 's/&gt; //'&gt;packages2add
$ nano packages2add &lt;&lt;&lt;&lt;&lt;&lt; delete linux* grub and any kernel packages.&gt;&gt;&gt;&gt;&gt;&gt;&gt;
$ cp -i ~/.ssh/id_rsa-n01-keypair packages2add  ubuntu@ec2-75-101-175-209.compute-1.amazonaws.com:.
$ ssh -i ~/.ssh/id_rsa-n01-keypair ubuntu@ec2-75-101-175-209.compute-1.amazonaws.com
$ sudo bash
# for p in `cat packages2add` ; do echo $p;  aptitude -y install $p; done</pre>
<p>At this point you should back check the new manifest and reboot the instance to make sure that you didn&#8217;t break anything before using your modified instance to create a new bundle. The ubuntu AMIs come with two disks defined by default / and /mnt which are close to the same size. you use /mnt to create an image. The process is convoluted at best. There is a pretty good description at <a href="http://alestic.com/2009/06/ec2-ami-bundle" target="_blank">http://alestic.com/2009/06/ec2-ami-bundle</a>.</p>
<pre style="padding-left: 30px;">$ scp -i ~/.ssh/id_rsa-n01-keypair  *.pem ubuntu@ec2-75-101-175-209.compute-1.amazonaws.com:.
cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem     100%  916     0.9KB/s   00:00
pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem       100%  922     0.9KB/s   00:00
$ ssh -i ~/.ssh/id_rsa-n01-keypair ubuntu@ec2-75-101-175-209.compute-1.amazonaws.com
$ sudo bash
# ec2-bundle-vol -r i386 -d/mnt -p ucsf-hardy-node \
-u XXXX-XXXX-XXXXX \
-k /home/ubuntu/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem \
-c /home/ubuntu/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem \
-s 10240 -e /mnt,/tmp,/root/.ssh,/home/ubuntu/.ssh
Copying / into the image file /mnt/ucsf-intrepid-head-node...
... &lt;&lt;&lt;&lt;&lt;&lt;&lt; wait for a small eternity &gt;&gt;&gt;&gt;&gt;&gt;&gt;
Bundling image file
... &lt;&lt;&lt;&lt;&lt;&lt;&lt; wait for a nother small eternity &gt;&gt;&gt;&gt;&gt;&gt;&gt;
Creating bundle manifest...
ec2-bundle-vol complete..
#ec2-upload-bundle  -b ucsfintrepid -m /mnt/ucsf-intrepid-head-node.manifest.xml   \
-a XXXXXXXXXXXXXXXX  -s XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Creating bucket...
Uploading bundled image parts to the S3 bucket ucsfintrepid ...
Uploaded ucsf-intrepid-head-node.part.000
...
Uploaded ucsf-intrepid-head-node.part.167
Uploading manifest ...
Uploaded manifest.
Bundle upload completed.
</pre>
<p>Once this is done you have to register the bundle this is done from the local machine (reference).here.</p>
<pre style="padding-left: 30px;">$ ec2-register ucsfintrepid/ucsf-intrepid-head-node.manifest.xml
IMAGE    ami-f339d89a</pre>
<p>Then you can test load it.</p>
<pre style="padding-left: 30px;">$ ec2-run-instances ami-f339d89a -k n01-keypair
$ ec2-describe-instances</pre>
<pre style="padding-left: 30px;">...INSTANCE    i-af261cc6    ami-f339d89a    ec2-67-202-25-96.compute-1.amazonaws.com    domU-12-31-39-00-65-C8.compute-1.internal    running    n01-keypair    0        m1.small    2009-07-20T03:41:11+0000    us-east-1c    aki-714daa18    ari-6a5bbc03        monitoring-disabled
$ ssh -i ~/.ssh/id_rsa-n01-keypair  ubuntu@ec2-67-202-25-96.compute-1.amazonaws.com
</pre>
<p>If this is successfull you can terminate your original instances.</p>
<pre style="padding-left: 30px;">$ for i in `ec2-describe-instances |grep INSTANCE |cut -f2` ; do ec2-terminate-instances $i; done
INSTANCE    i-cd4f75a4    running    shutting-down
INSTANCE    i-af261cc6    running    shutting-down.</pre>
<p>(This is important since amazon charges a nominal amount for each instance&#8217;s runtime ).</p>
<p style="padding-left: 30px;">
<p style="padding-left: 60px;">
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/don/uncategorized/virtualizing-the-ucsf-cluster/feed</wfw:commentRss>
		</item>
		<item>
		<title>Converting Android 1.5 &#8220;Camcorder&#8221; videos with SAMR audio codec on Ubuntu Jaunty with ffmpeg</title>
		<link>http://blog.tempusdictum.com/index.php/gepr/uncategorized/converting-android-15-camcorder-videos-with-samr-audio-codec-on-ubuntu-jaunty-with-ffmpeg</link>
		<comments>http://blog.tempusdictum.com/index.php/gepr/uncategorized/converting-android-15-camcorder-videos-with-samr-audio-codec-on-ubuntu-jaunty-with-ffmpeg#comments</comments>
		<pubDate>Tue, 02 Jun 2009 22:46:09 +0000</pubDate>
		<dc:creator>gepr</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=63</guid>
		<description><![CDATA[So, T-Mobile pushed the Android 1.5 update to me last Sunday (I think).  I installed it and subsequently had to record a video with the new Camcorder application.  It works well; but produces videos with the audio track in AMR format.  The standard ffmpeg distributed with Ubuntu doesn&#8217;t have AMR compiled in because the AMR [...]]]></description>
			<content:encoded><![CDATA[<p>So, T-Mobile pushed the Android 1.5 update to me last Sunday (I think).  I installed it and subsequently had to record a video with the new Camcorder application.  It works well; but produces videos with the audio track in AMR format.  The standard ffmpeg distributed with Ubuntu doesn&#8217;t have AMR compiled in because the AMR codec isn&#8217;t liberated/free.  I followed <a title="How to install FFmpeg with MP3 and AMR support " href="http://www.mattiouz.com/blog/2007/07/02/how-to-install-ffmpeg-with-mp3-and-amr-support">Chez&#8217; instructions</a> with a few modifications to get a tweaked ffmpeg that will convert videos recorded with my G1 phone.</p>
<ul>
<li style="text-align: left;">Run the standard ffmpeg to get the configure options used to compile it.</li>
<li style="text-align: left;">apt-get install libmp3lame-dev libgsm1-dev libshroedinger-dev libspeex-dev libtheora-dev libvorbis-dev libdc1395-22-dev.</li>
<li style="text-align: left;"><a title="AMR Codecs as Shared Libraries" href="http://www.penguin.cz/~utx/amr">Download</a>, unpack, configure [--prefix=/usr/local/amr], make &amp;&amp; make install both libamr-nb and -wb.</li>
<li style="text-align: left;">svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg-2009-06-02.</li>
<li style="text-align: left;">configure [*], make &amp;&amp; make install ffmpeg.</li>
<li style="text-align: left;">export LD_LIBRARY_PATH=/usr/local/amr/lib:/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH</li>
<li style="text-align: left;">/usr/local/ffmpeg/bin/ffmpeg -i video.3gp -ar 44100 vide.mpg</li>
</ul>
<p style="text-align: left;">[*] I ended up using the following configure command for ffmpeg:<br />
./configure &#8211;enable-gpl &#8211;enable-postproc &#8211;enable-x11grab &#8211;prefix=/usr/local/ffmpeg &#8211;enable-avfilter &#8211;enable-avfilter-lavf &#8211;enable-libgsm &#8211;enable-libschroedinger &#8211;enable-libspeex &#8211;enable-libtheora &#8211;enable-libvorbis &#8211;enable-pthreads &#8211;disable-stripping &#8211;enable-libdc1394 &#8211;disable-armv5te &#8211;disable-armv6 &#8211;disable-armv6t2 &#8211;disable-armvfp &#8211;disable-neon &#8211;disable-altivec &#8211;disable-vis &#8211;enable-shared &#8211;disable-static &#8211;enable-libamr-nb &#8211;enable-libamr-wb &#8211;enable-nonfree &#8211;extra-cflags=-I/usr/local/amr/include &#8211;extra-ldflags=-L/usr/local/amr/lib</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/gepr/uncategorized/converting-android-15-camcorder-videos-with-samr-audio-codec-on-ubuntu-jaunty-with-ffmpeg/feed</wfw:commentRss>
		</item>
		<item>
		<title>Reinventing the Wheel (watcher)</title>
		<link>http://blog.tempusdictum.com/index.php/don/uncategorized/reinventing-the-wheel-watcher</link>
		<comments>http://blog.tempusdictum.com/index.php/don/uncategorized/reinventing-the-wheel-watcher#comments</comments>
		<pubDate>Thu, 28 May 2009 05:44:58 +0000</pubDate>
		<dc:creator>don</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tempusdictum.com/?p=62</guid>
		<description><![CDATA[Its not very often that you get to go back to old designs and make improvements. Recently I got to rework a design from last year and build on the collective knowlege of 2 design teams and 3 design cycles.
Does practice make perfect? We shall see.
The first run.
Last year I got to build the electronics [...]]]></description>
			<content:encoded><![CDATA[<p>Its not very often that you get to go back to old designs and make improvements. Recently I got to rework a design from last year and build on the collective knowlege of 2 design teams and 3 design cycles.</p>
<p>Does practice make perfect? We shall see.</p>
<h2>The first run.</h2>
<p>Last year I got to build the electronics for a stationary bike racing system. The system had a large ballfield style clock with four hands that were run by these monster stepper motors The initial design was for two bikes done by Percor: a company that makes excercize equipment. Their design used these industrial (expensive and very bulky) cherry hall effect sensors which they loaned us for a race at Lance Armstrong&#8217;s bike shop in Austin (<a href="http://www.mellowjohnnys.com/" target="_blank">http://www.mellowjohnnys.com/</a>). My job for that cycle was to replace Percor&#8217;s pic based board with a 4 bike setup.</p>
<p><img src="http://farm4.static.flickr.com/3180/2930383455_848349a417.jpg?v=0" alt="" width="500" height="375" /></p>
<p>I broke the stepper driver section into four individual boards. For the processor I built a custom mega128 based board and did the programming in wiring.</p>
<h2>Second iteration.</h2>
<p>When the Austin race was over Percor needed their parts back so I got to rebuild the sensors. I found some allegra hall effect sensors which were a small fraction of the cost of the cherry&#8217;s (like (75c&lt;$25.00)X4).  As an attempt to get a zero indicator on the clock I  experimented with a triangle based design <img src="http://farm4.static.flickr.com/3270/2804910682_7a05dde6da.jpg?v=0" alt="" width="500" height="375" /></p>
<p>While I never did get this particular part of the clock to work correctly the triange stuck as a shape that I liked working with.</p>
<p><img src="http://farm4.static.flickr.com/3031/2854467892_2190716e90.jpg?v=0" alt="" width="250" height="187" /><img src="http://farm4.static.flickr.com/3240/2931242672_e89fb356c1.jpg?v=0" alt="" width="250" height="187" /></p>
<p>I also wanted to replace the cat5 wire used in the Percor design with with less expensive phone cord. (I got a panicked phone call  from Texas and had to remotely direct someone how to get some very expensive ethernet cable on a weekend: it was not cool). To do this I put a non inverting buffer on the sensors and since buffers come in 6s  I put an indicator led on the sensors output. In the practice of setting this up for the next race, the blinking lights were invaluable.</p>
<h2>Third Time Charm.</h2>
<p>A few weeks ago I was asked about another race setup in SanFrancisco. They were going to use a system called open sprints for the display but the open sprints people were out of their hardware for the sensors. So I got a 3 week timeline to put together a sensor and hardware interface that would be compatible with open sprints.</p>
<p>Open sprints (<a href="http://www.opensprints.org" target="_blank">www.opensprints.org</a>) is an open source ruby based software which takes information from an arduino and presents the race data in a way that can be projected instead of having a physical race clock. The only thing that needed to be built was the input side.</p>
<p>So I went back to what I liked and didn&#8217;t like about my earlier design and compared and contrasted the opensprints, the percor and my designs to come up with a new system which I could then have fabbed by our local pcb fab (<a href="http://sunstone.com" target="_blank">sunstone.com</a>). Looking at the opensprints design I revisited the hall effect sensors and found a set of sensors to experiment with and began to lay out my boards.</p>
<p>I had intended to use the dart design with a through hole led and a throuch hole (sip) sensor and then have some laser cut transparent plastic which could then be &#8220;lit&#8221; up by the led on the board. A second piece of opaque plastic would be cut to insulate the bottom of the board.</p>
<p>After talking to some of my ee freinds I decided to replace the on board drivers with a single schmidt trigger on the other end of the sensor cable  (the percor design used these as well)  When selecting the parts I found myself looking at a few options for the rj11 connectors. I ordered a few of each as well as both sip and the origional smt sensor from last year.</p>
<h3>Who needs plastic?</h3>
<p>When I got the parts I started looking at these rj11 connectors and rethinking things. The connectors were surface mount and shielded. The shielding wasn&#8217;t needed but they matched the un-soldermasked boards in texture in color they were about 7 cents more expensive apiece but they looked futuristic.</p>
<p>I went back to surface mount only. If I got rid of the sips and used the surface mount rj11 mounts then the bottom of the board would be shield/ground no insulation needed. The metal from the surface of the board and cable connector would reflect the light from the led and if any attention were payed to the layout of the traces it would look cool!</p>
<p><img src="http://farm4.static.flickr.com/3348/3571822057_38ecc27f11.jpg?v=0" alt="" width="375" height="500" /></p>
<p>Even in the hand rolled prototype!</p>
<h3>Who needs an Arduino?</h3>
<p>At this point given Paul Stoffregon&#8217;s (<a href="http://pjrc.com">pjrc.com</a>) &#8220;teensyduino&#8221; software and his 90usb based boards<strong> there is no reason to buy any other arduino or arduino clone</strong>.<em> (</em> at least in cases where you need usb to serial solution<em> &#8212; in cases where usb-serial is not needed the dorkboard rules <img src='http://blog.tempusdictum.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em>My first thought was to do a carrier board for on of Paul&#8217;s boards and adapt the opensprints code for the inverted inputs. The opensprints code needs to be adapted to invert the input signal and to adjust the registers for the different processor but using the teensyquino codebase that should be simple enough.<br />
In this application however, the board was so simple that it made more sense to just adopt the eagle design for my at90usb162 board (the benito).</p>
<p><img src="http://farm3.static.flickr.com/2423/3572317196_b71e4fe080.jpg?v=0" alt="" width="500" height="373" /></p>
<p>Tomorrow I get the boards from sunstone and I should have the hardware built out by late friday. The customer will be in portland saturday.</p>
<p>Does practice make perfect? We will let you know by next week.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tempusdictum.com/index.php/don/uncategorized/reinventing-the-wheel-watcher/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
