Michiel Konstapel wrote:
>> I'm wondering whether I can define global function.
>> The global function mean, I define a function in 
>> component A, and I can call this function in component
>> B without using interface, just call the function directly?
> 
> No, all interaction between components has to go through the commands and
> events they define in their interfaces. Well, you could probably hack your
> way there, but you're not really supposed to.

Actually, you can have components provide and use commands and events
that aren't tied to any interfaces; e.g.:

module SomeComponentP {
  provides command bool someCommand(uint8_t param);
}
implementation {
  command bool someCommand(uint8_t param) {
    ...
  }
}

This feature is used in a handful of places in TinyOS 2.0, like the
TOSSIM ActiveMessage layer.  See
tos/lib/tossim/ActiveMessageAddressC.nc and
tos/lib/tossim/TossimActiveMessageP.nc for an example.

Doing this is arguably bad style, but it's possible nonetheless.

Greg Hackmann
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to