Hello everybody.

I've just start studying theTinyOS and I have some problems about parametrized intefaces. The code I wrote is below (this app is something that should simulate a traffic light, I know that I could did it in another way, but I did it so just as exercise)


=====================================================

configuration Semaforo {
}
implementation {
  components Main, SemaforoM, TimerC, LedsC;

  Main.StdControl -> TimerC.StdControl;
  Main.StdControl -> SemaforoM.StdControl;
  SemaforoM.Timer -> TimerC.Timer[unique("Timer")];
  SemaforoM.Leds -> LedsC;
}


=====================================================

module SemaforoM {
  provides {
    interface StdControl;
  }
  uses {
    interface Timer;
    interface Leds;
  }
}


implementation {

  command result_t StdControl.init() {
    call Leds.init();
    return SUCCESS;
  }

  command result_t StdControl.start() {
      return call Timer.start[1](TIMER_ONE_SHOT, 1000);
        }



  command result_t StdControl.stop() {
    return call Timer.stop[1]();

  }

event result_t Timer.fired[1]() {
    switch (call Leds.get()) {
      case 1:
        call Leds.redOff();
        call Leds.yellowOn();
        call Timer.start[1](TIMER_ONE_SHOT, 1000);
        break;
      case 4:
        call Leds.greenOn();
        call Timer.stop[1]();
        call Timer.start[2](TIMER_ONE_SHOT, 300);
        break;
      default :
        call Leds.redOn();
        call Timer.start[1](TIMER_ONE_SHOT, 1000);
        break;
    }
    return call Timer.start[1](TIMER_ONE_SHOT, 1000);
  }

event result_t Timer.fired[2]() {
      call Leds.greenOff();
      call Leds.yellowOff();
      call Leds.redOn();
      return call Timer.start[1](TIMER_ONE_SHOT, 1000);
  }
}
====================================

When I compile it I  obtain the following errors:

=========================================

[EMAIL PROTECTED] /opt/tinyos-1.x/apps/Semaforo
$ make mica2
mkdir -p build/mica2
    compiling Semaforo to a mica2 binary
ncc -o build/mica2/main.exe -Os -finline-limit=100000 -Wall -Wshadow - DDEF_TOS_A M_GROUP=0x7d -Wnesc-all -target=mica2 -fnesc-cfile=build/mica2/app.c - board=mica sb -DIDENT_PROGRAM_NAME="Semaforo" - DIDENT_PROGRAM_NAME_BYTES="83,101,109,97,102 ,111,114,111,0" -DIDENT_USER_ID="Administrator" - DIDENT_USER_ID_BYTES="65,100,10 9,105,110,105,115,116,114,97,116,111,114,0" - DIDENT_HOSTNAME="dewsoli2" -DIDENT_ HOSTNAME_BYTES="100,101,119,115,111,108,105,50,0" - DIDENT_USER_HASH=0x268063f6L
-DIDENT_UNIX_TIME=0x479f328eL Semaforo.nc -lm
SemaforoM.nc: In function `StdControl.start':
SemaforoM.nc:69: subscripted value is neither array nor pointer
SemaforoM.nc: In function `StdControl.stop':
SemaforoM.nc:80: subscripted value is neither array nor pointer
SemaforoM.nc: At top level:
SemaforoM.nc:90: syntax error before `{'
SemaforoM.nc: `Timer.fired' not implemented
make: *** [exe0] Error 1
==========================================

What's happening? Who illustrate me how modificate the code and tell me why?
And... if I wanna declare the wiring as

----->   SemaforoM.Timer -> TimerC.Timer[uint8_t id];

How should I modify the module SemaforoM.nc??
Thank You!!

Ubaldo Tiberi
--


--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f

Sponsor:
Stai cercando l'email marketing di successo ed economica? Prova con Email.it le 
tue campagne di Email Marketing a partire da 250 Euro!
* Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7149&d=29-1
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to