[Tinyos-help] Accessing TOS_Msg fields from Java

Michael Schippling schip at santafe.edu
Fri Jan 12 20:53:42 PST 2007


I believe that is correct. The payload size is always TOS_DATA_LENGTH,
no matter how many bytes are actually used...
MS


Heo Heo wrote:
>   Mike,
>  
>   I was thinking of a different approach. In the OscopeMsg structure, I 
> put some extra fields for the TOS_Msg header fields. On the mote running 
> TOSBase, I copied the TOS_Msg header fields to these Java-based 
> structures. That should work.
>  
>   The downside of this approach is there are soem unnecessary fields in 
> the original OscopeMsg structure. Besides, the TOSBase code is not 
> "transparent" anymore.
>  
>   I have a question: since TOS_DATA_LENGTH is a constant which defines 
> the size of the payload of the TOS message. Does it mean that the size 
> of the packet transmitted over the air is always fixed (i.e. equal 
> TOS_DATA_LENGTH + size of some header fields), regardless of how little 
> the real payload is.
>  
>   Thanks a lot
>   Heo
> 
> 
> */Michael Schippling <schip at santafe.edu>/* wrote:
> 
>     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.
>      >
>      >
>      >
>      >
>      >
>     ------------------------------------------------------------------------
>      >
>      > _______________________________________________
>      > Tinyos-help mailing list
>      > Tinyos-help at Millennium.Berkeley.EDU
>      >
>     https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
> 
> 
> ------------------------------------------------------------------------
> Never miss an email again!
> Yahoo! Toolbar 
> <http://us.rd.yahoo.com/evt=49938/*http://tools.search.yahoo.com/toolbar/features/mail/> 
> alerts you the instant new Mail arrives. Check it out. < 
> http://us.rd.yahoo.com/evt=49937/*http://tools.search.yahoo.com/toolbar/features/mail/> 
> 


More information about the Tinyos-help mailing list