<?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; tinyos</title>
	<atom:link href="http://www.keally.org/tag/tinyos/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>Sidewinder: A Predictive Data Forwarding Protocol for Mobile Wireless Sensor Networks</title>
		<link>http://www.keally.org/2009/05/13/sidewinder/</link>
		<comments>http://www.keally.org/2009/05/13/sidewinder/#comments</comments>
		<pubDate>Wed, 13 May 2009 17:25:01 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[williamandmary]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=674</guid>
		<description><![CDATA[Here is a link to the final version of my SECON 2009 paper: Sidewinder: A Predictive Data Forwarding Protocol for Mobile Wireless Sensor Networks Matthew Keally, Gang Zhou, Guoliang Xing IEEE SECON 2009 June 22-26, Rome, Italy, acceptance ratio: 81/431=18.8%]]></description>
			<content:encoded><![CDATA[<p>Here is a link to the final version of my <a title="IEEE SECON" href="http://www.ieee-secon.org">SECON</a> 2009 paper:</p>
<p><a title="Sidewinder_secon09.pdf" href="http://www.cs.wm.edu/~makeal/papers/sidewinder_secon09.pdf"><strong>Sidewinder: A Predictive Data Forwarding Protocol for Mobile Wireless Sensor Networks</strong></a><br />
Matthew Keally, Gang Zhou, Guoliang Xing<br />
IEEE SECON 2009<br />
June 22-26, Rome, Italy, acceptance ratio: 81/431=18.8%</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2009/05/13/sidewinder/feed/</wfw:commentRss>
		<slash:comments>1</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>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>
		<item>
		<title>Interface Arrays in TinyOS 2.x</title>
		<link>http://www.keally.org/2008/12/03/interface-arrays-in-tinyos-2x/</link>
		<comments>http://www.keally.org/2008/12/03/interface-arrays-in-tinyos-2x/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 18:55:01 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tinyos]]></category>
		<category><![CDATA[wirelesssensornetworks]]></category>

		<guid isPermaLink="false">http://www.keally.org/?p=533</guid>
		<description><![CDATA[I&#8217;ve noticed my other posts for TinyOS installation and development issues have received a few hits, so I&#8217;ve got another resolved problem to discuss. Another annoyance I&#8217;ve come across while programming TinyOS applications is the need for multiple interfaces of the same type.  For example, it would be great to have an array of timers [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve noticed my other posts for TinyOS installation and development issues have received a few hits, so I&#8217;ve got another resolved problem to discuss.</p>
<p>Another annoyance I&#8217;ve come across while programming TinyOS applications is the need for multiple interfaces of the same type.  For example, it would be great to have an array of timers with different firing intervals.  Like most things TinyOS, documentation on something like this is thin and not explained very well.  There are a few similar examples in the <a href="http://csl.stanford.edu/~pal/pubs/tinyos-programming.pdf ">TinyOS 2.x Programming Manual</a>, but I found it oriented towards someone who really knows what they&#8217;re doing.  Now that I&#8217;ve found a solution, I&#8217;ve decided to post it so that others can benefit.  Of course, if you&#8217;re reading this and have a better solution, let me know.</p>
<p>My main purpose in doing this is to sample data from different sensors on the MTS310 sensorboard at different intervals.  I would like to associate one periodic timer with one particular sensor.  Of course, this leads to my nasty initial solution such as this in the *AppC.nc file:<br />
<code><br />
implementation {<br />
...<br />
components new TimerMilliC() as Sensor1Timer;<br />
components new TimerMilliC() as Sensor2Timer;<br />
components new TimerMilliC() as Sensor3Timer;<br />
...<br />
App.Sensor1Timer -&gt; Sensor1Timer;<br />
App.Sensor2Timer -&gt; Sensor2Timer;<br />
App.Sensor3Timer -&gt; Sensor3Timer;<br />
...<br />
}<br />
</code><br />
This means that in the *C.nc file, I&#8217;ve got something like:<br />
<code><br />
module *C {<br />
uses{<br />
...<br />
interface Timer as Sensor1Timer;<br />
interface Timer as Sensor2Timer;<br />
interface Timer as Sensor3Timer;<br />
...<br />
}<br />
}</code><br />
Having three different timer interfaces means I&#8217;ve got to implement fired() three different times (Sensor1Timer.fired(), Sensor2Timer.fired(), and so on), despite the code being almost exactly the same for each fired() instance.  What if I have a custom sensorboard with ten sensors?  What a mess that would be.</p>
<p>I figured out how to simplify this using parameterized interfaces: essentially an array of timer interfaces.  This is obtusely described in the TinyOS Programming Manual in the Parameterized Wiring section.  While the programming manual suggests the use of unique(&#8220;<i>identifier</i>&#8220;) for each array element (timer instance), I wanted to be able to associate a specific timer with a specific sensor and know which timer it was that fired so I can sample data from the appropriate sensor.  unique() abstracts away the index for each parameterized element so when a timer fires, the index provided isn&#8217;t really associated with a particular sensor.  I defined an enum in an *.h file that describes indexes for each timer in the array:<br />
<code><br />
enum{<br />
SENSOR_ONE = 0, SENSOR_TWO = 1, SENSOR_THREE = 2,<br />
};<br />
</code><br />
Then, in the *AppC.nc file, I changed the wiring to reflect the new parameterized interfaces:<br />
<code><br />
App.SampleTimer[SENSOR_ONE] -> Sensor1Timer;<br />
App.SampleTimer[SENSOR_TWO] -> Sensor2Timer;<br />
App.SampleTimer[SENSOR_THREE] -> Sensor3Timer;<br />
</code><br />
This allowed me to alter the interfaces section of the *C.nc file, where all timers are identified by SampleTimer and an unsigned 8-bit id (the index provided in the enum):<br />
<code><br />
interface Timer<TMilli> as SampleTimer[uint8_t id];<br />
</code><br />
This way I can call SampleTimer.startPeriodic[SENSOR_ONE]() for the first timer, and use the other elements in the enum for the other timers in the array.  When a timer fires, there is only one fired() event in my *C.nc file:<br />
<code><br />
event void SampleTimer.fired[uint8_t id](){<br />
    // read data for this particular sensor and do something with it<br />
    if(id == SENSOR_ONE)<br />
      // read sensor one data here<br />
    else if(id == SENSOR_TWO)<br />
      // read sensor two data here<br />
...<br />
}<br />
</code><br />
I can use the id provided by the event to figure out which timer it was that fired and then read data from the appropriate sensor.  The code is greatly simplified this way and easily allows the addition or removal of timers and sensors.  Furthermore, this parameterized wiring can be used with any interface, such as handling radio packets of different AM types.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keally.org/2008/12/03/interface-arrays-in-tinyos-2x/feed/</wfw:commentRss>
		<slash:comments>0</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! -->