微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > 射频无线通信设计 > 如何在tinyos下以较高的频率输出数据呢?

如何在tinyos下以较高的频率输出数据呢?

时间:10-02 整理:3721RD 点击:


这个问题我在tinyos-help里面也问了一下,但是这个论坛很不活跃,所以来这里请教大家了。

Currently, I am intending to record the cca and sfd value using a timer.
Due to the high frequency sampling rate (5ms/ sample), the output of the printf would flush themselves like follows:

[26804][26820]cca:1, sfd:0.
[26823][26831]cca:1, sfd:0.
[26834]cca:1, sfd:0.
[26841]cca:1, [26847]cca:0, sfd:0.
[26853][26868]cca:0, sfd:1.
[26876][26895]cca:1, sfd:0.
[26898][26914]cca:1, sfd:0.
[26917]cca:1, sfd:0.
[26924]cca:1, [26928]cca:1, sfd:0.
[26934][26938]cca:1, sfd:0.
[26946][26965]cca:1, sfd:0.
[26968][26985]cca:1, sfd:0.
[26988][26994]cca:1, sfd:0.
[26998][27014]cca:1, sfd:0.
[27020]cca:1, sfd:0.
[27027]cca:1, [27036]cca:1, sfd:0.
[27040][27055]cca:1, sfd:0.
[27058][27074]cca:0, sfd:0.
[27077][27084]cca:0, sfd:0.
[27087]cca:0, sfd:0.
[27097]cca:1, [27100]cca:1, sfd:0.
[27107][27116]cca:1, sfd:0.
[27119][27135]cca:1, sfd:0.

However, the correct format of output data should be "[time]cca:x, sfd:x". like follows:

[269842]cca:0, sfd:0.
[269859]cca:1, sfd:0.
[269872]cca:1, sfd:0.
[269887]cca:0, sfd:1.
[269905]cca:0, sfd:0.
[269918]cca:0, sfd:0.
[269932]cca:1, sfd:0.
[269947]cca:0, sfd:0.
[269962]cca:0, sfd:0.
[269977]cca:0, sfd:0.
[269992]cca:1, sfd:0.
[270007]cca:0, sfd:0.
[270024]cca:0, sfd:0.
[270038]cca:1, sfd:0.
[270053]cca:0, sfd:0.
[270067]cca:0, sfd:0.
[270082]cca:1, sfd:0.

So how to achieve the high rate sampling and recording with intended data format? My code is based on the TestNetworkLplC.nc, and I just add the periodic sampling timer as follows.

  1. event void WhiteSpaceTimer.fired(){
  2. uint32_t cur = call Timer.getNow();
  3. printf("[%ld]cca:%d, sfd:%d.\n", cur, call CCA.get(), call SFD.get());
  4. }

复制代码


The WhiteSpaceTimer is set to 5ms. and the packet send interval and wakeup interval both are 60ms.

此外,我还尝试了下面的代码,就是先用数组缓存一下数组,存到一定长度之后,让控制输出的这个timer加长一段时间,(2
s),然后再输出,但是还是不行。

[8473[85222]cca:0, sfd:1.
[85227]cca:0, sfd:1.
[85232]cca:0, sfd:1.
[85237]cca:0, sfd:1.
[85242]cca:0, sfd:1.
[85247]cca:0, sfd:1.
[85252]cca:0, sfd:1.
[85257]cca:0, sfd:1.
[85262]cca:0, sfd:1.
[85267]cca:0, sfd:1.
[85272]cca:0, sfd:1.
[85277]cca:0, sfd:1.
[85282]cca:0, sfd:1.
[8528[85782]cca:0, sfd:1.
[85787]cca:0, sfd:1.
[85792]cca:0, sfd:1.
[85797]cca:0, sfd:1.
[85802]cca:0, sfd:1.
[85807]cca:0, sfd:1.
[85812]cca:0, sfd:1.
[20281]cca:0, sfd:1.
[85822]cca:0, sfd:1.
[85827]cca:0, sfd:1.
[85832]cca:0, sfd:1.
[85838]cca:0, sfd:1.
[85842]cca:0, sfd:1.
[8584[20806]cca:0, sfd:238.
[20811]cca:0, sfd:238.
[20816]cca:0, sfd:238.
[20821]cca:0, sfd:238.
[20826]cca:0, sfd:238.
[86368]cca:0, sfd:238.
[86373]cca:0, sfd:238.
[86377]cca:0, sfd:238.
[86382]cca:0, sfd:238.
[86387]cca:0, sfd:238.
[86392]cca:0, sfd:238.

以下是代码:

  1. uint16_t samplerate = 5;// xx ms/sample
  2. uint8_t whiteOneShot = 3000;
  3. uint8_t bufflen = 50;
  4. uint8_t ccabuff[50];
  5. uint8_t sfdbuff[50];
  6. uint8_t buffcur = 0;
  7. uint16_t timebuff[50];
  8. event void WhiteSpaceTimer.fired(){

    uint32_t cur = call Timer.getNow();

    //printf("[%ld]cca:%d, sfd:%d.\n", cur, call CCA.get(), call SFD.get());

    if(buffcur <= 0 )

    {

    call WhiteSpaceTimer.startPeriodic(samplerate);

    }

    if(buffcur <= bufflen)

    {

    timebuff[buffcur] = call Timer.getNow();

    ccabuff[buffcur] = call CCA.get();

    sfdbuff[buffcur++] = call SFD.get();


  9. }

    else

    {

    buffcur = 0;

    for(spacei=0 ;spacei< bufflen;spacei++)

    {

    printf("[%ld]cca:%d, sfd:%d.\n",timebuff[spacei], ccabuff[spacei], sfdbuff[spacei]);

    }

    call WhiteSpaceTimer.startOneShot(whiteOneShot);

    }

    }

复制代码



Is there any approach can achieve my purpose ? Thanks!

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top