Are you running this on a simulator or a real mote? I think there was an answer to part of your problem a day or two ago: you may need to use the "packed" attribute in your structure definition to prevent types from being padded to fit some processor's idea of their boundaries. I think, but am not sure right now, that our real micro-controllers do not use padding, but a PC may.
Also having a pointer in a message is, well, pointless. You need to have the actual data array in the struct itself because the sending code doesn't de-ref the pointer to get to your data. But to answer the question, I think pointers are 2 bytes on the controllers and 4 bytes on Win32. To your subsequent question about variable length messages: All TOS messages are variable length, only the number of bytes specified in the send call are sent from the user's packet pointer. Your problem is that you have a fixed field "nx_uint32_t mac;" _after_ the variable length data portion so you will always have to send the full data[nn] in order to get to it. If you can change the order of the fields you can then just specify a sub-length of data for each send. MS Omar Cheikhrouhou (yahoo) wrote: > In fact, i use the following structure to exchange message between node > on network. > > > > typedef struct riseg_msg{ > > nx_uint8_t type; /*the type of the riseg message*/ > > uint8_t *data; > > nx_uint32_t mac; /* the mac field, present in all riseg message */ > > } riseg_msg_t; > > > > > > /*Default size=19 bytes*/ > > typedef struct join_key_msg{ > > > > nx_uint16_t next; /* the address of the next hop in the ring */ > > nx_uint8_t gid; /* the group identity */ > > uint8_t key[KEY_SIZE]; /*the group key. Default size=16 bytes*/ > > > > } join_key_msg_t; > > > > riseg_msg_t *risegMsgSent; > > > > However, when I print the size of message I get 12 instead of 9 (1+4+4). > > ====output using printf========================= > > sizeof(riseg_msg_t):12, sizeof(join_key_msg_t):19 > > sizeof(riseg_msg_t->type):1, sizeof(riseg_msg_t->data):4, > sizeof(riseg_msg_t->mac):4 > > sizeof(risegMsgSent):4, sizeof(*risegMsgSent):12, > > > > I do not understand. > > > > Can anybody explain to me why 12? What is the size of pointer in TinyOS? > > > > Thanks in advance, > > > > *De :* Prabhakar Misra [mailto:misra.pra...@gmail.com] > *Envoyé :* jeudi 8 juillet 2010 21:22 > *À :* Omar Cheikhrouhou (yahoo) > *Objet :* Re: [Tinyos-help] problem sending message > > > > Hi, > Your problem is a bit vague, may be you could be a bit more exact. > Is the sending being done over a radio or something?? > > On Thu, Jul 8, 2010 at 1:31 PM, Omar Cheikhrouhou (yahoo) > <enis01a...@yahoo.fr <mailto:enis01a...@yahoo.fr>> wrote: > > When i send two succesive message in telosb mote I got that the second > packet has as value the first one when I print its value in senddone and > receive. > > Do you have any explication for this problem… > > > _______________________________________________ > Tinyos-help mailing list > Tinyos-help@millennium.berkeley.edu > <mailto:Tinyos-help@millennium.berkeley.edu> > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > > > > > -- > Regards, > Prabhakar Misra, > Senior Undergraduate, > Department of Computer Science and Enginnering. > Indian Institute of Technology Kanpur, > India. > > > ------------------------------------------------------------------------ > > _______________________________________________ > 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