2013-03-11 62 views
1

我發現很難在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 

哪裏我犯了一個錯誤?如何正確連接組件?

回答

1

不知道這是否是原因,但在你的應用程序嘗試通過別名指MYC,即代替

MyC.MyInterface -> MS.MyInterface[unique("Hello")]; 

嘗試

App.MyInterface -> MS.MyInterface[unique("Hello")]; 

[更新]

至於解釋在this link中,由於您使用的是參數化接口,並且不能保證所有256個實例都將連接到您需要在My中提供默認實現的東西ComponentM模塊

default event MyInterface.actionDone[foo]() { 
    return; 
} 
+0

這是我的錯誤,應該有(並在我的真實代碼中有!)App而不是MyC。但這不是原因... – Grzes 2013-03-11 22:22:17

+0

我想那麼它也應該是' - > MC.MyInterface ...' – IvanR 2013-03-11 22:34:47

+0

好吧,再一次,這是我的錯。它應該是MC而不是MS。在這裏重新輸入代碼時可能會遇到一些其他的小錯誤。但這不是錯誤'MyInterface.actionDone not connected'的原因。它不是解析錯誤或未定義的符號,而是更深層次的東西。問題出在接口和組件接線的某個地方,但我不知道在哪裏。 – Grzes 2013-03-11 22:43:44