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

<channel>
	<title>Making Software Useful</title>
	<atom:link href="http://dstovall.com/feed" rel="self" type="application/rss+xml" />
	<link>http://dstovall.com</link>
	<description>Software Engineering thoughts by Drew Stovall</description>
	<lastBuildDate>Fri, 08 Jan 2010 00:00:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Player 2.1.x with a USB Segway RMP</title>
		<link>http://dstovall.com/posts/90.html</link>
		<comments>http://dstovall.com/posts/90.html#comments</comments>
		<pubDate>Mon, 04 Jan 2010 21:09:18 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Player]]></category>
		<category><![CDATA[Segway RMP]]></category>
		<category><![CDATA[USB Segway RMP]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=90</guid>
		<description><![CDATA[The following instructions are based mostly on the article Segway on player 2.1.x published by SRI International&#8217;s Artificial Intelligence Center.  This document is designed to be included with the player 2.1.x distribution.  The latest version of player is 3.x, which claims to include a correct and robust driver for the USB based Segway [...]]]></description>
			<content:encoded><![CDATA[<p>The following instructions are based mostly on the article <a href="http://www.ai.sri.com/~vincent/segway.php">Segway on player 2.1.x</a> published by <a href="http://www.sri.com/">SRI International</a>&#8217;s <a href="http://www.ai.sri.com/">Artificial Intelligence Center</a>.  This document is designed to be included with the player 2.1.x distribution.  The latest version of player is 3.x, which claims to include a correct and robust driver for the USB based Segway RMPs.</p>
<p>The instructions were developed for 32- and 64-bit versions of Ubuntu 9.10, but should be fairly protable to other versions and distributions.  The library versions are current as of 18-Dec-2009, but are likely to change over time.  You will need to update the commands below if a newer version is released.<br />
<span id="more-90"></span><br />
<!-- =========================================== --></p>
<h3>Step 1 &#8211; Pre-Req&#8217;s</h3>
<p>First we need to install all the programs and libraries that are required below. The following command will install all the required packages:</p>
<div class="code">sudo apt-get update<br />
sudo apt-get -y install build-essential libboost-dev libltdl7-dev swig libjpeg62-dev libxext-dev automake</div>
<p>The brltty package is &#8220;Access software for a blind person using a braille display&#8221;. Unfortunatly this package conflicts with a driver below, so we need to remove it.</p>
<div class="code">sudo apt-get -y remove brltty<br />
sudo apt-get -y autoremove</div>
<p><!-- =========================================== --></p>
<h3>Step 2 &#8211; FTD driver</h3>
<p>Here we install the driver for the FDT chip that the Segway uses to communicate.  In this step (and the remaining steps) we use a working directory &#8220;<code>~/work/</code>&#8221; to hold all the files that we are  using. You should check the <a href="http://www.ftdichip.com/Drivers/D2XX.htm">FTDI website</a> to confirm that the latest version is &#8220;0.4.16&#8243;.</p>
<div class="code">
#<br />
# Begin FTD driver installation<br />
#<br />
mkdir ~/work/<br />
cd ~/work/</p>
<p>#<br />
# Download, extract, and place the ftd library<br />
#</p>
<p># &#8212;&#8212;&#8212;&#8212;- 32-Bit &#8212;&#8212;&#8212;&#8212;-<br />
wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16.tar.gz<br />
tar xzvf libftd2xx0.4.16.tar.gz</p>
<p>sudo cp ./libftd2xx0.4.16/libftd2xx.so.0.4.16 /usr/local/lib<br />
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 /usr/local/lib/libftd2xx.so<br />
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 /usr/lib/libftd2xx.so</p>
<p>sudo cp ./libftd2xx0.4.16/ftd2xx.h /usr/include<br />
sudo cp ./libftd2xx0.4.16/WinTypes.h /usr/include<br />
sudo chmod go+r /usr/include/ftd2xx.h /usr/include/WinTypes.h<br />
sudo chmod a-x  /usr/include/ftd2xx.h /usr/include/WinTypes.h</p>
<p># &#8212;&#8212;&#8212;&#8212;- 64-Bit &#8212;&#8212;&#8212;&#8212;-<br />
wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16_x86_64.tar.gz</p>
<p>tar xzvf libftd2xx0.4.16_x86_64.tar.gz</p>
<p>sudo cp ./libftd2xx0.4.16_x86_64/libftd2xx.so.0.4.16 /usr/local/lib<br />
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 /usr/local/lib/libftd2xx.so<br />
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 /usr/lib/libftd2xx.so</p>
<p>sudo cp ./libftd2xx0.4.16_x86_64/ftd2xx.h /usr/include<br />
sudo cp ./libftd2xx0.4.16_x86_64/WinTypes.h /usr/include<br />
sudo chmod go+r /usr/include/ftd2xx.h /usr/include/WinTypes.h</p>
<p>#<br />
# Configure the other bits of the system<br />
#</p>
<p># Recommended by the FTDI documentation. It is not clear that this step<br />
# is actually required.<br />
sudo sh -c &#8220;echo &#8216;none /proc/bus/usb usbfs defaults,mode=0666 0 0&#8242; >> /etc/fstab&#8221;<br />
sudo mount -a</p>
<p># Add an entry to the udev rules to ensure that devices use the same name/id<br />
# between reboots<br />
sudo sh -c &#8220;echo &#8216;# For FTDI FT232 &#038; FT245 USB devices with Vendor ID = 0&#215;0403, Product ID = 0xe729&#8242; >> /etc/udev/rules.d/99-usbftdi.rules&#8221;</p>
<p>sudo sh -c &#8220;echo &#8216;SYSFS{idProduct}==\&#8221;e729\&#8221;, SYSFS{idVendor}==\&#8221;0403\&#8221;, RUN+=\&#8221;/sbin/modprobe -q ftdi-sio product=0xe729 vendor=0&#215;0403\&#8221;&#8216; >> /etc/udev/rules.d/99-usbftdi.rules&#8221;</p>
<p>sudo restart udev</p>
<p>#<br />
# Update the links and caches to pick up the new libraries.<br />
# You&#8217;ll need to log out and then log back in to make sure these<br />
# changes are accepted.<br />
#<br />
sudo ldconfig<br />
logout</p>
<p>#<br />
# Test the FTD driver<br />
#<br />
# Unplug in the segway and run the following command.<br />
# It should result in _NO_ output<br />
dmesg | grep FTDI</p>
<p># Plug in the segway and run the same command.<br />
# This time you should get some output.<br />
dmesg | grep FTDI</p></div>
<p><!-- =========================================== --></p>
<h3>Step 3 &#8211; CAN driver install</h3>
<p>The installation of the CAN driver is much more straightforward.</p>
<p>Unfortunately, you must fill out a form before downloading the driver distribution, so this step can&#8217;t be completely automated.  To get the distribution, visit the <a href="http://www.kvaser.com/index.htm">KVASER website</a>.  It can be found by following this path: </p>
<ol>
<li>Support</p>
<li>Download
<li>Beta Releases
<li>All Beta Releases
<li>Linux driver and SDKv4.75 BETA</ol>
<p>Using a browser, download <code>linuxcan_beta.tar.gz</code> to <code>~/Downloads/</code></p>
<p>The instructions below assume that the distribution is still on version 4.75.  You will need to make the appropriate updates if the version has changed.</p>
<div class="code">
#<br />
# Begin CAN driver installation<br />
#<br />
cd ~/work/</p>
<p>#<br />
# Extract, and place the ftd library<br />
#<br />
mv ~/Downloads/linuxcan_beta.tar.gz linuxcan-beta-4.75.tgz<br />
tar xzvf linuxcan-beta-4.75.tgz</p>
<p>pushd linuxcan_v4/<br />
  sudo make install<br />
popd</p></div>
<p>This is the one &#8220;hack&#8221; of the install.  For some reason, the typedefs in the canlib.h header conflict with those in the FTD headers.  Really this is a conflict in the packages that ought to be resolved by one of the two authors, but for now we have to resolve the problem ourselves.</p>
<p>Edit <code>/usr/include/canlib.h</code> and comment out the definitions for <code>DWORD</code>, <code>HANDLE</code>, <code>BOOL</code>.  Use the &#8220;<code>//</code>&#8221; comment style and leave yourself a comment in the source code describing why you&#8217;ve done this.</p>
<div class="code">
sudo nano /usr/include/canlib.h</p>
<p>#<br />
# Update the links and caches to pick up the new libraries.<br />
# You&#8217;ll need to log out and then log back in to make sure these<br />
# changes are accepted.<br />
#<br />
sudo ldconfig<br />
logout</p></div>
<p>At this point, there is no way to test that this installation has gone correctly.</p>
<p><!-- ============================================= --></p>
<h3>Step 4 &#8211; Try Player for Roomba</h3>
<p>This might be a bit of a reach, but I will assume that if you&#8217;re working with a Segway RMP, you probably already have access to one of the other robots supported by the Player project.  In this step, we want to confirm that the player server is working correctly without the influence of the RMP code or libraries. </p>
<p>For the purposes of the example here, I will further assume that you have access to a Roomba Create.  If not, update the &#8220;&#8211;enable-roomba&#8221; bit with the name of your robot&#8217;s driver.</p>
<p>In the following script, I am using player version 2.1.3, but this script has also been used with version 2.1.2.  Just update the version numbers in the script to use the other version.</p>
<div class="code">
#<br />
# Download, extract, build, and install the player server<br />
#<br />
cd ~/work/<br />
wget http://downloads.sourceforge.net/playerstage/player-2.1.3.tar.gz<br />
tar xzf player-2.1.3.tar.gz</p>
<p>pushd player-2.1.3<br />
  ./configure \<br />
  &#8211;disable-alldrivers \<br />
  &#8211;enable-roomba</p>
<p>  make<br />
  sudo make install<br />
popd</p>
<p>#<br />
# Update the links and caches to pick up the new libraries.<br />
# You&#8217;ll need to log out and then log back in to make sure these<br />
# changes are accepted.<br />
#<br />
sudo ldconfig<br />
logout</p>
<p>#<br />
# Create a configuration file for the roomba<br />
#<br />
echo &#8220;driver<br />
(<br />
name \&#8221;roomba\&#8221;<br />
provides [\"position2d:0\"]<br />
port \&#8221;/dev/ttyUSB0\&#8221;<br />
safe 1<br />
alwayson 1<br />
)&#8221; > ~/work/roomba.cfg</p></div>
<p>Start the player server in one console&#8230;</p>
<div class="code">
cd ~/work/<br />
player roomba.cfg</div>
<p>&#8230; and start the joystick controller in another console.</p>
<div class="code">
cd ~/work/<br />
playerjoy localhost:6665</div>
<p><!-- ============================================= --></p>
<h3>Step 5 &#8211; Try the  Segway</h3>
<p>Assuming that you&#8217;ve gotten this far and everything is working, it&#8217;s time to try the Segway</p>
<p>First, connect your USB based Segway RMP and turn it on (green button).  Then turn it on (yellow button).</p>
<div class="code">
#<br />
# These steps have been cited by &#8220;the internet&#8221; as potentially required.<br />
# The don&#8217;t hurt anything in the case that they are not required, so we<br />
# do them anyway, just to be safe.<br />
#<br />
sudo modprobe usbserial<br />
sudo modprobe ftdi_sio</div>
<p>If my patch has not yet been included in the player distribution (these instructions are not in /server/drivers/mixed/rmp/README), then you need to download and apply my patch.  Use the following script to do so:</p>
<div class="code">
cd ~/work/</p>
<p># &#8212;&#8212;&#8212;&#8212;- player 2.1.2 &#8212;&#8212;&#8212;&#8212;-<br />
wget http://XXX/SegwayRmpUsb_for_player-2.1.2.patch<br />
cd player-2.1.2<br />
patch -p1 < ../SegwayRmpUsb_for_player-2.1.2.patch</p>
<p># ------------- player 2.1.3 -------------<br />
wget http://XXX/SegwayRmpUsb_for_player-2.1.3.patch<br />
cd player-2.1.3<br />
patch -p1 < ../SegwayRmpUsb_for_player-2.1.3.patch</div>
<p>Now it&#8217;s time to build the driver.  We need to let the build know that the ftd and canbus driver libraries should be included, so we set the LIBS environment variable.  Other then that, it&#8217;s a standard build.</p>
<p>(It seems that sometimes I need to enclose the value for LIBS in quotes: <code>export LIBS="-lftd2xx -lcanbus"</code>. I don&#8217;t know why or when this needs to be done.)</p>
<div class="code">
cd ~/work/player-2.1.3<br />
pushd player-2.1.3<br />
  LIBS=-lftd2xx -lcanbus</p>
<p>  ./configure \<br />
    &#8211;disable-alldrivers \<br />
    &#8211;enable-roomba \<br />
    &#8211;enable-segwayrmp</p>
<p>  make<br />
  sudo make install<br />
popd</p>
<p>#<br />
# Update the links and caches to pick up the new libraries.<br />
# You&#8217;ll need to log out and then log back in to make sure these<br />
# changes are accepted.<br />
#<br />
sudo ldconfig<br />
logout</p>
<p>#<br />
# Create a configuration file for the roomba<br />
#<br />
echo &#8220;driver<br />
(<br />
name \&#8221;segwayrmp\&#8221;<br />
provides [\"position2d:0\" \"position3d:0\" \"power:0\"]<br />
canio \&#8221;rmpusb\&#8221;<br />
max_xspeed 3.0<br />
max_yawspeed 60<br />
alwayson 1<br />
)&#8221; > ~/work/segway.cfg</p></div>
<p>Now the moment of truth. I&#8217;ve tried to augment the driver to print some useful information when it starts up. If the player server doesn&#8217;t start, take a look at the output for debugging hints.</p>
<p>Start the player server in one console&#8230;</p>
<div class="code">
cd ~/work/<br />
sudo player segway.cfg</div>
<p>&#8230; and start the joystick controller in another console.</p>
<div class="code">
cd ~/work/<br />
playerjoy localhost:6665</div>
<p><!-- ============================================= --></p>
<h3>Step 6 &#8211; Extra Credit</h3>
<p>If you have an actual joystick, this is the time to pull it out.  Once you connect the joystick, you&#8217;ll need to calibrate it like this:</p>
<div class="code">jscal &#8211;calibrate /dev/input/js1</div>
<p>Then you can fire up a player client to use the joystick rather then the keyboard:</p>
<div class="code">playerjoy -dev /dev/input/js1 localhost:6665</div>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/90.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pharos Mission 2 &#8211; Success</title>
		<link>http://dstovall.com/posts/82.html</link>
		<comments>http://dstovall.com/posts/82.html#comments</comments>
		<pubDate>Thu, 19 Nov 2009 22:03:55 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=82</guid>
		<description><![CDATA[Monday was a big day for the Pharos project.  We took 10 robots out to the Dell Diamond's back parking lot and collected the first real, useful data.  There were two main focuses for the mission: (1) how accuratly can we move along a predetermined path using GPS coordinates, and (2) how does distance effect the connectivity of the standard ad-hoc wireless network.]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://dstovall.org/posts/650.html">I completed my dissertation</a> a couple months back, I&#8217;ve switched over to working on the <a href="http://pharos.ece.utexas.edu">Pharos Project</a> nearly full-time.  Pharos is a fledging project aimed at creating a modular testbed for (primarily) wireless networking research.  Basically, we get a bunch of robots to move around in a big parking lot and see if we can still get them to collaborate, even though they can&#8217;t alway communicate.</p>
<p>Monday was a big day for the Pharos project.  We took 10 robots out to the Dell Diamond&#8217;s back parking lot and collected the first real, useful data.  There were two main focuses for the mission: (1) how accuratly can we move along a predetermined path using GPS coordinates, and (2) how does distance effect the connectivity of the standard ad-hoc wireless network.</p>
<p>To answer the first question, take a look at the following picture. Here the red line is the track that we wanted the robot to follow.  The purple line is the path that it actually took (according to the on-board GPS).  The node started in the bottom left and drove to it&#8217;s first waypoint in the upper right.  Then it visited each waypoint in turn, ending in the upper left.  <em>(It seems that maybe it started wandering around on it&#8217;s own for a while after it was supposed to stop)</em></p>
<p><a href="http://dstovall.com/wp-content/uploads/2009/11/pem-002.run-03.node-01.mobility-trace.jpg"><img src="http://dstovall.com/wp-content/uploads/2009/11/pem-002.run-03.node-01.mobility-trace-300x199.jpg" alt="Mobility trace for one robot" title="Mobility trace for one robot" width="300" height="199" class="aligncenter size-medium wp-image-83" /></a></p>
<p>Given that this is very preliminary data, it seems that this bot did a darn fine job of going where it was supposed to go.</p>
<p>To answer the second question, we had one robot sit still, and another drive past it several times.  We measured the acheaviable throughput over the wireless network to find out just how far you have to go to disconnect.  Well, it seems that you have to go about 80m.  I wish I had the graph to show you, but it&#8217;s still under construction&#8230; in the mean time, here&#8217;s the mobility trace from this experiment:<br />
<a href="http://dstovall.com/wp-content/uploads/2009/11/pem-002.run-06.node-02.mobility-trace.jpg"><img src="http://dstovall.com/wp-content/uploads/2009/11/pem-002.run-06.node-02.mobility-trace-300x199.jpg" alt="Mobility trace from connectivity experiment" title="Mobility trace from connectivity experiment" width="300" height="199" class="aligncenter size-medium wp-image-84" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/82.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Middleware Demo Results</title>
		<link>http://dstovall.com/posts/51.html</link>
		<comments>http://dstovall.com/posts/51.html#comments</comments>
		<pubDate>Thu, 04 Dec 2008 08:51:56 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=51</guid>
		<description><![CDATA[I&#8217;m proud to say that my demo at Middleware 2008 went very well.  It seemed that everyone understood both the basic tentants of the architecture and the actual implementation sitting on the table in front of them.
As murphy&#8217;s law dictates, the sexiest part of the demo (the Roomba) failed to work on demo day. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m proud to say that my demo at <a href="http://middleware2008.cs.kuleuven.be/">Middleware 2008</a> went very well.  It seemed that everyone understood both the basic tentants of the architecture and the actual implementation sitting on the table in front of them.</p>
<p>As murphy&#8217;s law dictates, the sexiest part of the demo (the Roomba) failed to work on demo day.  I&#8217;ll be diagnosing this issue when I get home, but I now believe the servos make a better demonstation tool anyway.</p>
<p>For more information about the SEAP system, here is a list of other resources:</p>
<ul>
<li><a href=""http://mpc.ece.utexas.edu/Papers/TR-UTEDGE-2008-015.pdf">A more detailed explanation of SEAP</a> currently under review for a conference.</li>
<li><a href="http://mpc.ece.utexas.edu/Papers/TR-UTEDGE-2008-003.pdf">The first SEAP (short) paper with a brief explanation</a> of the technique</li>
<li><a href="http://mpc.ece.utexas.edu/Papers/TR-UTEDGE-2008-013.pdf">Original Demo Proposal for Middlware 2008</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/51.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Demo at Middleware 2008</title>
		<link>http://dstovall.com/posts/35.html</link>
		<comments>http://dstovall.com/posts/35.html#comments</comments>
		<pubDate>Fri, 17 Oct 2008 23:00:46 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=35</guid>
		<description><![CDATA[My demo of the SEAP middleware architecture was accepted at Middleware 2008.  I&#8217;ll be traveling out to Leuven, Belgium in December to give the demo.
I&#8217;m excited to give this demo for a couple reasons.  First, I think it&#8217;s going to be a really interesting demo to interact with.  The devices and code [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://mpc.ece.utexas.edu/Papers/TR-UTEDGE-2008-013.pdf">demo of the SEAP middleware architecture</a> was accepted at <a href="http://middleware2008.cs.kuleuven.be/">Middleware 2008</a>.  I&#8217;ll be traveling out to <a href="http://maps.google.com/maps?hl=en&#038;q=Leuven,+Belgium&#038;ie=UTF">Leuven, Belgium</a> in December to give the demo.</p>
<p>I&#8217;m excited to give this demo for a couple reasons.  First, I think it&#8217;s going to be a really interesting demo to interact with.  The devices and code are all going to be right out on the table to play with.  Second, Middleware has <em>two</em> dedicated slots for demos, so there&#8217;s a good chance to meet people.</p>
<p>If you&#8217;re going to Middleware also, be sure to check out our lab&#8217;s paper on <a href="http://mpc.ece.utexas.edu/Papers/TR-UTEDGE-2008-002.pdf">Adaptive Milddleware to Support Delay Tolerant Networking</a> in the <a href="http://www.comp.lancs.ac.uk/computing/arm2008/">ARM &#8216;08 Workshop</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/35.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JUnit and SunSpots</title>
		<link>http://dstovall.com/posts/26.html</link>
		<comments>http://dstovall.com/posts/26.html#comments</comments>
		<pubDate>Fri, 25 Jul 2008 22:45:47 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=26</guid>
		<description><![CDATA[I&#8217;ve been fairly frustrated trying to write code for SunSpots lately.  This frustration mostly stems from my previous self-imposed training to use test-driven development. There is some support for using JUnit with SunSpots, but it requires that the code and tests all be deployed to an actual Spot before the tests are run.  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been fairly frustrated trying to write code for <a href="http://www.sunspotworld.com">SunSpots</a> lately.  This frustration mostly stems from my previous self-imposed training to use test-driven development. There is some support for using JUnit with SunSpots, but it requires that the code and tests all be deployed to an actual Spot before the tests are run.  Since deployment can take a minute or three, I find that I&#8217;m developing much larger chunks of code because I don&#8217;t want to run the tests as often&#8230;</p>
<p>Thus, I spent the time to figure out how to run JUnit tests on my desktop for SunSPOT applications.  I put together a strip-down <a href='http://dstovall.com/wp-content/uploads/2008/07/sunspotjunitexample.zip'>template using JUnit tests for Spots on the desktop</a> for anyone who would like to build on it.  I was also able to get my IDE (IDEA) to use the Spot JVM and libraries, so I&#8217;m back in the groove with test-driven development!</p>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/26.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ICSE 2008 &#8211; Day 2</title>
		<link>http://dstovall.com/posts/22.html</link>
		<comments>http://dstovall.com/posts/22.html#comments</comments>
		<pubDate>Sat, 17 May 2008 05:33:58 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=22</guid>
		<description><![CDATA[As with the previous post, the following papers piqued my interest during their presentation, and are potentially cool papers.
Challenges in Automotive Software Engineering (Keynote)
Authors: Manfred Broy
It figures that I’d start with a presentation that has no matching paper, eh?  The whole presentation was rather interesting, but here are a couple key points that are [...]]]></description>
			<content:encoded><![CDATA[<p>As with the previous post, the following papers piqued my interest during their presentation, and are potentially cool papers.</p>
<h3>Challenges in Automotive Software Engineering (Keynote)</h3>
<p>Authors: <a href=”http://www4.informatik.tu-muenchen.de/~broy/”>Manfred Broy</a><br />
It figures that I’d start with a presentation that has no matching paper, eh?  The whole presentation was rather interesting, but here are a couple key points that are relevant to my research:</p>
<ul>
<li>Integrating all the control units found in a car is complicate by the combinatorial explosion resulting from the combination of optional features.</li>
<li>There is heavy use of automatic code generation based on models in this arena.  While I didn’t completely grasp the extent and the ramifications of this, it’s something to keep in mind when targeting these types of applications.</li>
<li>A while back I was told that the automobile industry would love to use radios to communicate information between control units.  This was routed in the desire to reduce the weight associated with the all the wiring involved with standard techniques.  Well, it seems that even with wired networks on the car, there’s a more compelling problem: non-determinism.  The old protocol “CAN” is being replaced by new technologies that using (some variation of) time division to guarantee a certain amount of bandwidth to each control unit.  If we want to replace wired networks, we’re going to have to consider this problem which is very much non-trivial in wireless networks.</li>
</ul>
<h3>40 Years of Middleware</h3>
<p>Presenter: <a href=”http://www.cs.ucl.ac.uk/staff/ucacwxe/”>Wolfgang Emmerich</a><br />
Overall, this was a fun presentation.  It’s hard to report exactly what was said since it was mostly a detailed historical retrospective of the evolution of middleware.  <a href=”http://www.cs.ucl.ac.uk/staff/ucacwxe/”>Wolfgagng Emmerich</a> did an excellent job of researching and presenting this information, and referred to a paper recently published (in TSE?) that contains much of the information presented.  This paper ought to be an interesting read.<br />
As a side note, many people in my lab have discussed “what is middleware” with varring degrees of success.  The definition used for this presentation included two aspects: (1) multiple hosts (physical or logical), (2) heterogeneity, and (3) distribution.  It’s probably worth looking up this paper to at least look at and consider the definition of Middleware presented there.</p>
<h3>Asking and Answering Why and Why Not Questions about Program Behavior</h3>
<p>Authors: <a href=”http://faculty.washington.edu/ajko/”>Andrew Ko</a>, <a href=”http://www.cs.cmu.edu/~bam/”>Brad Myers</a><br />
Paper: <a href=”http://faculty.washington.edu/ajko/papers/Ko2008JavaWhyline.pdf”>PDF</a>, <a href=”www.cs.cmu.edu/~natprog/whyline-java.html“>Tool Homepage</a><br />
ICSE08 Distinguished paper award<br />
This was cool, and defiantly worth a read.  I’ll likely force this paper on my lab when I get back, even though it’s outside our research area. <img src='http://dstovall.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
The biggest open question in my mind at the end of the presentation was weather the tool can be (easily) applied to unit/integration testing implementations.  The presentation clearly focused on the ability to integrate ith GUI-based applications, so it’s hopefully just a less glamorous version of the same underlying engine.</p>
<h3>TODO or To Bug: Exploring How Task Annotations Play a Role in the Work Practices of Software Engineers</h3>
<p>Authors: <a href=”http://webhome.cs.uvic.ca/~mstorey/”>Margaret-Anne Storey</a>, Jody Ryall, <a href=”http://www.ianbull.com/”>Ian Bull</a>, Del Myers, Janice Singer<br />
Paper: <a href=”http://www.thechiselgroup.org/publications”>PDF will be available here some day</a><br />
This research focused on the in-line comments that developers leave to themselves (and others) in the form of “TODO”, “FixMe”, and similar tags.  I didn’t find the results particularly suprizing, but that might be due to wonderful presentation of the material.  Again, this is outside my research area, but probably a paper that I’ll be reading to solidiy my pre-existing notions.</p>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/22.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ICSE 2008 &#8211; Day 1</title>
		<link>http://dstovall.com/posts/21.html</link>
		<comments>http://dstovall.com/posts/21.html#comments</comments>
		<pubDate>Fri, 16 May 2008 05:44:46 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ICSE08]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=21</guid>
		<description><![CDATA[As always, the welcome address for the ICSE conference included the submission/acceptance reports… and this year ICSE came in at 15% acceptance… pretty strong accept rate as always.  One thing that the speaker pointed out that I hadn’t really realized earlier is that this includes all “submissions,” no matter what those submissions where.  [...]]]></description>
			<content:encoded><![CDATA[<p>As always, the welcome address for the ICSE conference included the submission/acceptance reports… and this year ICSE came in at 15% acceptance… pretty strong accept rate as always.  One thing that the speaker pointed out that I hadn’t really realized earlier is that this includes all “submissions,” no matter what those submissions where.  Later in the slides, he pointed out that some 14 of the original submissions were thrown out for being off-topic or because they “were just power-point slides and the such.”  (I’m impressed that anyone bothers to submit presentation slides as research papers for such a big conference… but I shouldn’t be surprised by anything anymore)</p>
<p>Below I’ve listed some of the paper presentations that I found interesting.  Note that I say <i>interesting</i> not <i>good/great</i>.  Before I say that any of these items are really great, I’ll read the paper first.  So let’s just say that these papers are candidates to be <i>good</i> papers…</p>
<h3>Time will Tell: Fault Localization using Time Spectra</h3>
<p>Authors: Cemal Yilmaz, Amit Paradkar, Clay Williams (IBM T.J. Watson Labs)</p>
<p>This idea and the presentation were both rather interesting.  The presenter claimed that method execution time could be used to localize defects in source code.  The technique operated in two phases: 1) Using passing test cases, execution times are correlated with the execution times of other methods, then 2) a failing test case is run and then look for a execution time that is outside the coloration model.</p>
<p>When the time for questions came around, I think some people forgot that the technique was only for localizing errors that were known to exist rather than detecting errors outright.  This lead to questioning how the technique compared to stack traces (complementary,  esp. once the trace doesn’t immediately work) and questions about the specific technique for correlation (anything will work at first to prove the concept, better techniques can be used later).</p>
<h3>Precise Memory Leak Detection for Java Software Using Container Profiling</h3>
<p>Authors: Guoqing Xu, Atanas Rountev</p>
<p>At first, I found most of this presentation rather obvious.  The idea that Java leaks memory (via objects) is well known.  In order to leak them, they have to still be referenced, but not directly.  The reference has to be somewhat anonymous, otherwise the object is “owned” by someone which (when applied recursively) means that it’s either active or a candidate for GC.  The primary way to keep an object around without “owning” it is via some sort of container.  (In my practice, the biggest memory leak in Java is actually String.subString()’s implementation detail, but that’s another topic)</p>
<p>Ok, so once we assume that most memory leaks are due to objects loosing their identity and ownership by being placed in a container, then this paper proposes a technique for figuring out which container in the application is holding the leaking objects.  Basically, containers are ranked based on how much memory they (and their contents) consume through a deep traversal of the object graph.   They are also ranked based on a staleness metric (see the paper for exact details) which measures how long an object hangs out in a container after it retrieved (via get).</p>
<p>On the surface it seems like a reasonable idea, but in practice I would expect many cases where containers are working as designed when they <i>cache</i> large objects for long periods of time.  If (and how) the authors account for this will be interesting to find out.</p>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/21.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Omnet++ and Eclipse</title>
		<link>http://dstovall.com/posts/20.html</link>
		<comments>http://dstovall.com/posts/20.html#comments</comments>
		<pubDate>Mon, 14 Apr 2008 23:09:59 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c/c++]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[OMNet]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=20</guid>
		<description><![CDATA[So if I&#8217;m going to take the plunge to learn c++ just so that I can use the Omnet simulator, I  better have some decent tools to figure out what&#8217;s going wrong.
Since it&#8217;s likely that I&#8217;ll be doing some development on my windows machine and some on Ubuntu boxes, I&#8217;m opting for an Eclipse-based [...]]]></description>
			<content:encoded><![CDATA[<p>So if I&#8217;m going to take the plunge to learn c++ just so that I can use the Omnet simulator, I  better have some decent tools to figure out what&#8217;s going wrong.</p>
<p>Since it&#8217;s likely that I&#8217;ll be doing some development on my windows machine and some on Ubuntu boxes, I&#8217;m opting for an Eclipse-based development environment.  Unfortunately, it&#8217;s not so trivial to get everything working together, so here I am with yet another guide to what I&#8217;ve done to get my setup working. I hope it helps someone else out there&#8230;<br />
<span id="more-20"></span></p>
<h3>Eclipse and CDT</h3>
<p>Downloading and installing Eclipse, and getting a couple &#8220;Hello World&#8221; apps up and going is the first step.  Go do this and come back</p>
<h3>OMNet Install</h3>
<p>The OMNet install should be pretty straight forward.  It&#8217;s likely that you&#8217;ll need to use the setup tool (cygwin:setup.exe, ubuntu:apt-get) again to install some missing packages, but the configure script it pretty good about telling you what you&#8217;re missing.</p>
<blockquote><p><code>./configure<br />
make</code></p></blockquote>
<h4>Omnet dependency: BLT</h4>
<p>I never did get the developer extensions for BLT installed, but I did find an executable for BLT on the sourceforge site.  This was close enough for me.  I just dropped the (renamed) blt.exe into my <code>bin</code> directory that was already in my path.</p>
<h4>Omnet dependency: giftrans</h4>
<p>Again, I never did get this installed &#8216;correctly&#8217;, but I did find an executable version somewhere on the web and dropped it into my <code>bin</code> directory.</p>
<h3>Omnet Verification</h3>
<p>Ok, so now OMNet should be working, but we need to verify that first.  Go to the tictoc sample and run it.  This should work no problem.</p>
<blockquote><p><code>cd samples/tictoc/<br />
./tictock.exe</code> or <code>./tictoc</code></p></blockquote>
<h3>Update OMNet to include debug information</h3>
<p>Before going too much further, take a second now to edit the <code>configure.user</code> file. Uncomment this line:<br />
<code>CFLAGS='-g -Wall'" and </code><br />
and comment out the others.  Then recompile Omnet again to include these options.</p>
<blockquote><p><code>./configure<br />
make clean<br />
make</code></p></blockquote>
<h3>Create the Eclipse Project</h3>
<p>First, create a new project:</p>
<ol>
<li>From the workbench, <code>File -> New -> C++ Project</code></li>
<li>Project Name: tictoc</li>
<li>Project Type: Makefile project</li>
<li>Toolchain: &#8212; Other Toolchain &#8211;</li>
<li>Finish</li>
</ol>
<p>Then we need to get the code in there&#8230; Copy the contents of the tictoc sample directory into the new tictoc directory under your eclipse workspace directory.  Then clean it, just to be sure&#8230;</p>
<blockquote><p><code>cd /c/dev/eclipse-workspace/tictoc<br />
cp /c/bin/omnetpp-3.3/samples/tictoc/* .<br />
make clean</code></p></blockquote>
<p>If you try to build, eclipse will complain that there&#8217;s <code>no rule to make target `all'</code>.  This is because eclipse by default tries to run &#8220;make all&#8221; rather then just &#8220;make&#8221;.  Fix this:</p>
<ol>
<li>From the workbench, <code>Project -> Properties</code></li>
<li>On left: C/C++ Build</li>
<li>On Right: &#8220;Behaviour&#8221; tab</li>
<li>Clear the text field next to &#8220;build (incremental build)&#8221;</li>
<li>Ok</li>
</ol>
<p>Now you should be able to build.  Clicking the little hammer icon should cause the console to start scolling with make output, or report that `tictoc is up to date&#8217;.</p>
<h3>Try debugging!</h3>
<p>Before we start, throw a break-point on the <code>send(msg, "out");</code> line of <code>txc1.cc</code>.  When the debugger stops on this line, you&#8217;ll know you&#8217;re done.</p>
<p>Now, we need to set the binary parser option so that eclipse recognizes the executable that we are producing:</p>
<ol>
<li>From the workbench, <code>Project -> Properties</code></li>
<li>On left: C/C++ Build -> Settings</li>
<li>On Right: &#8220;Binary parsers&#8221; tab</li>
<li>Check the &#8220;Cygwin PE Parser&#8221; option</li>
<li>Ok</li>
</ol>
<p>Now create the debug configuration:</p>
<ol>
<li>From the workbench, <code>Run -> Open Debug Dialog</code></li>
<li>On left: C/C++ Local Application</li>
<li>At the top: The &#8216;new&#8217; icon</li>
<li>On Right: Project &#8220;tictoc&#8221;</li>
<li>On Right: C/C++ Application: &#8220;tictoc.exe&#8221; (hopefully this is filled in for you already)</li>
<li>Debug!</li>
</ol>
<p>If you&#8217;re using Cygwin, you&#8217;ll likely run into the problem below.  Otherwise, you should be done.  Congrats!</p>
<h4>Can&#8217;t launch debugger:  &#8230;No symbol table is loaded&#8230;</h4>
<p>(I think this only applies to Cygwin users)<br />
This was the most aggravating bug to fix, mostly because the message boards all looked like this:</p>
<blockquote><p><code><span style="color:blue">Newbie: I'm getting this error: ....</span><br />
<span style="color:red">"Expert": Try gdb.<br />
"Expert": Try the -g option<br />
"Expert": Try google first, n00b!</code></code>
</p></blockquote>
<p>Gee... you think I should google stuff before posting a question?  Come on people.  Turns out that the <code>-s</code> option to the linker is hard-coded into the <code>opp_makemake</code> script.  The <code>-s</code> <a href="http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html">does the following</a>:</p>
<blockquote><p>Remove all symbol table and relocation information from the executable.</p></blockquote>
<p>So, golly, it's OMNet's make files that are to blame... not the newbie... go figure.</p>
<p>So to fix this, you can either remove the option from Omnet's configure script (permanent), or you can always remember to remove it from the generated <code>Makefile</code> (not permanent).  I opted for the later since (a) it'll be obvious when I forget and (b) my omnet install will be as standard as possible.</p>
<ol>
<li>Open the generated Makefile in the tictoc directory</li>
<li>Find the line that defines "LDFLAGS"</li>
<li>Remove the option "-s"</li>
<li>Save</li>
<li>From the workbench, <code>Project -> Clean...</code></li>
<li>From the workbench, <code>Project -> Build Project</code></li>
<li>From the workbench, Click the debug button</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/20.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JSimpleModule Step-by-step</title>
		<link>http://dstovall.com/posts/19.html</link>
		<comments>http://dstovall.com/posts/19.html#comments</comments>
		<pubDate>Tue, 08 Apr 2008 22:44:39 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[JSimpleModule]]></category>
		<category><![CDATA[OMNet]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=19</guid>
		<description><![CDATA[First things first
First off, make sure that you have java installed and that you have your JAVA_HOME environment variable set.  To check for java, just run java and see what happens.  If there&#8217;s no program by that name, go install java&#8230;
You also want to make sure that your JAVA_HOME environment variable is set, [...]]]></description>
			<content:encoded><![CDATA[<h3>First things first</h3>
<p>First off, make sure that you have java installed and that you have your JAVA_HOME environment variable set.  To check for java, just run <code>java</code> and see what happens.  If there&#8217;s no program by that name, go install java&#8230;</p>
<p>You also want to make sure that your <code>JAVA_HOME</code> environment variable is set, and to make sure that there is no trailing &#8220;<code>/</code>&#8221; on the value.  To check it: <code>echo $JAVA_HOME</code></p>
<h3>Download/Extract JSimpleModule</h3>
<p>You can use these commands to download and extract JSimpleModule:</p>
<blockquote><p><code>wget&nbsp;http://www.omnetpp.org/filemgmt/visit.php?lid=126<br />
tar xzvf jsimplemodule-3.3-1.tgz<br />
</code></p></blockquote>
<p><span id="more-19"></span></p>
<h3>Attempt to build JSimpleModule</h3>
<p>Nominally, the following is what you should have to do in order to compile the base JSimpleModule code.  However, you will probably run into one of the two problems below.  Repeat the last two steps until you can successfully compile these files.</p>
<blockquote><p><code><br />
cd jsimplemodule-3.3-1<br />
cp makefrag.SAMPLE makefrag<br />
opp_makemake -f<br />
make<br />
</code></p></blockquote>
<h4>Script Error: Can&#8217;t open opp_makedep</h4>
<p>if you get an error like this:</p>
<blockquote><p><code>/bin/sh: Can't open opp_makedep<br />
Error: command 'opp_makedep -Y --objdirtree  -fMakefile -- *.cc' returned nonzero exit code</code></p></blockquote>
<p>You&#8217;re probably using Ubuntu 6.10+.  There&#8217;s a <a href="http://omnetpp.org/listarchive/msg08030.php">mailing list post</a> that describes the problem (ubuntu changed the default shell).  The easiest fix is like this:</p>
<blockquote><p><code>cd /bin<br />
sudo mv sh sh.orig<br />
sudo ln -s bash sh</code></p></blockquote>
<h4>Compile Error: &#8230;SetBooleanField&#8230;</h4>
<p>At this point, I started getting compile errors that looked something like this:</p>
<blockquote><p><code>JUtil.cc: In member function â??void JObjectAccess::setBooleanJavaField(const char*, jboolean):<br />
JUtil.cc:153: error: JUtil::jenv->JNIEnv_::SetBooleanField(((JObjectAccess*)this)->JObjectAccess::javaPeer, fieldID, ((int)value)) has type void and is not a throw-expression</code></p></blockquote>
<p>I have yet to see any &#8220;official response&#8221;, but the fix seems to be to turning some of the in-line conditionals into full conditionals.  Please see <a href="http://www.omnetpp.org/listarchive/msg10714.php">Nuno Alexandre Carvalho&#8217;s mailing list post</a> for details on fixing this problem.</p>
<h3>Get the example java simulations working</h3>
<p>First thing to do is to get this working using the files that are provided.  After that, we can start renaming and moving things around to make more sense.  For now, just bare with me, &#8216;k.</p>
<p>The shell script &#8220;<code>run</code>&#8221; has the wrong line delimiters in it (it was created by a windows/dos machine).  To fix this:</p>
<blockquote><p><code>dos2unix run</code></p></blockquote>
<p>This script calls a program &#8220;./yoursimulation&#8221;.  This doesn&#8217;t exist in the directory, so we need to find it.  Turns out that all we need is the executable that we compiled in the previous section.  Since I don&#8217;t like extra copies of stuff hanging around and getting out-of-date, let&#8217;s just make a link:</p>
<blockquote><p><code>ln -s ../jsimplemodule-3.3-1 yoursimulation</code></p></blockquote>
<p>That should be all we need.  Let&#8217;s try running it:</p>
<blockquote><p><code>./run</code></p></blockquote>
<p>And viola&#8230; the Omnet simulation windows open up (hopefully).</p>
<h4>Can&#8217;t run: Core dump</h4>
<p>This is another problem that <a href="http://www.omnetpp.org/listarchive/msg10714.php">Nuno Alexandre Carvalho&#8217;s mailing list post</a> addresses.  Go back to the <code>jsimplemodule-3.3-1</code> directory and edit the file <code>Makefile</code> manually.  Find the line that looks like this:</p>
<blockquote><p><code>CFLAGS=-O2 ...</code></p></blockquote>
<p>and make it look like this (by removing the &#8220;<code>2</code>&#8221; after &#8220;<code>-O</code>&#8221;</p>
<blockquote><p><code>CFLAGS=-O ...</code></p></blockquote>
<p>Then, from the command line, rebuild:</p>
<blockquote><p><code>make clean; make</code></p></blockquote>
<h4>Can&#8217;t run: libjvm.so: cannot open shared object file&#8230;</h4>
<p>This is an indication that your LD_LIBRARY_PATH environment variable isn&#8217;t setup quite right.  In my LD_LIBRARY_PATH, I need to include <cope>/usr/lib/jvm/java-6-sun-1.6&#8230;/jre/lib/i386/client/</code>.  You may notice that this is smore eomewhat similar to the <code>PATH</code> variable set up in the <code>run</code> script, so I would actually recommend adding the following line to your <code>run</code> script:</p>
<blockquote><p><code>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386/client</code></p></blockquote>
<h3>Make it pretty</h3>
<p>At this point, you've got something that works, so it's time to make a backup copy! <img src='http://dstovall.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Once you've done that, copy the example directory out of the <code>jsimplemodule</code> directory, and update the reference to "<code>../simkernel.jar</code>" in the <code>run</code> script.  (I use another soft link in the same directory, but an environment variable or absolute path will work fine too)  Then update the link "<code>yoursimulation</code>" to "<code>jsimplemodule-3.3-1</code>" or something similar, and update the last line in the <code>run</code> script to match.</p>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/19.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expose different data formats when using REST</title>
		<link>http://dstovall.com/posts/3.html</link>
		<comments>http://dstovall.com/posts/3.html#comments</comments>
		<pubDate>Tue, 12 Feb 2008 22:15:41 +0000</pubDate>
		<dc:creator>dstovall</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://dstovall.com/?p=3</guid>
		<description><![CDATA[
This article caught my eye today: RESTful SOA using XML.  Since I&#8217;ve been helping a friend to flush out some RESTful service ideas of his own, I wanted to make a comment on this topic&#8230;


Generally, the point of using RESTful patterns is to make the information easier to consume.  For IBM (and  [...]]]></description>
			<content:encoded><![CDATA[<p>
This article caught my eye today: <a href="http://www.ibm.com/developerworks/java/library/x-restfulsoa/index.html" title="RESTful SOA using XML" target="_blank">RESTful SOA using XML</a>.  Since I&#8217;ve been helping a friend to flush out some RESTful service ideas of his own, I wanted to make a comment on this topic&#8230;
</p>
<p>
Generally, the point of using RESTful patterns is to make the information easier to consume.  For IBM (and  a lot of programmers), &quot;easy to consume&quot; immediately spawns images of XML and automatically generated parsers or XStream or whatever.  For me (and a lot of programmers), this same idea spawns ideas of <code>.properties</code>, JSON, flat text, and even HTML&#8230;
</p>
<p>
If you&#8217;re writing a web service to expose data to a customer, then shouldn&#8217;t you build in support for providing data in their format?  After all, &quot;easy to consume&quot; is a valuable trait for data to support. In the interest of supporting the wide variety of people that will eventually be clambering at our door for data, let&#8217;s allow them to select their data format.  So instead of using these URI&#8217;s:
</p>
<blockquote><p><span class="code"><br />
http://luggagetracking.airlinecompany.com/bags/{id} http://luggagetracking.airlinecompany.com/flights/{id} http://luggagetracking.airlinecompany.com/travellers/{id}<br />
</span><br />
<cite><a href="http://www.ibm.com/developerworks/java/library/x-restfulsoa/index.html" title="RESTful SOA using XML" target="_blank">RESTful SOA using XML</a></cite>
</p></blockquote>
<p>
Add the little bit of extra code to expose these URI&#8217;s:
</p>
<blockquote><p>
<span class="code"><br />
http://luggagetracking.airlinecompany.com/bags/{id}.xml http://luggagetracking.airlinecompany.com/flights/{id}.xml http://luggagetracking.airlinecompany.com/travellers/{id}.xml</p>
<p>http://luggagetracking.airlinecompany.com/bags/{id}.properties http://luggagetracking.airlinecompany.com/flights/{id}.properties http://luggagetracking.airlinecompany.com/travellers/{id}.properties</p>
<p>http://luggagetracking.airlinecompany.com/bags/{id}.html http://luggagetracking.airlinecompany.com/flights/{id}.html http://luggagetracking.airlinecompany.com/travellers/{id}.html<br />
</span>
</p></blockquote>
<p>
In the article above, we&#8217;re already shown how to use regular expressions to parse the interesting bits from the requested url, so switching to a different view based on a file name extension is fairly straight forward.  For those of you who are more advanced, this file extension could be cross-referenced with the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">HTTP Accept header</a> to provide even more complex format selection.
</p>
<p>
Now I know that some of you are likely responding with doubts.  The most likely of these is that exposing the same data in different formats probably isn&#8217;t will be worth the investment&#8230;  and it may not be.  It&#8217;s unlikely that your web service will greatly benefit from exposing multiple data formats right out of the blocks.  <em>However</em>, by building in the assumption that you will do so later, you (a) help guarantee that your view layer will indeed be separated from your model and controllers, and (b) lower the cost of future integration or migration projects.
</p>
<p>
That brings me to the motivating scenario that I have in my head&#8230; For the application my friend is developing, we need to be able to show lay-people what the service &#8220;looks like&#8221; to remote devices.  Showing a machine-readable version of the service&#8217;s data to these people is silly.  Even if XML was human readable (it&#8217;s not), the verbose overhead associated with it makes it relatively unattractive to look at.  But HTML&#8230; now that (can) look good to people.  By using an XML-based template when a .xml URL is requested, and a HTML-based template with a <code>.html</code> URL is requested, we can be friendly to the casual on-looker.
</p>
<p>
Down the line, we can also use this technique to help integrate test harnesses, debug views, and data documentation.  For example, if the data provided by the service seems to be wrong, we take the request (<code>http://foo.com/bar/baz.xml</code>) and swap in <code>.html</code> for <code>.xml</code> and a host of documentation is included along with the data values.  Request <code>http://foo.com/bar/baz.debug-html</code> and you get a host of debugging information as well.  Whoa, cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://dstovall.com/posts/3.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
