[Tinyos Core WG] Serial source address in Java

Philip Levis pal at cs.stanford.edu
Tue Feb 13 13:27:08 PST 2007


On Feb 13, 2007, at 12:57 PM, David Moss wrote:

> Hi David,
>
> We need a way for Java to set the source address of a packet before  
> it is transmitted to the serial port, and a way of accessing the  
> source address from the message header when a message is received  
> in Java.  Right now, the source address of serial packets received  
> on the mote is left undefined.  Setting it on the way out in Java  
> will prevent any serial stack from having to do it manually on the  
> embedded end.  There should probably be some kind of address that  
> represents the serial port, like 0xFFFE (didn't 1.x do this?).   
> This would allow application logic to evaluate that source address  
> of any inbound packet and know whether it needs to reply to the  
> serial or the radio.

The issue with specifying a serial address is that active messages  
don't use it for dispatch. That is, if you call AMSend.send(0xFFFE),  
the packet does not go to the serial stack. Now, you could (as you  
suggest) layer a level of dispatch on top of the two possible link  
layers, but this is a more general problem than that; if you had two  
radios, for example, you need to know which radio to send the packet  
over.

In short, this is an issue that sits above the given AM stacks and so  
hardcoding a solution into the stacks seems problematic.  I agree  
that you need to be able to access these fields on the Java side so  
that you can set this up. But I think that decision of what address  
to use should be in your application.


>
> We should also update the messageReceived(..) interface to allow  
> the user in Java to access any field in the message header they  
> need, instead of only the destination address. To do this, we would  
> need to give the user access to both the SerialPacket and the Message:
>
> public interface MessageListener {
>   public void messageReceived(SerialPacket originalPacket, Message m);
> }
>
> Then in the user's software it's still possible to access that  
> destination address along with all the other header information  
> available:
> originalPacket.get_header_dest()
> originalPacket.get_header_src()
> originalPacket.get_header_group()
> ...
>
> I think these changes are pretty minimal.  Users who already have  
> applications that implement messageReceived(int to, Message m) will  
> need to update their interface, but I was able to do that to my  
> slew of Java applications in no time.
>
> Thoughts?
> -David Moss


This seems pretty reasonable. My only tweak would be to make the  
interface signature this:

public interface MessageListener {
   pubic void messageReceived(SerialPacket packet, Message m payload);
}

Phil


More information about the Tinyos-2.0wg mailing list