I would generate 3 different data-structures.

1) "Overall packet" (contains CtpData and TestNetwork fields, or at
least a dummy buffer to accommodate such data)
2) CtpData
3) TestNetwork

When you receive an "Overall packet", take it (and, in Java), create
the new CtpData and TestNetwork message types from it.
You'll only need to deal with the offsets during the tear-down phase,
and the interface makes this easy to do during the constructor calls.
This seems about what I did and it worked well enough.

HTH,
Paul

On Wed, Jul 23, 2008 at 12:20 AM, Varun Jain <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am currently running the "TestNetwork" application with 4 nodes. Using the
> Listen tool, I am getting the following data:
>
>
>
> 00 FF FF F4 01 17 00 05 00 01 00 19 00 06 04 EE 00 06 00 04 01 F4 00 19 00
> 06 00 00 00 00 00
>
>
>
> 00 FF FF F4 01 17 00 05 – Serial Header
>
> 00 01 00 19 00 06 04 EE – CtpDataMsg (1st part of payload)
>
> 00 06 00 04 01 F4 00 19 00 06 00 00 00 00 00 – TestNetworkMsg (2nd part of
> payload)
>
>
>
> The data that I am getting is correct but I want to generate two java files
> using 'mig' such that I have a TestNetworkMsg and CtpDataMSg.java file so
> that I can use "MsgReader" tool.
>
>
>
> My Makefile looks as follows:
>
>
>
> --------------------------------Makefile-----------------------------------------------------
>
> TestNetwork.class: $(wildcard *.java) TestNetworkMsg.java CtpDataMsg.java
>
>                 javac *.java
>
>
>
> TestNetworkMsg.java:
>
>                 mig java -target=null -java-classname=TestNetworkMsg
> ../TestNetwork.h TestNetworkMsg -o $@
>
>
>
> CtpDataMsg.java:
>
>                 mig java -target=null -java-classname=CtpDataMsg
> -I$(TOSDIR)/lib/net/ctp/Ctp.h ctp_data_header_t -o $@
>
>
>
> I am getting error while generating CtpDataMsg but I am able to generate the
> TestNetworkMsg.java and .class file if I comment out the CtpDataMsg part.
> Though, TestNetworkMsg file also has problem. A part of the file looks like
> this:
>
>
>
> /////////////////////////////////////////////////////////
>
>     // Accessor methods for field: source
>
>     //   Field type: int, unsigned
>
>     //   Offset (bits): 0
>
>     //   Size (bits): 16
>
>     /////////////////////////////////////////////////////////
>
>
>
>     /**
>
>      * Return whether the field 'source' is signed (false).
>
>      */
>
>     public static boolean isSigned_source() {
>
>         return false;
>
>     }
>
>
>
>     /**
>
>      * Return whether the field 'source' is an array (false).
>
>      */
>
>     public static boolean isArray_source() {
>
>         return false;
>
>     }
>
>
>
>     /**
>
>      * Return the offset (in bytes) of the field 'source'
>
>      */
>
>     public static int offset_source() {
>
>         return (0 / 8);
>
>     }
>
>
>
>     /**
>
>      * Return the offset (in bits) of the field 'source'
>
>      */
>
>     public static int offsetBits_source() {
>
>         return 0;
>
>     }
>
>
>
>     /**
>
>      * Return the value (as a int) of the field 'source'
>
>      */
>
>     public int get_source() {
>
>         return (int)getUIntBEElement(offsetBits_source(), 16);
>
>     }
>
>
>
>     /**
>
>      * Set the value of the field 'source'
>
>      */
>
>     public void set_source(int value) {
>
>         setUIntBEElement(offsetBits_source(), 16, value);
>
>     }
>
>
>
>     /**
>
>      * Return the size, in bytes, of the field 'source'
>
>      */
>
>     public static int size_source() {
>
>         return (16 / 8);
>
>     }
>
>
>
>     /**
>
>      * Return the size, in bits, of the field 'source'
>
>      */
>
>     public static int sizeBits_source() {
>
>         return 16;
>
>     }
>
>
>
> The problem I think is that the received message's payload that is sent to
> the UART has two parts, Ctp_data_header and TestNetworkMsg, so when I try to
> read the TestNetworkMsg, it gives me the values of the ctp_data_header.
> After generating the TestNetworkMsg.java file, If I change the offset values
> manually from 0 to 64 for the source and correspondingly for other variables
> such as:
>
>
>
>     public static int offset_source() {
>
>         return (0 -> 64 / 8);    }
>
> then I get the correct data which is understandable because actually the
> TestNetworkMsg starts at bit-64 in the payload.
>
>
>
> My query is how can I generate the TestNetworkMsg USING MIG such that it
> starts from bit-64 (of the serial payload) and consequently generate a
> CtpDataMsg file to access the first 8 bytes of the serial's payload.
>
>
>
> Thanks,
>
>
>
> Varun Jain
>
>
>
>
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>

_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to