Hamidreza,
I'm glad to see you here too.
I've used this code in my projects alot.Please try this new one.
hope it works.
*
*
*event void message_t* Receive.receive(message_t* msg, void* payload,
unit8_t len) {*
* if (len == sizeof(BlinkToRadioMsg)) { // the AM message is
called BlinkToRadioMsg*
*
*
* BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload;*
* unit16_t y = btrpkt->X;*
* y = y +15;*
* *
* BlinkToRadioMsg *data = call
Packet.getPayload(&pkt,sizeof(BlinkToRadioMsg));*
* *
* data->X = y;*
*
*
* // now sending to the next node*
* *
* if call AMSend.send(3,&pkt,sizeof(BlinkToRadioMsg)) == SUCCESS)
{*
* }*
Cheers,
On Sun, Sep 12, 2010 at 3:36 PM, Hamidreza Ghafghazi <
[email protected]> wrote:
> Hi Mojtaba,
>
> Thank you for your quick response, I am so glad that an Iranian researcher
> answered my question.
>
> Unfortunately not, because when you want to send the packet again we should
> define a new packet and then send that new packet.
> In BlinktoRadio example when the mote wanted to send its packet it should
> call the payload and modify it but since it was its own packet it is OKAY to
> send that one. here we have different situation since I want to send a new
> packet. I cannot send the packet that just received. Even though it looks
> like relaying a packet but I have to define a new packet and assign all my
> values to it and then relay it to the nest mote.
>
> I am looking for your new suggestions, it seems so simple but I don`t know
> where is the problem.
>
> Best regards,
>
> Hamidreza
>
>
> On Sun, Sep 12, 2010 at 6:19 PM, mojtaba raznahan <
> [email protected]> wrote:
>
>> Hi dear hamidreza,
>>
>> I think you have to just remove this line :
>>
>> pkt = *msg;
>>
>> because when you define BlinkToRadioMsg* btrpkt =
>> (BlinkToRadioMsg*)payload; , it's a pointer so when you modify it,It will
>> affect the pointed source too.
>> It should be ok with that.
>>
>>
>> On Sun, Sep 12, 2010 at 2:30 PM, Hamidreza Ghafghazi <
>> [email protected]> wrote:
>>
>>> Dear all,
>>>
>>> I want to send, for example, a number from node 1 to node 2 and in node 2
>>> I need to modify that number and send the new number to node 3.
>>> I know how to access to that data, but I don`t know how to assign the new
>>> value to the packet that will be send.
>>>
>>> Is it right that I write sth like below:
>>>
>>> For example the data that has been received is X and in the receive event
>>> I have written :
>>>
>>> event void message_t* Receive.receive(message_t* msg, void* payload,
>>> unit8_t len) {
>>> if (len == sizeof(BlinkToRadioMsg)) { // the AM message is
>>> called BlinkToRadioMsg
>>> BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload;
>>> unit16_t y = btrpkt->X;
>>> y = y +15;
>>> pkt = *msg; // message_t pkt has been introduced
>>> btrpkt->X = y;
>>> // now sending to the next node
>>> if (call AMSend.send(3, &pkt, sizeof (BlinkToRadioMsg)) ==
>>> SUCCESS) {
>>> }
>>>
>>> ...
>>>
>>> Actually in the compiling there is no problem but when I downloaded it in
>>> the motes they don`t work as I expected. I think that I have not assigned
>>> the new value correctly or the ( pkt = *msg) is wrong.
>>> So I need help and I will appreciate any suggestion.
>>> thanks in advance
>>>
>>> best regards,
>>> hamidreza
>>>
>>>
>>> _______________________________________________
>>> Tinyos-help mailing list
>>> [email protected]
>>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>>
>>
>>
>>
>> --
>> Mojtaba Raznahan
>> BS of Computer engineering
>> TMU university
>> www.raznahan.com
>>
>
>
--
Mojtaba Raznahan
BS of Computer engineering
TMU university
www.raznahan.com
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help