Hello,
I am trying to obtain something similar to how the timers are
implemented, a number of generic modules and a central module that can
communicate with them with commands/events.
My central module should
be a generic module with a parameter, always instantiated using
uniqueCount, so that only one instance is actually created.
This module
should provide a parametrized interface to wire the many generic
modules to it.
My problem is that with my wiring, I can seem to call
commands, but when I try to signal events, the compiler claims that the
event is not connected (but with the same wiring calling the command
works).
I did a minimal application as a proof of concept, so I have
an interface that defines one command and one signal:
interface
TestInterface {
command uint8_t call_test(uint8_t p);
event
uint8_t event_test(uint8_t p);
}
Then i have one module that uses the
interface, which is meant to be instantiated many times:
generic module
UserC() {
uses interface TestInterface;
uses interface Boot;
uses interface Leds;
}
implementation {
uint8_t last;
event uint8_t TestInterface.event_test(uint8_t p) {
last = p;
return 0;
}
event void Boot.booted() {
uint8_t
r = call TestInterface.call_test(0);
if (r == last) {
call Leds.set(0);
}
}
}
And the
central module, provides the interface
generic module ProviderC(uint8_t
max) {
provides interface TestInterface as TestInterface[uint8_t
num];
uses interface Leds;
}
implementation {
command uint8_t
TestInterface.call_test[uint8_t num](uint8_t p) {
static
uint8_t l = 0;
call Leds.set(l++);
signal TestInterface.
event_test[num](l);
return l;
}
}
In the end I have some
wiring to make it stick together
configuration TestAppC {}
implementation {
components LedsC;
components MainC;
components new UserC() as U0;
components new UserC() as U1;
components new ProviderC(0) as P0;
P0.Leds -> LedsC;
P0.
TestInterface[0] <- U0.TestInterface;
P0.TestInterface[1] <- U1.
TestInterface;
U0.Boot -> MainC;
U0.Leds -> LedsC;
U1.Boot -> MainC;
U1.Leds -> LedsC;
}
Could someone tell me
what is wrong with my code?
Thanks
Invita i tuoi amici e Tiscali ti premia! Il consiglio di un amico vale più di
uno spot in TV. Per ogni nuovo abbonato 30 € di premio per te e per lui! Un
amico al mese e parli e navighi sempre gratis: http://freelosophy.tiscali.it/
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help