[Tinyos-help] Accessing TOS_Msg fields from Java

Michael Schippling schip at santafe.edu
Fri Jan 12 11:39:35 PST 2007


Warning: answer only relevant to TOS1.x...

I was going to say just look at the Message classes:
     net/tinyos/message/Message.java
     net/tinyos/oscope/OscopeMsg.java
and the doc for MIG (which generates OscopeMsg.java).

But when I did (because I just refused to use them from
the outset so I never did before) I found that there are
no builtin accessors for the message header. And what's
more the way to get to arbitrary fields is:

   protected long getUIntElement(int offset, int length)

So you can't use it from outside OscopeMsg. Somehow I have
come to expect this sort of thing but it still annoys me...


So your two options are A) extend OscopeMsg and add accessors
that call getUIntElement() using your own special knowledge of
the header structure gleaned from tos/types/AM.h; or, B) write
the whole thing yourself (assuming you are not just modifying
the oscope app...). For an example of the DIY option see my code:
     http://www.etantdonnes.com/Motes/robocode.tar.gz

MS

Heo Heo wrote:
>   I was wondering if there is a way to access the TOS_Msg fields (like 
> addr, type, group, strength, etc.) from Java.
>  
>   The context is that there is a mote running OscilloscopeRF. This mote 
> sends messages (class OscopeMsg) to the base station (connected to PC 
> with Serial forwarder). For each message received at the PC, our Java 
> program (running on the PC) needs to access some fields of the TOS_Msg 
> header.
>  
>   Thanks a lot for any help.
>  
>  
>  
> 
> Everyone is raving about the all-new Yahoo! Mail beta. 
> <http://us.rd.yahoo.com/evt=42297/*http://advision.webevents.yahoo.com/mailbeta> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


More information about the Tinyos-help mailing list