I do see an error in at least one location on the read.  When you post a
task, the execution of that task is deferred for later when the task queue
comes around to executing it.  Your readInToFlash() function is passing back
a pointer to a buffer that contains data that was previously read from flash
- not the data you want to currently read from flash.  The function that
calls readInToFlash is therefore using old data.  After all that execution
is complete, FlashBridge is coming around and filling in the buffer with the
new data - the data you really want - from flash.

        Buffer* readInToFlash(uint32_t addr, uint32_t len){
                flashAddr=addr;
                flashLen=len;
                post readFlash();
                return flashBuffer;
        }

Put another way, you're dealing with a split-phase execution here because of
"post readFlash()" - the readFlash task is going to get executed after this
function has returned the *flashBuffer pointer.

So, instead of returning the pointer and using it, you'll probably want to
use some kind of state machine that lets you component know how to handle
the FlashBridge.readDone event.  Only after that event is signaled will you
be able to use the buffer with confidence.

-David




-----Original Message-----
From: Munaretto, Daniel [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 23, 2006 9:33 AM
To: David Moss
Cc: tinyos-help@Millennium.Berkeley.EDU
Subject: RE: [Tinyos-help] Help with Flash!


Hi David,
    now the code is going little better but i don't know why of this
behaviour:
 
i explain you in a simple way:
 
i have 2 nodes, every node creates a new packet every 10 seconds. When they
create or receive a packet, they inject them in a buffer with the same
generation (a parameter to distinguish). If the packet is new they create a
new buffer, otherwise they read from flash the correct buffer for injecting
the packet into.
 
Well, it seems easy, but for now all is working except the fact that: in my
flash the node are writing in the right places (for reading i'm not sure..),
so they recognize if the correspondent buffer exists. But they inject in
this way the packet:
 
in flash, the buffer with 
-generation=0 has:  the pck from node 0, generation 0 and the pck from node
1 generation 1(so the generation is wrong, may be it's wrong in the
reading?..)
-generation1 : from node 0 generation 1 and from node 1 generation2.
and so on
it means by node1 there is not matching (it differs by 1 generation)
 
i see all these things on node 0, that is the first which starts working.  
 
And also the data i read on mote 0 by your flashbridgeviewer application are
not correct. In the matrix field i can see that the real data aren't
matching with the displayed ones by some bytes (from 1 byte for generation 0
to 4 bytes to generation 3!). But the other fields are ok, so my functions
for injecting or other are working properly. 
I attached a simple version of my code, may be it would be easy to find an
error...i think however in the reading phase from flash...but i'm gonna
crazy on finding it..
 
thanks for your availability
cheers
Daniele 
 
 
 
 
 

         



_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to