|
From: Bruno F. M. <bm...@es...> - 2010-10-11 11:10:30
|
Hi List,
Hi Joris
First of all, Joris thanks for your explanation.
Just some bits ...
If I want to use contikimac, using NETSTACK_RADIO_on()/off() will put radio on/off, wright ? I have simulated it and looks that way.
I have another question: If I want to put everything sleep (except timers since I need to use them to wakeup the node from time to time) what instructions must I use ?
Thanks again in advance
/bruno
On 2010/10/11, at 09:21, Borms, Joris wrote:
> Hello Bruno,
>
> There is some difference between "mac->on()", "mac->off()" and "radio on", "radio off". You see, contikimac is an RDC (radio duty cycling) layer which contains a power-saving algorithm to turn the radio off for most of the time, while still allowing nodes to communicate.
>
> When you turn on contikimac, you activate this algorithm, thus turning off the radio for most off the time. Vice versa, when you deactivate the algorithm, contikimac assumes you want to keep the radio on.
>
> To make it work your way, you probably don't need an RDC, so I would recommend using the nullrdc layer by changing the definition of NETSTACK_RDC this in Contiki-conf.h:
> #define NETSTACK_CONF_RDC nullrdc_driver // old config was contikimac_driver
>
> Then, you should be able to turn the radio on and off correctly by using NETSTACK_RADIO.on() or NETSTACK_RADIO.off().
>
> Regards,
> Joris
>
>
> -----Original Message-----
> From: Bruno Filipe Marques [mailto:bm...@es...]
> Sent: Saturday, October 09, 2010 3:18 PM
> To: Adam Dunkels
> Cc: Contiki developer mailing list
> Subject: Re: [Contiki-developers] How to Put TelosB sleeping/waking
>
> Hi Adam,
> Hi All,
>
> Can anyone explain me this application behavior? Is like this:
>
> I want that my TelosB mote runs an application with cycle of 10 seconds ( as defined on bottom code - #define APP_PERIOD_T 10 * CLOCK_SECOND). After booting it keeps radio on during 4 seconds (#define TWAKE_PERIOD_T 4 * CLOCK_SECOND), then it turns radio off for 6 seconds (#define TSLEEP_PERIOD_T APP_PERIOD_T - TWAKE_PERIOD_T).
>
> After simulating the application in cooja, I realize that instead of turn the radio on, it turns it off, and vice-versa.
> What is wrong with the code ? It runs exactly the opposite I expected to !
>
> Any explanation on this ? What Am I doing wrong ?
>
> Regards
> /bruno
>
> ----8<--------------8<--------------8<--------------8<--------------
> #include "contiki-conf.h"
> #include "contiki.h"
> #include "contiki-lib.h"
> #include "contiki-net.h"
> #include "net/mac/contikimac.h"
>
> #include <string.h>
> #include <stdio.h>
> #include <string.h>
>
> #include <io.h>
> #include <signal.h>
>
> #define APP_PERIOD_T 10 * CLOCK_SECOND
> #define TWAKE_PERIOD_T 4 * CLOCK_SECOND
> #define TSLEEP_PERIOD_T APP_PERIOD_T - TWAKE_PERIOD_T
>
> static void app_handler(void *ptr);
> static void app_twake_handler(void *ptr);
> static void app_tsleep_handler(void *ptr);
>
> PROCESS(my_sol_process, "My Solution process");
> AUTOSTART_PROCESSES(&my_sol_process);
>
> static const struct rdc_driver *mac = &contikimac_driver;
>
> static struct ctimer app_timer;
>
> static void app_twake_handler(void *ptr)
> {
> //NETSTACK_RDC.on();
> mac->on();
> printf("Radio ON!\n");
> ctimer_set(&app_timer, TWAKE_PERIOD_T, app_tsleep_handler, NULL);
> }
>
> static void app_tsleep_handler(void *ptr)
> {
> //NETSTACK_RDC.off(0);
> mac->off(0);
> printf("Radio OFF!\n");
> ctimer_set(&app_timer, TSLEEP_PERIOD_T, app_twake_handler, NULL);
> }
>
> static void app_handler(void *ptr)
> {
> ctimer_set(&app_timer, 1 * CLOCK_SECOND, app_twake_handler, NULL);
> }
>
> PROCESS_THREAD(my_sol_process, event, data)
> {
> PROCESS_BEGIN();
>
> printf("Booting Node ...\n");
> app_handler(NULL);
>
> PROCESS_END();
> }
>
> ------------------------------------------------------------
> Bruno Filipe Marques,
> MsC in Electrical and Computer Engineering
>
> FCT PhD Schollarship (SFRH/BD/36221/2007)
>
> PhD Student @ DEEC/FEUP
> WiN, Wireless Networks
> UTM, INESC Porto,
> http://win.inescporto.pt/
>
> Electrical Engineering Department
> School of Technology and Management
> Polytechnic Institute of Viseu,
> Portugal
>
> url: http://www.estv.ipv.pt/paginaspessoais/bmarq/
> e-mail: bm...@es...
>
> MSN: bm...@ip...
> Skype: bmarq2k5
> Facebook: http://www.facebook.com/bmarq
> Twitter: http://twitter.com/bmarq2k9
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Contiki-developers mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/contiki-developers
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Contiki-developers mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/contiki-developers
>
------------------------------------------------------------
Bruno Filipe Marques,
MsC in Electrical and Computer Engineering
FCT PhD Schollarship (SFRH/BD/36221/2007)
PhD Student @ DEEC/FEUP
WiN, Wireless Networks
UTM, INESC Porto,
http://win.inescporto.pt/
Electrical Engineering Department
School of Technology and Management
Polytechnic Institute of Viseu,
Portugal
url: http://www.estv.ipv.pt/paginaspessoais/bmarq/
e-mail: bm...@es...
MSN: bm...@ip...
Skype: bmarq2k5
Facebook: http://www.facebook.com/bmarq
Twitter: http://twitter.com/bmarq2k9
|