[Tinyos-help] Call external function of C in nesC

Philip Levis pal at cs.stanford.edu
Fri Sep 21 08:53:58 PDT 2007


On Sep 21, 2007, at 2:06 AM, Chan kenniel wrote:

> Dear all,
>
> We are about to make a nesc program testing application. The  
> application will insert some functions into the source code so that  
> the running environment can be recorded. Something like:
> source:
> While (i)
> {
> ...
> i++;
> }
> inserted:
> while(i)
> {
> record(i) //inserted code
> ...
> i++
> }
> The problem comes that current record() is written by c. And when I  
> try to compile the inserted code, and error of implicit declaration  
> occurred. I am wondering if there is any way I can make my function  
> recognized by the compiler, just like those familiar functions such  
> as memcpy or printf, which can be recognized by nesc compiler?
>

Just like in C, make an include file. The trickier part is linking  
the function in. Take a look at the TinyOS programming manual's  
section on attributes on how to write a C function in a component.  
TOSSIM has a couple examples of doing this (writing a C function in a  
component so it is in the global C namespace rather than the  
component local namespace).

Phil



More information about the Tinyos-help mailing list