Contiki UDP包传输持续时间与CC2538 [英] Contiki UDP packet transmission duration with CC2538

查看:266
本文介绍了Contiki UDP包传输持续时间与CC2538的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



以下是我的设备当前的消耗量,具体如何运行在CC2538芯片:





我使用 contiki / examples / ipv6 / simple-udp-rpl / broadcast-example.c 中的示例有人有个想法吗?



解决方案

我发现问题:传输数据包后,收音机没有正常关闭。



在文件 cpu / cc2538 / ...中的函数结尾处 transmit() dev / cc2538-rf.c 无线电仅在以前关闭时关闭。

  if(rf_flags& WAS_OFF){
rf_flags& =〜WAS_OFF;
off();
}

但实际上该程序永远不会在这种情况下,收音机没有关闭发送数据包之后立即发送。



出现问题是因为函数 channel_clear() transmit()函数)首先清除此标志。因此,函数 transmit()不知道收音机在执行之前已经关闭,因此收音机被保持。



为了解决这个问题,我把一个局部变量放在 channel_clear()中,关闭收音机,只有在功能开启的时候才清除标志本身。

  static int 
channel_clear(void)
{
int cca;
/ *修复:局部变量* /
uint8_t intern_onoff;

intern_onoff = 0;

PRINTF(RF:CCA\\\
);

/ *如果我们关闭,请先打开* /
if((REG(RFCORE_XREG_FSMSTAT0)& RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE)== 0){
rf_flags | = WAS_OFF;
on();
intern_onoff = 1;
}

/ *等待RSSI_VALID * /
while((REG(RFCORE_XREG_RSSISTAT)& RFCORE_XREG_RSSISTAT_RSSI_VALID)== 0);

if(REG(RFCORE_XREG_FSMSTAT1)& RFCORE_XREG_FSMSTAT1_CCA){
cca = CC2538_RF_CCA_CLEAR;
} else {
cca = CC2538_RF_CCA_BUSY;
}

/ *如果我们关闭,请关闭* /
if((rf_flags& WAS_OFF)== WAS_OFF&& intern_onoff){
rf_flags& =〜WAS_OFF;
off();
intern_onoff = 0;
}

return cca;
}

数据包传输期间的当前消耗量现在如下:





注意:频闪时间被有意减少到10ms:

  #define STROBE_TIME RTIMER_ARCH_SECOND / 100 

这解释了为什么只有三个频闪的频道广播消息。



选通的持续时间为3ms。这意味着数据速率是〜140kbps(?)。


Could someone explain me what is going on within the Contiki-OS when it transmits an UDP packet?

Here is the current consumption of my device in details running with the CC2538 chip:

My question is: why it takes so long to transmit an UDP broadcast packet (about 250ms) knowing that theoretically at 250kbps the packet of 408 bits length should be transmitted in approximately 2ms? I'd understand if the transmission last lets say ten milliseconds but here the difference is huge.

I use the example in contiki/examples/ipv6/simple-udp-rpl/broadcast-example.c

Does anyone have an idea?

解决方案

I found the problem : the radio is not turned off properly after the transmission of a packet.

At the end of the function transmit() in the file cpu/cc2538/dev/cc2538-rf.c the radio is turned off only if it was previously off.

if(rf_flags & WAS_OFF) {
    rf_flags &= ~WAS_OFF;
    off();
}

But actually the program never goes in this condition and the radio is not turned off immediately after the transmission of a packet.

The problem arises because the function channel_clear() (called at the beginning of the transmit() function) clears this flag first. Thus the function transmit() doesn't know anymore that the radio was off before its execution and therefore the radio is kept on.

To fix the problem I put a local variable inside the channel_clear() which turn off the radio and clear the flag only if it is turned on inside the function itself.

static int
channel_clear(void)
{
  int cca;
  /* Fix: local variable */
  uint8_t intern_onoff;

  intern_onoff = 0;

  PRINTF("RF: CCA\n");

  /* If we are off, turn on first */
  if((REG(RFCORE_XREG_FSMSTAT0) & RFCORE_XREG_FSMSTAT0_FSM_FFCTRL_STATE) == 0) {
    rf_flags |= WAS_OFF;
    on();
    intern_onoff = 1;
  }

  /* Wait on RSSI_VALID */
  while((REG(RFCORE_XREG_RSSISTAT) & RFCORE_XREG_RSSISTAT_RSSI_VALID) == 0);

  if(REG(RFCORE_XREG_FSMSTAT1) & RFCORE_XREG_FSMSTAT1_CCA) {
    cca = CC2538_RF_CCA_CLEAR;
  } else {
    cca = CC2538_RF_CCA_BUSY;
  }

  /* If we were off, turn back off */
  if((rf_flags & WAS_OFF) == WAS_OFF && intern_onoff) {
    rf_flags &= ~WAS_OFF;
    off();
    intern_onoff = 0;
  }

  return cca;
}

The current consumption during a packet transmission looks like now to:

Note: the strobe time was reduced intentionally to 10ms with:

#define STROBE_TIME                        RTIMER_ARCH_SECOND / 100

This explain why there is only three strobes of transmission for the broadcast message.

The duration of a strobe is 3ms. Which means that the data rate is ~140kbps (?).

这篇关于Contiki UDP包传输持续时间与CC2538的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆