TOSH_DATA_LENGTH is a define. So what you are trying to do doesn't work. packets (messages) in tinyos are fixed in size (data portion is TOSH_DATA_LENGTH). It was done to avoid the problems of dynamic allocation. Dynamic allocation requires dynamically changing pointers which can be very problematic. TinyOS trys to avoid dynamic pointers.
What exactly are you trying to do? On Tue, Oct 16, 2012 at 9:12 AM, ANDRIA Lama <[email protected]> wrote: > > Hi, > > Someone know how to change payload size dynamically? > My algorithm is like that, > > My payload size is 1, I send my data every 1s, and after 10s (counter = > 10), I want to update my packet size to 1 (TOSH_DATA_LENGTH + 1). > > I'm posting some of my code according to my logic I would do. > > 1) pld_send.h > > #ifndef TOSH_DATA_LENGTH > #define TOSH_DATA_LENGTH 1 > #endif > > enum { > TIMER_PERIOD_MILLI = 1000, > AM_PLD_SEND =3, > }; > > typedef nx_struct pld_send { > nx_uint16_t data; > nx_uint8_t fillBytes[TOSH_DATA_LENGTH]; > }pld_send_t > > 2) PldSendC.nc > > event void RadioControl.startDone(error_t radioBooted) { > > if ((counter & 0x0A) && TOSH_DATA_LENGTH !=26)) > TOSH_DATA_LENGTH = TOSH_DATA_LENGTH + 1; > > fillBytes[TOSH_DATA_LENGTH] = TOSH_DATA_LENGTH ; > > if ((call AMSend.send(AM_BROADCAST_ADDR, &VarStorePacket, > sizeofpld_send_t))) == SUCCESS) { > call Leds.led2Toggle(); > } > } > > Am I right? > Please help me. > > > _______________________________________________ > Tinyos-help mailing list > [email protected] > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > -- Eric B. Decker Senior (over 50 :-) Researcher
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
