<?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>Matt Keally&#039;s Blog &#187; development</title>
	<atom:link href="http://www.keally.org/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.keally.org</link>
	<description>Life of the ABD grad student...</description>
	<lastBuildDate>Tue, 27 Jul 2010 21:32:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Low Level Serial Control in TinyOS</title>
		<link>http://www.keally.org/2010/03/30/low-level-serial-control-in-tinyos/</link>
		<comments>http://www.keally.org/2010/03/30/low-level-serial-control-in-tinyos/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 16:38:20 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=1137</guid>
		<description><![CDATA[It&#8217;s been awhile since my last TinyOS post, but a new project required me to return to programming motes.  In this case, we needed to send ASCII characters over the serial port to the PC, bypassing the default TinyOS serial stack. The TinyOS serial stack is designed to work with Active Messages so that packets [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been awhile since my last TinyOS post, but a new project required me to return to programming motes.  In this case, we needed to send ASCII characters over the serial port to the PC, bypassing the default TinyOS serial stack.</p>
<p>The <a href="http://www.tinyos.net/tinyos-2.x/doc/html/tep113.html">TinyOS serial stack</a> is designed to work with Active Messages so that packets received over the radio can be easily forwarded on to the PC.  To that end, the high-level serial and radio components provide the same interfaces.  The TinyOS serial stack has layers for packet formatting, error checking, and a read/write buffer.  However, for our project, we wanted to simplify the PC side so we didn&#8217;t have to use the TinyOS JNI libraries to receive TinyOS Active Message packets.  A simple program to read ASCII characters over the serial connection would suffice for our purposes &#8212; <a href="http://en.wikipedia.org/wiki/Minicom">Minicom</a> does this quite well and is easily installed on Ubuntu Linux and can be configured to read from attached USB devices.</p>
<p>The goal was to produce a TinyOS component that provided a command for transmitting ASCII character strings over the serial connection to a PC.  The  implementation is very similar to the <a href="http://www.keally.org/2009/06/15/bci-pulse-oximeter-in-tinyos-2-1/"><span style="color: #000000;">Pulse Oximeter</span></a> code I wrote for Atmel-based devices, however this time I targeted MSP430-based devices, such as the TelosB or Tmote Sky.  The implementation uses the <code>Msp430Uart1C</code> component for accessing the serial connection.  This component provides the <code>UartByte</code> or <code>UartStream</code> interfaces for reading and writing and the <code>Resource</code> interface for gaining control of the UART.  <code>Msp430Uart1C</code> also provides the <code>Msp430UartConfigure</code> interface for setting the baud rate.</p>
<p>The control flow for writing a character string is as follows: First, request the UART resource.  Second, when the resource has been granted, call <code>UartStream.send()</code> to transmit the string.  Lastly, when <code>UartStream.sendDone()</code> is signaled, signal the higher level application that the character string has been sent or an error message if something went wrong.  In my <code>SerialAscii</code> module, I have the following command to send a character string:</p>
<pre>  command error_t SerialAscii.sendAscii(char *str)
  {
    bufferLength = strlen(str);
    if(bufferLength &gt; BUFFER_SIZE)
      return FAIL;
    memcpy(strBuffer,str,bufferLength);  // copy string into a buffer
    call Resource.request(); // request access to the UART
    return SUCCESS;
  }</pre>
<p>I copy the string into a buffer to keep the application from modifying it before being transmitted.  When the resource request is granted, I transmit the string:</p>
<pre>  event void Resource.granted()
  {
    error_t result = call UartStream.send(strBuffer,bufferLength);
    if(result == FAIL)
      post sendDoneFailTask();  // return failure message to the user if something bad happened
  }</pre>
<p>Lastly, when the string is sent, I release the resource and signal the higher level application:</p>
<pre>  async event void UartStream.sendDone(uint8_t *buf, uint16_t len, error_t error)
  {
    // call Resource.release() in each of these tasks
    if(error == SUCCESS)
      post sendDoneSuccessTask(); // signal SerialAscii.sendAsciiDone(SUCCESS);
    else
      post sendDoneFailTask(); // signal SerialAscii.sendAsciiDone(FAIL);
  }</pre>
<p>I&#8217;ve made my code available <a href="http://www.cs.wm.edu/~makeal/projects/serialAscii/SerialAscii.tar.gz">here</a>.  Let me know if you find any bugs or have any comments or suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2010/03/30/low-level-serial-control-in-tinyos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BCI Pulse Oximeter in TinyOS 2.1</title>
		<link>http://www.keally.org/2009/06/15/bci-pulse-oximeter-in-tinyos-2-1/</link>
		<comments>http://www.keally.org/2009/06/15/bci-pulse-oximeter-in-tinyos-2-1/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 00:33:54 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mts310]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[school]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=748</guid>
		<description><![CDATA[After days of getting lost in TinyOS 1.1 and 2.1 low level hardware abstractions, the Harvard design BCI pulse oximeter now works in TinyOS 2.1. Prior to writing the driver/interface code, I had to procure the pulseox hardware.  Detailed descriptions of hardware, software, and applications are found at the Harvard CodeBlue website.  I first ordered [...]]]></description>
			<content:encoded><![CDATA[<p>After days of getting lost in TinyOS 1.1 and 2.1 low level hardware abstractions, the Harvard design BCI pulse oximeter now works in TinyOS 2.1.</p>
<p>Prior to writing the driver/interface code, I had to procure the pulseox hardware.  Detailed descriptions of hardware, software, and applications are found at the <a href="http://fiji.eecs.harvard.edu/CodeBlue">Harvard CodeBlue website</a>.  I first ordered a <a href="http://www.smiths-medical.com/bci-oem/">Smiths Medical OEM Digital Micro Power Pulse Oximeter Board</a>.  I was able to get in contact with sales staff by emailing Smiths Medical.  The pulseox board comes with a finger sensor and runs about $200.</p>
<p>Next, I needed an interface board to connect the BCI pulseox board to the 51 pin connector on the Crossbow IRIS.  The Harvard CodeBlue source code has documentation for a PCB layout and suggests that you order the PCB from an online manufacturer.  You also have to purchase some other components that must be soldered onto the interface board.  Fortunately, I was able to &#8220;skip&#8221; this step with the help of <a href="http://www.cs.virginia.edu/~ls2ef/">Leo Selavo</a>, who graciously supplied me with two interface boards.  He emphasized that soldering the components onto the interface board requires a lot of skill and experience and if I were to try on my own that I would most likely break the PCB or components several times until I got it right.  The setup with pulseox board, interface board, IRIS mote, and finger sensor is illustrated below:</p>
<div id="attachment_752" class="wp-caption aligncenter" style="width: 410px"><a rel="attachment wp-att-752" href="http://www.keally.org/2009/06/15/bci-pulse-oximeter-in-tinyos-2-1/bciirissm/"><img class="size-full wp-image-752" title="Pulse Oximeter on IRIS" src="http://www.keally.org/wp-content/uploads/2009/06/bciIrisSm.jpg" alt="Pulse Oximeter on IRIS" width="400" height="300" /></a><p class="wp-caption-text">Pulse Oximeter on IRIS</p></div>
<p>With the pulseox board, interface board, and of course IRIS mote, I was ready to get my heart rate.  The biggest challenge still lay ahead: writing code to interface with the pulseox.  The CodeBlue pulseox code was written in 2005 for TinyOS 1.0.  All of the low level UART and mote hardware interfaces have changed drastically since then, so the old code wouldn&#8217;t just work right out of the box.  I had seen plenty of posts on the CodeBlue mailing list about implementations for the pulseox in TinyOS 2.x, but nobody had bitten the bullet and actually written anything.</p>
<p>What I wanted was to be able to use the pulseox like a sensor on the MTS300/310 sensorboard: call a Pulse.read() or Oxygen.read() command and get back a uint16_t with pulse or blood oxygen saturation.  This is fairly straightforward since I had experience <a href="2009/05/14/mts300310-sensorboard-sampling-multiple-sensors-simultaneously/">modifying the MTS310 sensorboard code to power on the sensors manually</a>.  I created configurations PulseC and OxygenC to provide SplitControl and Read interfaces to power on the sensor and read, respectively.  I then wired PulseC and OxygenC to a PulseoxP, which functioned as an intermediary between the application and the low-level pulseox driver code.  Like in the original CodeBlue source, I created a BciC configuration and BciP implementation to communicate with the pulseox directly through the UART and return data back to PulseoxP.</p>
<p>The key changes between the CodeBlue TinyOS 1.0 code and my implementation are all found in BciP (or BCIM.nc in the original CodeBlue source).  Two issues come to mind.  First, setting the mote hardware pins is done differently in TinyOS 2.1.  Calls like TOSH_SET_PW0_PIN() are replaced by abstractions.  I had to wire MicaBusC.PW0 to the GeneralIO interface in BciC and then call GeneralIO.set() in BciP.</p>
<p>The second difference is with the UART.  TinyOS 1.0 uses the HPLUART interface for low level UART communication, but this has been replaced by Atm128Uart0C for the Atmel 1281 architecture.  The CodeBlue source code initializes the low level UART to its default state, turns it off, and then sets the hardware registers to the desired UART configuration so that the mote can communicate with the pulseox board.  After figuring out what the CodeBlue UART configuration code did, I can&#8217;t believe that you can actually write to the registers directly!  Imagine if you could do that with user-level code on a PC!  To enable transmissions and reception along with interrupts for the UART in TinyOS 1.x, you had to do the following:<br />
<code><br />
// Enable tx/rx interrupts and tx/rx<br />
outp(((1 &lt;&lt; RXCIE) | (1 &lt;&lt; TXCIE) | (1 &lt;&lt; RXEN) | (1 &lt;&lt; TXEN)) ,UCSR0B);<br />
</code><br />
TinyOS 1.0 uses the outp() macro to set bits of a given register, but this macro does not exist in TinyOS 2.x.  Instead, the UART register bits are configured in a struct with fields for each bit in the register.  For the above example in TinyOS 2.1, the following union represents the control register in Atm128Uart.h:<br />
<code><br />
/* UART Control Register */<br />
typedef union {<br />
struct Atm128_UCSRB_t {<br />
uint8_t txb8  : 1;  //!&lt; UART Transmit Data Bit 8<br />
uint8_t rxb8  : 1;  //!&lt; UART Receive Data Bit 8<br />
uint8_t ucsz2 : 1;  //!&lt; UART Character Size (Bit 2)<br />
uint8_t txen  : 1;  //!&lt; UART Transmitter Enable<br />
uint8_t rxen  : 1;  //!&lt; UART Receiver Enable<br />
uint8_t udrie : 1;  //!&lt; USART Data Register Enable<br />
uint8_t txcie : 1;  //!&lt; UART TX Complete Interrupt Enable<br />
uint8_t rxcie : 1;  //!&lt; UART RX Complete Interrupt Enable<br />
} bits;<br />
uint8_t flat;<br />
} Atm128UartControl_t;<br />
</code><br />
The flat uint8_t is a real slick way to convert all the elements in the struct to a single word, which can then be written to the register.  Following the code that initializes the UART in tos/chips/atm128/HplAtm128UartP.nc, I was able to configure the UART to run with the pulseox board requirements: 4800 baud, double rate, transmission and reception interrupts enabled, no parity checking, 1 stop bit, and 8 bit word size.  So, with the previous example to enable transmissions and reception, you do the following in TinyOS 2.x:<br />
<code><br />
Atm128UartControl_t ctrl;<br />
ctrl.bits = (struct Atm128_UCSRB_t) {rxcie:1, txcie:1, rxen:1, txen:1};<br />
UCSR0B = ctrl.flat; // ctrl.flat<br />
</code><br />
I ran my concerns by the CodeBlue mailing list, which elicited a reply from <a href="http://www.eecs.harvard.edu/~mdw/">Prof. Matt Welsh</a> that I was headed in the right direction.  I finished my implementation, worked out some compile errors, and loaded the new pulseox and general data collection code onto a mote to see what would happen.  Almost never does my TinyOS code run correctly on the first try &#8212; usually I spend hours or days debugging, but this time it was magic.  A number jumped onto the screen in the data column of my PC Java application, which was connected wirelessly though a base station mote to the pulseox mote.  The sensor readings seemed reasonable for a heart rate, for jumping up and down and breathing hard made it go up and laying down and trying to breathe slowly made it slow down.</p>
<div id="attachment_753" class="wp-caption aligncenter" style="width: 471px"><a rel="attachment wp-att-753" href="http://www.keally.org/2009/06/15/bci-pulse-oximeter-in-tinyos-2-1/pulseoxdata/"><img class="size-full wp-image-753" title="Pulse Oximeter data returned to PC" src="http://www.keally.org/wp-content/uploads/2009/06/pulseoxData.jpg" alt="Pulse Oximeter Reading" width="461" height="77" /></a><p class="wp-caption-text">Pulse Oximeter Reading</p></div>
<p>I have made my <a href="http://www.cs.wm.edu/~makeal/projects/pulseox/pulseox.zip">code available here</a> and any feedback, suggestions, or questions are encouraged.  To use it, place the pulseox directory into the tos/sensorboards directory in TinyOS 2.x.  In the makefile for your application, add the line &#8220;SENSORBOARD=pulseox&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/06/15/bci-pulse-oximeter-in-tinyos-2-1/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>MTS300/310 Sensorboard: Sampling multiple sensors simultaneously</title>
		<link>http://www.keally.org/2009/05/14/mts300310-sensorboard-sampling-multiple-sensors-simultaneously/</link>
		<comments>http://www.keally.org/2009/05/14/mts300310-sensorboard-sampling-multiple-sensors-simultaneously/#comments</comments>
		<pubDate>Thu, 14 May 2009 21:27:23 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mts310]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=680</guid>
		<description><![CDATA[My current project involves sampling data with the Crossbow Iris and MTS310 sensorboard. I wish to sample data at regular intervals, say 20ms, using all available modalities on the MTS310: x and y-axis accelerometer, x and y-axis magnetometer, light, temperature, and acoustic. Every 20ms, a timer fires and collects data samples from each sensor using [...]]]></description>
			<content:encoded><![CDATA[<p>My current project involves sampling data with the <a href="http://www.xbow.com/Products/productdetails.aspx?sid=264">Crossbow Iris</a> and <a href="http://www.xbow.com/Products/productdetails.aspx?sid=177">MTS310 sensorboard</a>.  I wish to sample data at regular intervals, say 20ms, using all available modalities on the MTS310: x and y-axis accelerometer, x and y-axis magnetometer, light, temperature, and acoustic.  Every 20ms, a timer fires and collects data samples from each sensor using the Read interface.  As it turns out, the current TinyOS 2.x code for the MTS300/310 does not allow this.</p>
<p>I found that every time I called Read.read() for some of the sensors, that there would often be a delay in getting my data back with Read.readDone().  This delay was because each call to Read.read() would power on the sensor, requiring a warm-up time before a sample could be retrieved.  While the warm-up time for the accelerometer is 17ms, the warm-up time for the light sensor is an excruciatingly long 1200ms!  So, I would call Read.read() at 20ms intervals, but have to wait over a second to get data from the light sensor.  When the data sample is returned at Read.readDone(), the sensor would power off again, thus requiring another warm-up the next time a sample is requested.  Basically, the constant warm-up lag in the current TinyOS code prevents sampling at a reasonably fast rate using Read.</p>
<p>I also found that if I wished to get both axes of the accelerometer or magnetometer simultaneously, that only one axis would ever return data.  The accelerometer, magnetometer, and light/photo sensors use the ArbitratedResource interface to block all other sensors that use the same resource when one sensor has a lock on the resource.  If the x-axis accelerometer was sampling with Read.read(), it would have a lock on a UQ_ACCEL_RESOURCE identifier, preventing the y-axis from sampling simultaneously, since its resource is also identified by UQ_ACCEL_RESOURCE.  I wasn&#8217;t the only one with these problems, as illustrated by <a href="https://www.millennium.berkeley.edu/pipermail/tinyos-help/2009-January/037930.html">this TinyOS mailing list post</a>.  The mailing list poster also points out that the ReadStream interface blocks data sampling for all sensors but the first one that calls it: if you try using ReadStream to get streaming data for the accelerometer x-axis and the magnetometer x-axis, the call to ReadStream.read() for the accelerometer would block the sampling of the magnetometer if it was called first.  With ReadStream, all sensors use the same resource identifier, so when one is sampling, it has the lock, and all others must wait.  The resource arbitration effectively prevents multiple sensors from sampling data simultaneously using ReadStream.</p>
<p>This automated power control for Read as well as the blocking for Read and ReadStream really limits the functionality of the sensorboard.  Initially, I thought it was a hardware constraint.  You would think that since the board has all those sensors on it, the manufacturers would have designed it such that you can use all the sensors at the same time.  It turns out, that it isn&#8217;t a hardware problem &#8212; it&#8217;s just that the MTS300/310 sensorboard code is written so you can only effectively use one sensor at a time.  I managed to change this by modifiying the behavior of the Read.read() of every MTS sensor.</p>
<p>The current TinyOS code uses SplitControlPowerManagerC to power on the sensor when you call Read.read().  Read.read() triggers the power manager to call the sensor&#8217;s SplitControl interface.  Supposedly, when Read.readDone() is signaled and the sensor data is ready, the power manager will keep the sensor powered on for some amount of time in case the sensor is needed again &#8212; this is from the comments in PowerManagerP.nc.   However, from my testing, there is no evidence that the sensor stays on after Read.readDone() is signaled.  The warm-up routine starts all over again the next time Read.read() is called.  It&#8217;s possible that 20ms is too much time between samples, but it appears from the power manager code that the sensor is turned off immediately if no resource requests for that sensor are pending.  Currently, I can&#8217;t find anywhere in the MTS310 sensorboard code or in the power manager code where some kind of backoff timer is set before powering down the sensor.</p>
<p>To that end, I eliminated this automated power control through the power manager.  I altered each sensor&#8217;s interface in the mts300 code library so that each sensor provided a SplitControl interface.  This now allows me to manually power on each sensor I want to use before I start sampling.  I then have a timer call Read.read() at regular intervals for each sensor I want, which returns the data with Read.readDone().  When I&#8217;m done sampling, I can turn the sensors off.</p>
<p>The current code is more a less a hack and has a weird side effect.  For example, since the x and y-axis accelerometers use the same AccelP module with the same SplitControl power interface, only one accelerometer has to call SplitControl.start() to turn the sensor on.  The same goes for the magnetometer and the light/photo sensors, as well as for calling SplitControl.stop() to power down the sensors.  Otherwise, the warm-up/power on sequence is triggered twice for the same sensor if you want to use both axes of the accelerometer or magnetometer, or wish to use both light and temperature sensors. <em>Edit: this issue has been fixed in the code.  Calling SplitControl.start() for both axes of the accelerometer/magnetometer will only run the power on sequence once, but both calls will return SplitControl.startDone().  The same applies for SplitControl.stop().</em></p>
<p>The modified sensorboard code can be <a href="http://www.cs.wm.edu/~makeal/projects/mts310/mts310.zip">downloaded here</a>, which is a zipped directory of all the mts300 sensor code, but changed to mts310.  Just unzip it into the tos/sensorboards directory.  The configurations AccelXC, AccelYC, MagXC, MagYC, MicC, PhotoC, and TempC have all been modified to provide the SplitControl interface, so for example you can call AccelXC.start() to power on the accelerometer, then AccelXC.read() to get data, and then AccelXC.stop() to power the accelerometer off.  I&#8217;ve used this extensively with the accelerometers, magnetometers, acoustic, and light sensors and it seems to work without any issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/05/14/mts300310-sensorboard-sampling-multiple-sensors-simultaneously/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>When motelist doesn&#8217;t see your motes&#8230;</title>
		<link>http://www.keally.org/2009/02/28/when-motelist-doesnt-see-your-motes/</link>
		<comments>http://www.keally.org/2009/02/28/when-motelist-doesnt-see-your-motes/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 17:26:13 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[Running]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=613</guid>
		<description><![CDATA[Since I&#8217;ve upgraded to TinyOS 2.1, motelist always reports &#8220;no devices found&#8221; for my Iris motes when they are plugged in to the interface board.  A search of the TinyOS mailing list showed that the motelist script may not be including the correct Product ID when looking for motes.  I was able to get the [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;ve upgraded to TinyOS 2.1, motelist always reports &#8220;no devices found&#8221; for my Iris motes when they are plugged in to the interface board.  A search of the TinyOS mailing list showed that the motelist script <a href="http://www.mail-archive.com/tinyos-help@millennium.berkeley.edu/msg10359.html">may not be including the correct Product ID</a> when looking for motes.  I was able to get the script to recognize the interface board by altering /usr/bin/motelist to include the product id &#8220;6010&#8243; instead of the default &#8220;6001&#8243;:<br />
<code><br />
grep { ($_->{UsbVendor}||"") eq "0403" &#038;&#038; ($_->{UsbProduct}||"") eq "6010" }<br />
</code><br />
The manufacturer, product ID and other information about USB devices can be found in /sys/bus/usb/devices and running dmesg can tell you the path of the stuff you just plugged in.  For now, the script only prints out the path of the interface board but not the attached Iris mote.  The path of the interface board is needed for installing TinyOS programs, but the path of the mote is needed to listen for data packets from the mote.  So far, I haven&#8217;t found a way to get motelist to recognize the mote, but if I find it, I&#8217;ll post it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/02/28/when-motelist-doesnt-see-your-motes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enabling ACKs in TinyOS 2.x</title>
		<link>http://www.keally.org/2009/02/25/enabling-acks-in-tinyos-2x/</link>
		<comments>http://www.keally.org/2009/02/25/enabling-acks-in-tinyos-2x/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 20:26:10 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tests]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=608</guid>
		<description><![CDATA[I&#8217;ve seen a lot of questions about how to enable ACKs in TinyOS and not too many responses. Unlike a lot of TinyOS problems I&#8217;ve had, this one isn&#8217;t too bad. Some sample code for enabling ACKs is available in $TOSROOT/apps/tests/cc2420/TestAcks. In your configuration .nc file, just wire the PacketAcknowledgements interface: implementation { ... MainC.PacketAcknowledgements [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve seen a lot of questions about how to enable ACKs in TinyOS and not too many responses.  Unlike a lot of TinyOS problems I&#8217;ve had, this one isn&#8217;t too bad.  Some sample code for enabling ACKs is available in $TOSROOT/apps/tests/cc2420/TestAcks.  In your configuration .nc file, just wire the PacketAcknowledgements interface:<br />
<code><br />
implementation {<br />
...<br />
MainC.PacketAcknowledgements -&gt; ActiveMessageC;<br />
}<br />
</code><br />
Then, in your implementation file:<br />
<code><br />
module TestAcksP {<br />
uses {<br />
interface PacketAcknowledgements;<br />
...<br />
</code><br />
Then, just before you call AMSend.send() for a message_t testMsg:<br />
<code><br />
call PacketAcknowledgements.requestAck(&amp;testMsg);<br />
</code><br />
When a packet arrives with an ACK request, the ACK will be sent automatically.  In the sender&#8217;s AMSend.sendDone(), you will want to make sure the packet was ACKed to determine if a retransmission is required:<br />
<code><br />
if(!call PacketAcknowledgements.wasAcked(&amp;testMsg))<br />
retransmit();<br />
</code><br />
And that&#8217;s pretty much it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/02/25/enabling-acks-in-tinyos-2x/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Upgrading to TinyOS 2.1</title>
		<link>http://www.keally.org/2009/02/25/upgrading-to-tinyos-21/</link>
		<comments>http://www.keally.org/2009/02/25/upgrading-to-tinyos-21/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 18:00:35 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tests]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=606</guid>
		<description><![CDATA[I recently upgraded my TinyOS version from 2.0.2 to 2.1 and discovered that it makes use of Java 6.  I was testing my installation and kept getting the following when compling TestSerial: java.lang.UnsupportedClassVersionError: Bad version number in .class file Changing my java complier and runtime to Java 6 fixed this problem.]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded my TinyOS version from 2.0.2 to 2.1 and discovered that it <a href="http://docs.tinyos.net/index.php/Installing_TinyOS_2.1#Step_1:_Install_Java_1.6_JDK">makes use of Java 6</a>.  I was testing my installation and kept getting the following when compling TestSerial:<br />
<code><br />
java.lang.UnsupportedClassVersionError: Bad version number in .class file<br />
</code><br />
<a href="http://www.keally.org/2009/01/10/more-ubuntu-tinyos-2x-and-java/">Changing my java complier and runtime</a> to Java 6 fixed this problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/02/25/upgrading-to-tinyos-21/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TinyOS and NesC syntax highlighting</title>
		<link>http://www.keally.org/2009/02/20/tinyos-and-nesc-syntax-highlighting/</link>
		<comments>http://www.keally.org/2009/02/20/tinyos-and-nesc-syntax-highlighting/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 22:26:06 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[school]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=599</guid>
		<description><![CDATA[Since I&#8217;ve been doing some more work with TinyOS, here is a gedit .lang file that provides nesC syntax highlighting.  I got the file from the author of this post on the TinyOS mailing list and it&#8217;s been pretty useful.  To install it in Ubuntu, place the file in /usr/share/gtksourceview-2.0/language-specs/.  Unfortunately, you&#8217;ve got to be [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;ve been doing some more work with TinyOS, here is a <a href="http://www.cs.wm.edu/~makeal/lens/ncc.lang">gedit .lang file</a> that provides nesC syntax highlighting.  I got the file from the author of <a href="http://www.mail-archive.com/tinyos-help@millennium.berkeley.edu/msg17168.html">this post</a> on the TinyOS mailing list and it&#8217;s been pretty useful.  To install it in Ubuntu, place the file in /usr/share/gtksourceview-2.0/language-specs/.  Unfortunately, you&#8217;ve got to be root to do this and I don&#8217;t know of another way to add .lang files if you aren&#8217;t.  This is a problem for the departmental machines where I don&#8217;t have root access, so I can&#8217;t use custom gedit syntax highlighting.</p>
<p>There is a more heavyweight solution, if you like Eclipse.  Since I&#8217;ve been using Subclipse with Eclipse on several machines to keep all my code in sync, I&#8217;ve found Eclipse to be pretty useful.  A TinyOS 2.x Eclipse plugin is available on <a href="http://tos-ide.ethz.ch/wiki/index.php">this site</a> that provides syntax highlighting and it appears as though it will compile and install source code as well (though I haven&#8217;t tried that part).</p>
<p>2/21/2009: Since I&#8217;m on the topic of Eclipse, I&#8217;ve noticed that the Ubuntu repository Eclipse version is 3.2, but 3.4 is available from the Eclipse website.  Following <a href="http://atentia.wordpress.com/2008/08/01/upgrading-eclipse-32-to-34/">this guide</a>, it seems that you can override the /usr/eclipse directory with the new version if you want to upgrade.  Plugins will have to be reinstalled, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/02/20/tinyos-and-nesc-syntax-highlighting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Size: It&#8217;s too big for my head</title>
		<link>http://www.keally.org/2009/02/09/code-size-its-too-big-for-my-head/</link>
		<comments>http://www.keally.org/2009/02/09/code-size-its-too-big-for-my-head/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 22:13:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[computing]]></category>
		<category><![CDATA[internship]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[opinions]]></category>
		<category><![CDATA[practice]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[school]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=594</guid>
		<description><![CDATA[In all my previous programming projects that I&#8217;ve done on my own, I&#8217;ve always remembered exactly how everything worked: what every function and variable did and how every data structure and class interacted with each other.  In a way, I was able to store and compile the entire source code in my mind and know [...]]]></description>
			<content:encoded><![CDATA[<p>In all my previous programming projects that I&#8217;ve done on my own, I&#8217;ve always remembered exactly how everything worked: what every function and variable did and how every data structure and class interacted with each other.  In a way, I was able to store and compile the entire source code in my mind and know exactly how it would work.  With my current project, I can no longer do that.  The code is just too big and I can only remember pieces of it.</p>
<p>I think I&#8217;ve got about 10,000 lines that I&#8217;ve written for this over the past few months, which easily surpasses anything I&#8217;ve worked on before.  Nearly every week I&#8217;ve made significant changes to existing code and added in a lot of new stuff.  Something of this size in a constant state of change is a new challenge to me.</p>
<p>Consequently, I&#8217;ve taken a lot of steps to keep everything organized since I can&#8217;t do it in my head.  Since the code is mostly in Java, I&#8217;ve done my best to take advantage of its object oriented nature.  I try to keep things as loosely coupled as possible so that when I&#8217;ve got to make some modifications, it doesn&#8217;t screw everything.  I&#8217;ve made use of Java packages to group stuff together that has similar functions.  On top of all that, I&#8217;ve put the project into a Subversion repository so I can always go back to old stuff and so that I can work on it from multiple machines without it being a huge headache.</p>
<p>Of course, this is standard procedure for any programmer, but until now it&#8217;s never been absolutely necessary for any projects I&#8217;ve worked on alone.  During my internships, I had worked on stuff that was in the tens of thousands of lines, but it had been contributed to by other people.  Good programming practices made sense since other people would be working with my code and vice versa.  With what I&#8217;m working on now, it&#8217;s almost as if some of the stuff was written by someone else.  I&#8217;ll come across a method that I wrote two months ago and not remember much of how it worked.  I feel like a one man programming team.  I recall an <a href="http://itmanagement.earthweb.com/features/article.php/12297_3789981_2">interview of Bjarne Stroustrup</a> that complained about grad students that would work on their own projects and write terrible code, not expecting that later on it would be needed for another project or possibly released to others.  I&#8217;d rather not fall into that trap since the stuff I&#8217;m working on now will likely see plenty of use in the future.</p>
<p>Increased comprehensiveness is one reason they say that Extreme Programming is so valuable &#8212; having someone else there with you really helps in making something that not only works, but is built in such a way that everyone can understand it.  Some people, including myself, can often write something that is almost completely unintelligible to others.  Knowing this is one reason I like to avoid cramming several actions into one line, for which I&#8217;ve gotten grief from others about being &#8220;verbose&#8221;.  I&#8217;d rather be verbose, but understandable than concise ambiguous.  I&#8217;ve never understood why people brag about writing a program in as few lines as possible, usually in some loosely-typed scripting language.  For part of this project, I had to use someone else&#8217;s MATLAB script to convert some trace data.  Of course, they crammed the conversion code into about fifteen lines that took me forever to figure out what it did (partly because I&#8217;ve never used MATLAB).  Not wanting to revisit that, I translated the code into Java in a more drawn out format so it would integrate well with the rest of my project.</p>
<p>I&#8217;m sure there are plenty of things I could do to make my code more better than it is now, but it&#8217;s hard to improve when there isn&#8217;t someone to give you feedback.  I can learn from my successes and mistakes from previous projects when working on my current project, however.  It seems as if most good programming practices don&#8217;t matter so much when the code size is small, but when a threshold is crossed, they seem to go from irrelevant to absolutely necessary.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/02/09/code-size-its-too-big-for-my-head/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Upgrade Headaches&#8230;</title>
		<link>http://www.keally.org/2009/01/29/upgrade-headaches/</link>
		<comments>http://www.keally.org/2009/01/29/upgrade-headaches/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 17:31:07 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[general]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[computers]]></category>
		<category><![CDATA[displays]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[gaming]]></category>
		<category><![CDATA[isp]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[usb]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[xbox]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=585</guid>
		<description><![CDATA[Yesterday I installed Intrepid Ibex 8.10 on my aging (now ex-gaming) desktop machine in an attempt to breathe new life into it.  I wound up biting the bullet and ordering a new monitor and Xbox 360 for games, so now I&#8217;ve got two monitors.  Neither the Lenovo nor the Mac laptop I&#8217;ve got support two [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I installed Intrepid Ibex 8.10 on my aging (now ex-gaming) desktop machine in an attempt to breathe new life into it.  I wound up biting the bullet and ordering a <a href="http://h10010.www1.hp.com/wwpc/us/en/sm/WF05a/382087-382087-64283-72270-444767-3648442.html">new monitor</a> and Xbox 360 for games, so now I&#8217;ve got two monitors.  Neither the Lenovo nor the Mac laptop I&#8217;ve got support two external monitors, so I thought I would give the desktop a try.  Though the installation went fairly well, two really annoying things weren&#8217;t working correctly, and a third I&#8217;m still dealing with.</p>
<p>First, the mouse.  I have a Razer Copperhead USB mouse that&#8217;s been great for years and when I first booted after the installation, it didn&#8217;t work.  The lights came on, but I couldn&#8217;t move it.  If I unplugged it and plugged it back in, it worked fine.  This would happen every time I rebooted the machine: no movement, unplug, plug back in.  After some digging around, I found the problem was that the mouse firmware had to be upgraded.  Of course, Razer only has the update software for Windows, so after some screwing around with that, I rebooted with the Linux machine and it worked fine without having to unplug the mouse.</p>
<p>Second, the dual head support for my ATI video card was lacking after the initial install, just mirroring my primary monitor onto the other.  I was able to fix this by installing the proprietary ATI drivers and using the ATI Catalyst Control Center to &#8220;merge&#8221; both screens into one.  Of course, this didn&#8217;t entirely fix the problem since every time I rebooted, the mirroring came back.  I finally found out that after I set the displays correctly in the ATI Control Center that I had to open up the Ubuntu Display Settings panel and hit &#8220;Apply&#8221;.</p>
<p>Both of these problems were really annoying, kept me searching and frustrated for hours, and have rather quirky solutions.  While I really like Linux, stuff like this doesn&#8217;t seem to happen as much with Mac or Windows.  However, community support is pretty good so after some extensive research I was finally able to find others with my problems that had found solutions.</p>
<p>Now everything seems to be working well, except that the stand for my monitor arrived bent.  It&#8217;s only a couple millimeters out of shape and the box it came in seemed undamaged, so I&#8217;m not sure what happened.  It&#8217;s bad enough that when I type sometimes the monitor wobbles.  It&#8217;s something I could probably live with, but the wobbling is annoying and I paid for a new product (not refurbished) so I don&#8217;t feel like letting it go.  So, I spent two hours with phone tree hell HP tech support about returning it and then filed an RMA request from the online vendor.  It would be best if I could just replace the stand since the monitor is fine &#8212; there&#8217;s only one stuck pixel.  Shipping the whole thing back is going to be expensive if the RMA is approved.  I guess the question is if the bent stand is worth another $30.</p>
<p>I still haven&#8217;t gotten to the Xbox yet because of all this (and some other annoying legwork type stuff for a research proposal that is due this week).  It also turns out that I got the wrong RCA to mini-stereo adapter and will have to try to exchange that so I can plug in the Xbox sound to the line in on my PC.  The whole thing is kind of funny because part of the reason I went with an Xbox was to avoid dealing with putting together a new system and troubleshooting the whole thing when a bunch of stuff doesn&#8217;t work.  Instead, I got more than I bargained for.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/01/29/upgrade-headaches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Ubuntu, TinyOS-2.x, and Java</title>
		<link>http://www.keally.org/2009/01/10/more-ubuntu-tinyos-2x-and-java/</link>
		<comments>http://www.keally.org/2009/01/10/more-ubuntu-tinyos-2x-and-java/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 19:44:00 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Running]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=576</guid>
		<description><![CDATA[Last time I checked, the TinyOS 2.1 tools want Java 5 and in the instructions I posted here I wrote about removing other Java versions that were giving me trouble with the install. I figured at the time that removing Java 6 might come back to bite me and it did today, when another app [...]]]></description>
			<content:encoded><![CDATA[<p>Last time I checked, the TinyOS 2.1 tools want Java 5 and in the instructions I <a href="http://www.keally.org/2008/11/11/installing-tinyos-2x-on-ubuntu-with-iris-support/">posted here</a> I wrote about removing other Java versions that were giving me trouble with the install.  I figured at the time that removing Java 6 might come back to bite me and it did today, when another app I tried to install blew up on me.  It needed Java 6.  I found a way to switch between Java runtime versions using <a href="http://kulitkulit.wordpress.com/2008/09/15/set-default-java-in-ubuntu/">this post</a> and <a href="http://www.local-guru.net/blog/2009/01/23/switching-java-versions-in-ubuntu">this post</a>, by running:<br />
<code><br />
$sudo update-alternatives --config java<br />
</code><br />
To change the java complier (javac), run:<br />
<code><br />
$sudo update-alternatives --config javac<br />
</code><br />
Now I can have multiple Java versions coexisting on the same machine (I hope).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/01/10/more-ubuntu-tinyos-2x-and-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->