In your startDone function, your line:

dbg("teste", "ENVIAR_PKT_DADOS: destino %hu nodeid %hu slot %hu [cont %hu]
no tempo=%lu.\n", syncwith, nodeid, slot, cont, call Clock.get());

As far as I can tell, you haven't actually declared or assigned a variable 
called 'nodeid'. Perhaps you meant to use TOS_NODE_ID instead?


________________________________
From: tinyos-help-boun...@millennium.berkeley.edu 
<tinyos-help-boun...@millennium.berkeley.edu> on behalf of arsaraiva 
<andresara...@id.uff.br>
Sent: 06 May 2017 14:24:16
To: tinyos-help@millennium.berkeley.edu
Subject: [Tinyos-help] Variable with static TOS_NODE_ID

Hello friends,

I need some help.
I need to store in a variable (nodeid) the source node of a package, so that
this variable does not receive new value with each hop.
In summary, if a tree of height 3, where node 0 is the root, node 2 child of
the root and parent of node 7, need that when a packet leaves node 7, nodeid
variable receives the value of 7, pass By its parent (node 2) without being
altered and reaches the root with the same value 7. My shipping code looks
like this:

event void AMControl.startDone(error_t err) {
    radio = TRUE;
    dbg("teste","SLOT_ATIVO: No %hu no slot [%hu] com tempo=%lu.\n",
TOS_NODE_ID, slot, call Clock.get());
    if (err == SUCCESS) {
        if ((call Clock.get() > (ultpkdados+5000)) && (TOS_NODE_ID != 0)){
             teste_msg_t* rcm = (teste_msg_t*)call Packet.getPayload(&pkt,
sizeof (teste_msg_t));
             rcm->tipo=1;
             rcm->nodeid = TOS_NODE_ID;
             rcm->slot = slot;
             rcm->proxsalto = syncwith;
             rcm->cont = cont;
             call PacketAcknowledgements.requestAck(&pkt);
             if (call AMSend.send(syncwith, &pkt, sizeof(teste_msg_t)) ==
SUCCESS) {
                 dbg("teste", "ENVIAR_PKT_DADOS: destino %hu nodeid %hu slot 
%hu [cont
%hu] no tempo=%lu.\n", syncwith, nodeid, slot, cont, call Clock.get());
                 cont++;
                 ultpkdados = call Clock.get();
                 locked = TRUE;
             }
        } else ......

My reception code looks like this:
 event message_t* Receive.receive(message_t* bufPtr, void* payload, uint8_t
len) {
    uint16_t transmissor;
    uint16_t destino;
    uint16_t seqnumin;
    if (len != sizeof(teste_msg_t)) {return bufPtr;}
    else {
       teste_msg_t* rcm = (teste_msg_t*)payload;
       if (rcm->tipo == 1) {
           if (TOS_NODE_ID == rcm->proxsalto){
               if (TOS_NODE_ID ==0){
                    transmissor = call AMPacket.source(bufPtr);
                    cont = rcm->cont;
                    nodeid= rcm->nodeid;
                    slotin = rcm->slot;
                    dbg("teste", "SORVEDOURO: [trans=%hu] [origem=%hu] [slot
%hu] [cont-%hu] [time=%lu].\n", transmissor, nodeid, slotin, cont, call
Clock.get());

                } else .....

However in the output of the debug nodeid always is = 0:
dbg("teste", "ENVIAR_PKT_DADOS: destino %hu nodeid %hu slot %hu [cont %hu]
no tempo=%lu.\n", syncwith, nodeid, slot, cont, call Clock.get());

and

dbg("teste", "SORVEDOURO: [trans=%hu] [origem=%hu] [slot %hu] [cont-%hu]
[time=%lu].\n", transmissor, nodeid, slotin, cont, call Clock.get());

But in the output of the debug, the [origin =% hu] is always equal value
[trans =% hu]

I do not know what I'm missing
Thanks in advance for any help.



--
View this message in context: 
http://tinyos-help.10906.n7.nabble.com/Variable-with-static-TOS-NODE-ID-tp25094.html
Sent from the TinyOS - Help mailing list archive at Nabble.com.
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to