Re: [Tinyos-help] Negative values from Counter

2009-11-13 Thread Robert Smith
Thats why Thanks a lot for your help=] Best, Rob %ld is for signed int, use %lu for unsigned long int. Cheers, Thomas On Fri, Nov 13, 2009 at 8:01 AM, Robert Smith wrote: > Thank you. > > I didn't cast the return value, so I'm geussing I misused prin

Re: [Tinyos-help] Negative values from Counter

2009-11-13 Thread Thomas Schmid
%ld is for signed int, use %lu for unsigned long int. Cheers, Thomas On Fri, Nov 13, 2009 at 8:01 AM, Robert Smith wrote: > Thank you. > > I didn't cast the return value, so I'm geussing I misused printf. > I did "printf("%ld", call Counter.get());".  I checked TestPrintfC.nc of > tutorial/Pri

Re: [Tinyos-help] Negative values from Counter

2009-11-13 Thread Robert Smith
Thank you. I didn't cast the return value, so I'm geussing I misused printf. I did "printf("%ld", call Counter.get());". I checked TestPrintfC.nc of tutorial/Printf, and it uses %ld for uint32_t, so I assumed %ld is for uin32_t format. Can anyone tell if I am using printf correctly? Best Rega

Re: [Tinyos-help] Negative values from Counter

2009-11-13 Thread Michael Schippling
Who says it's negative? When a signed integer's top bit gets set it "becomes" negative. Somewhere along the way your unsigned variable is being mis-interpreted. Often the default behavior is signed, so make sure you are using the right declarations and casts. Java doesn't know from unsigned, so t

Re: [Tinyos-help] Negative values from Counter

2009-11-13 Thread Thomas Schmid
Are you maybe converting the uint32_t into an int32_t? How do you know it is negative? Because a uint32_t is never negative, per definition, except if you cast it into a different signed type. Cheers, Thomas On Fri, Nov 13, 2009 at 7:25 AM, Robert Smith wrote: > Hi, > > I am currently using Tin

[Tinyos-help] Negative values from Counter

2009-11-13 Thread Robert Smith
Hi, I am currently using TinyOS2.x, and tyring to use microseconds in mica platform. I used CounterMicro32C to get microsec counter, and after awhile, the return value becomes negative value. CounterMicro32C provides interface Counter with uint32_t format, but why am I getting negative values fr