posts - 8,  comments - 28,  trackbacks - 0

       看了一个下午,终于明白了Tinyos下的Message packet ——TOS_Msg其实就是用typede声明的一个结构体,完整的说明在头文件AM.h这个文件里面找到。以下是TOS_Msg的结构:
typedef struct TOS_Msg
{
  /* The following fields are transmitted/received on the radio. */
  uint16_t addr;
  uint8_t type;
  uint8_t group;
  uint8_t length;
  int8_t data[TOSH_DATA_LENGTH];    //TOSH_DATA_LENGTH=29
  uint16_t crc;
 
/* The following fields are not actually transmitted or received
   * on the radio! They are used for internal accounting only.
   * The reason they are in this structure is that the AM interface
   * requires them to be part of the TOS_Msg that is passed to
   * send/receive operations.
   */
  uint16_t strength;
  uint8_t ack;
  uint16_t time;
  uint8_t sendSecurityMode;
  uint8_t receiveSecurityMode; 
} TOS_Msg;
The addr field specifies the destination address (a moteID or the broadcast address). The group field specifies a channel for motes on a network. If a mote receives a packet with a different group ID, the packet is dropped. The type field specifies which handler to be called at the AM level when a packet is received. The length field specifies the length of the data portion of the TOS_Msg. Packets have a maximum payload of 29 bytes. The data portion consists of an array of 29 bytes (as specified by TOSH_DATA_LENGTH). The unsigned two byte field crc follows. When sending, the crc is incrementally calculated as each byte of the packet is transmitted.
      So, the maximum length of a transmitted TOS_Msg is 36 bytes (addr(2 bytes) + type(1 bytes) + group(1 bytes) + length(13 bytes) + data(29 bytes) + crc(2 bytes) = 36 bytes).
      虽然最大长度是36个字节,但是除去各种开销,有效字节只有29个
• sendingNode (2 bytes) – the node that has sent the packet.
• originNode (2 bytes) – the node that generated the packet.
• seqNo (2 bytes) – the sequence number of the packet.
• hopCount (2 bytes) – the number of hops the packet has travelled.
• data[21] (8 bytes) – the payload field of length 21 bytes.

posted on 2005-08-11 18:45 记忆中的深蓝 阅读(2088) 评论(6)  编辑 收藏 引用 所属分类: TinyOS

FeedBack:
# re: The structure of the TOS_Msg
2005-09-04 21:47 | tony
也是刚学吧,我可能比你早点,我感觉上手太慢了  回复  更多评论
  
# re: The structure of the TOS_Msg
2005-10-19 15:53 | yym
这到底是个什么系统啊。我要研究WSN了,还一无所知呢。  回复  更多评论
  
# re: The structure of the TOS_Msg
2005-10-19 15:55 | yym
可不可以交流一下啊。yiyanm@yahoo.com.cn  回复  更多评论
  
# 请教!!!
2006-04-19 21:40 | joanmm
tinyos文件夹下的java的子文件夹里net中的那些后缀为java的小程序的主要功能是什么??当然了里边有很多的小程序,我只要知道那些主要的就可以了,谢谢了,哪位高手知道的劳烦给指点指点。 那些应该是完成关于对节点传送的信息监控和控制等(比如说截取和显示等)功能的,但具体到每个的功能我实在看不来了。  回复  更多评论
  
# re: The structure of the TOS_Msg
2008-03-09 16:17 | hailin
哎 我竟然找不到AM.h 真是纳闷
感觉这nesC确实上手很慢   回复  更多评论
  
# re: The structure of the TOS_Msg
2009-04-25 17:55 | 悦读
在tinyos-1.x里面搜索到N多的AM.h文件,看过几个之后发现:只有一点不同:TOSH_DATA_LENGTH 这个常量的定义有两个值。一个28,一个29。
我现在在调试SimpleCmd。请问该使用哪个值?
以后又如何确定这两个不同的文件的使用情况。
QQ:59514073
MAIL:595140273@qq.com
谢谢啦  回复  更多评论
  
只有注册用户登录后才能发表评论。
<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(8)

随笔分类(7)

随笔档案(8)

相册

www.tinyos.net

最新随笔

搜索

  •  

积分与排名

  • 积分 - 14884
  • 排名 - 243

最新随笔

最新评论

阅读排行榜

评论排行榜