I just uploaded something that may be of interest to you to in
tinyos-2.x-contribs, created back in November 2006.  We can kind of emulate
dynamic memory allocation at compile time based on which components are
compiled in with your system.   It's proof-of-concept, but it works.

 

It can handle all of the data types you mention because it basically
allocates bytes to the end of a structure, and you access those bytes or
words through an interface which allows you to store() and load() your
variables that are located in your extendable array.  

 

The library for extendable structures is located in
tinyos-2.x-contribs/rincon/tos/lib/extended_storage.

The applications that demonstrate and test its capabilities are located in
tinyos-2.x-contribs/rincon/apps/tests/TestParameterStorage

Both of those directories have readme files in them.  And that's the only
documentation I have available.

 

As for storing your different types, you'd first make a structure (or
something) that's extendable.  Then, create a component that adds
bytes/words to it.  Your uint16_t and int16_t will take up the same number
of bytes - 2 - which is a word, so you'd create a new ExtendedWordC(..) to
reference either one.  A bool is really a byte, so you'd create a new
ExtendedByteC(..) to store/load a Boolean value.  And so on.  I never made
the modules to access a 32-bit number, but you can duplicate the
Extended***C/P code to add in that capability.

 

Maybe it's what you're looking for, maybe not - but it's a neat proof of
concept and it's there for you to use.

 

-David

 

 

 

 

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: Monday, May 21, 2007 11:32 AM
To: [email protected]
Subject: [Tinyos-help] Generic Data Structure in TinyOS

 

Hi guys,
I'm trying to implement a generic data structure in nesC... just like a
Vector in java. Now, since nesC doesn't support dynamic allocation of
memory, I'm thinking to fix the data structure size at compilation time.
But, actually there is another issue: how to implement a component able to
store uint16, int16, bool, and so on, without code replication? I read
something about generic component in the TinyOS 2.0 Programming guide... I
analized BitVectorC, in which is it used the 'typedef' keyword... but, you
know, implementing a generic data structure you of course need a kind of
"elementAt(index)" function... so, right now I don't know what return type I
have to use... Note that I want to give my component the skill to store
different element type, simply setting the type itself at compilation time;
in other words, I don't  need to store in the same component instance, i.e.,
some bool, some uint32 and finally some int16! 

So, anyone has so me suggestion to give me?! 
Thank you very much,
Antonio

----
Email.it, the professional e-mail, gratis per te: clicca qui
<http://www.email.it/cgi-bin/start?sid=3>  

Sponsor:
Vuoi ascoltare i tuoi MP3 in auto anche se la tua autoradio non lo permette?
Con HEMP3CAR puoi collegare il tuo IPOD o la tua Pen Drive direttamente alla
tua vecchia autoradio!
Clicca qui <http://adv.email.it/cgi-bin/foclick.cgi?mid=6591&d=20070521>  

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

Reply via email to