我发现很难在nesC中发出事件信号。有人可以帮忙吗? (编辑:我在下面的代码中省略了MainC组件)。
我定义了一个简单的界面:
interface MyInterface {
command uint8_t action();
event void actionDone();
}
它有一个动作和一个事件。
我还有一个提供MyInterface的组件:
configuration MyComponentC {
provides interface MyInterface[uint8_t id];
}
implementation {
components MyComponentM;
MyInterface = MyComponentM.MyInterface;
}
module MyComponentM {
provides interface MyInterface[uint8_t id];
}
implementation {
command uint8_t MyInterface.action[uint8_t id]() {...}
...
event void bar() {
signal MyInterface.actionDone[foo]();
}
}
事件栏来自完全不同的界面。在这种情况下,我想用id == foo发出事件actionDone的信号。
我还有“主要”组件:
configuration MyAppC {
}
implementation {
components MyC as App;
components MyComponentC as MC;
App.MyInterface -> MC.MyInterface[unique("Hello")];
}
module MyC {
uses interface MyInterface;
}
implementation {
event void MyInterface.actionDone() {...}
}
但在编译过程中我收到错误:
MyInterface.actionDone not connected
我在哪里弄错了?如何正确连接组件?
答案 0 :(得分:1)
不确定这是否是原因,但在您的App中尝试通过别名引用MyC,即代替
MyC.MyInterface -> MS.MyInterface[unique("Hello")];
试
App.MyInterface -> MS.MyInterface[unique("Hello")];
[UPDATE]
如this link中所述,由于您使用的是参数化接口,并且无法保证所有256个实例都连接到您需要在MyComponentM模块中提供默认实现的内容
default event MyInterface.actionDone[foo]() {
return;
}