But only some additional fields (blue and/or red) are appended, no operation
is applied to them at all. Can this rule out the possibility of memory
access bug?

Another related question:
typedef struct {
uint8_t foo_a;
uint32_t foo_b;
} internal_t;
internal_t inter[4];

typedef nx_struct{
nx_uint8_t foo_a;
nx_uint32_t foo_b;
} external_t;
external_t exter[4];

Will this operation memcpy(exter, inter, sizeof(inter)) work? Or it has to
be copied manually via iteration of field assignment? Thanks.

On Fri, Aug 20, 2010 at 12:50 AM, Philip Levis <[email protected]> wrote:

>
> On Aug 19, 2010, at 8:57 PM, Xiaohui Liu wrote:
>
> > Hi,
> >
> > The following appears in my header file.
> > enum {
> >         SWS = 15,
> >         NUM_OF_QUANTILES = 4,
> >       LINK_MARKER_COUNTS = 11,
> > };
> > typedef struct neighbor_table_entry {
> >   am_addr_t ll_addr;
> >   uint8_t lastseq;
> >   uint8_t rcvcnt;
> >   uint8_t failcnt;
> >   uint8_t flags;
> >   uint8_t inage;
> >   uint8_t inquality;
> >   uint16_t eetx;
> >   uint8_t data_success;
> >   uint8_t data_total;
> > } neighbor_table_entry_t;
> >
> > Till now, everything works as expected. However, after the blue part is
> appended to the structure definition to the following, which is the only
> change to my program, it's not working anymore. Then I append the red part
> and it goes back to normal. Can anyone help me understand what is going on?
> I guess this may be related to alignment and order issue. I've encountered
> several problems so far and every time I have to randomly change the order
> of some fields or add some padding bytes till it's working. Is there a rule
> regarding how a structure must be defined in TinyOS? Thanks.
>
> There are no special rules. Chances are you have a memory access bug in
> your program somewhere; adding the padding leads the compiler to place the
> structure differently, such that you don't see the bug manifest.
>
> Phil




-- 
-Xiaohui Liu
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to