I'll go out on a limb since I don't know T2 and guess that
getPayload(bufPtr) does NOT copy the payload buffer but just
returns a pointer to the right location in the given buf, and
additionally that one does NEED to have a copy.

Therefore I would do something like:

    message_t buffer;   // new message buffer -- note: "global" value

    some *mySome;       // utility pointer to new payload
    // copy whole message
    memcpy(&buffer, bufPtr, sizeof(message_t));
    // get pointer to your newly copied payload
    mySome = (some*)Packet.getPayload(&buffer);
    // muck with stuff in new payload
    mySome->data = 0xffff;
    // then post task to do AM.send() as shown


MS

Muhammad Azhar wrote:
Hi all,
  (I'm using TinyOS 2)
In Receive.receive(message_t* bufPtr, void* payload, uint8_t len), supposing the payload is of "some" struct (assume it contains nodeid, data, seqNo):
some* rcvd = (some*)payload;
Supposing I'd wanna change some value in this payload before forwarding it to node x, should I simply do:
(1)
rcvd->data = 0xffff;
memcpy(&buffer, bufPtr, sizeof(message_t));
//assume buffer is a message_t structure
//then call "AMSend.send(x, &buffer, sizeof(some));" in another task
OR
(2)
some* rcvd = (some*)call Packet.getPayload(&buffer);
rcvd->data = 0xffff;
//I'm a bit lost as to how to continue from here

  Thanks.

Regards,
Azhar


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

Reply via email to