我发现很难在 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
我在哪里做错了?如何正确连接组件?