[Tinyos-help] can I write to a file using nesC
Steve McKown
rsmckown at yahoo.com
Tue Mar 27 09:12:12 PDT 2007
On Monday 26 March 2007 01:17, vaibhav chakki wrote:
> Hi All,
>
> I was wondering if there was any API in nesC that allows me to read/write
> to file to capture some data. If possible could you list the API names plz?
For most target systems running nesC code, the concept of data storage is
limited to a RAM buffer or some kind of flash. TinyOS 2.x provides a couple
of different implementations of a set of data storage interfaces that are
defined in TEP103. A link to TEP103 is available on the front page of
www.tinyos.net. There are other data storage mechanisms, like Matchbox, but
I've not used any of them myself.
> Also, can I make "C" function calls from nesC code? I use the the
> "__attribute__ ((C,spontaneous));" along with the C function letting the
> nesC compiler to not worry when compiling, but the linker to take care of
> it. But I am not able to load the C object files during linking? I keep
> getting linker errors, can anyone suggest me on how should I load the C
> objects for the linker to find it?
Yes, you can make calls to C functions from nesC code. You don't need to use
the C,spontaneous attribute if you place your C code in a .c file and compile
with the appropriate gcc compiler. IMHO, it's easiest to then bundle the
object files into a library file (.a), and reference it from your nesC
Makefile via:
LDFLAGS += path/to/your/libfile.a
Your C library will require a header file to provide function prototypes and
other definitions for code using your library, so you'll also need to tell
your nesC build where to find that header:
CFLAGS += -Ipath/to/your/include/dir
Then, all you have to do in a nesC component which wishes to use functions
exported from your libfile.a is to #include the prototype header and call the
functions directly.
All the best,
Steve
More information about the Tinyos-help
mailing list