我发现很难在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。
我还有一个"main“组件:
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我哪里弄错了?如何正确连接组件?
发布于 2013-03-12 06:07:10
不确定这是否是原因,但在您的应用程序中尝试通过别名引用MyC,例如,而不是
MyC.MyInterface -> MS.MyInterface[unique("Hello")];试一试
App.MyInterface -> MS.MyInterface[unique("Hello")];更新
正如在this link中所解释的,由于您使用的是参数化接口,并且不能保证所有256个实例都将连接到需要在MyComponentM模块中提供默认实现的东西
default event MyInterface.actionDone[foo]() {
return;
}https://stackoverflow.com/questions/15349012
复制相似问题