[Tinyos-help] Bug In Arithmetic Ops
Philip Levis
pal at cs.stanford.edu
Wed Nov 28 11:41:08 PST 2007
On Nov 27, 2007, at 1:36 PM, Federico Fiorentin wrote:
> Bug In Arithmetic Ops
> I did more tests, and the problem still persists.
> It seems that the evaluation becames incorrect when the T1 operand
> is bigger then 2^24.
>
> Below the operands T1, T2.
> T1 is the LocalTime.get() value. AlwaysT1 >= T2.
>
> The subtraction T1-T2 evaluated by mote, T1-T2 by Calc OpenOffice,
> then (T1-T2 by mote)-(T1-T2 by Calc) and last one logT1 in base 2.
> The same data in the attachment.
>
> I'll send the code if you need, but I'm sure that there aren't
> errors in it.
> I hope to find a solution.
> thanks
>
> T1 T2 T1-T2 by mote T1-T2 by Calc
> Difference logT1/log2
>
> 16983908 16759804 224103 224104
> -1 24,02
>
I am unable to reproduce this case in a simple, controlled test. The
mote always returns 224104, for all combinations of uint32_t and
nx_uint32_t operations. So there is something weird going on with
your code. Try rewriting it to figure out what construction causes
the problem. For example, rewrite
PollResp_ptr->globalTime = PollResp_ptr->eta[1] - T2
To be
uint32_t gTime = PollRsp_ptr->eta[1];
gTime -= T2;
Or directly access arrivalTimestamp rather than going through your
structure. The generated assembly is very long (and inefficient), so
hard to work through. But it is not an arithmetic problem.
Phil
More information about the Tinyos-help
mailing list