Hi,everyone
  I  simulate  the surge application by tosism in tinyos-1.x ,but a exceptin is thrown .
The exception is as following :
 
Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: Message.checkBounds: bad offset (32) or length (16), for data_length 5
 at net.tinyos.message.Message.checkBounds(Message.java:282)
 at net.tinyos.message.Message.getUIntElement(Message.java:306)
 at net.tinyos.surge.SurgeMsg.get_parentaddr(SurgeMsg.java:268)
 at net.tinyos.surge.PacketAnalyzer.ObjectMaintainer.PacketReceived(ObjectMaintainer.java:124)
 at net.tinyos.surge.PacketAnalyzer.PacketAnalyzer.messageReceived(PacketAnalyzer.java:69)
 at net.tinyos.message.Receiver.packetReceived(Receiver.java:218)
 at net.tinyos.packet.PhoenixSource.dispatch(PhoenixSource.java:160)
 at net.tinyos.packet.PhoenixSource.packetDipatchLoop(PhoenixSource.java:152)
 at net.tinyos.packet.PhoenixSource.run(PhoenixSource.java:169)
 
I check the file Surge.java ,and find a problem .
 
 In the file ,
 
   package net.tinyos.surge;
 
   public class SurgeMsg extends net.tinyos.message.Message {
 
    /** The default size of this message type in bytes. */
    public static final int DEFAULT_MESSAGE_SIZE = 6;
...........................................
 
Why the DEFAULT_MESSAGE_SIZE is 6 ? Based the struct SurgeMsg defined in surge/surge.h ,
I think that DEFAULT_MESSAGE_SIZE  should be  5.
The SurgeMsg is as following :
 
typedef struct SurgeMsg {
  uint8_t type;  -----------1 byte
  uint16_t reading; --------2 byte
  uint16_t parentaddr;------2 byte
} __attribute__ ((packed)) SurgeMsg;
 
The command that generate the file  Surge.java is :
 
/opt/nesc/nesc-1.1.1/tools/mig  -target=pc -I/opt/tinyos-1.x/tos/platform/pc   -tosdir=/opt/tinyos-1.x/tos java -java-classname=net.tinyos.surge.SurgeMsg  /opt/tinyos-1.x/apps/Surge/Surge.h SurgeMsg -o SurgeMsg.java
 
My platform is cygwin ,and I use  both  tinyos-1.x and tinyos-2.x .
 
 
 
 

_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to