Setting aside, for the moment, why you want to include studio.h...

Decimal is a property of a display device such as printing to a screen.
All(most all) values are stored in computers in binary representation.
Since there is no way to "print" anything directly from a mote, we are
somewhat confused as to where you want to get a "decimal equivalent"?

If you have a PC-host program that is receiving data from a mote you
can use something like this

in Java:

     System.out.println( "my data = " + myIntValue );

or in C:

     printf( "my data = %d", myIntValue );

Both of which convert a binary value to a string of characters in decimal
format on your screen. The second example legally requires that you
   #include <studio.h>
to get the prototype for printf(), so maybe that is why you ask about that.
However neither of the above will do much good in a TOS program, aside
perhaps from a simulation, because there is no screen to print to.

Continuing on and reading into your posted code example...taking the
ones-compliment of something named Msg->strength leads me to believe that
you are trying to get an RSSI value in dbm. If that is the case then you
are partially implementing instructions for a well trodden path. Please
search this list, documentation, and manuals for RSSI and signal strength
to see the right way to do it.

MS


ram kishore wrote:
> Hi,
>       I tried #include <stdio.h>,but in vain.
> example code:
> Msg->strength(rssi) is uint16_t variable which is by default displayed 
> in hex like shown below:
> ReceivedMsg->data[0] = Msg->strength & 0xFF;(MSB)
> ReceivedMsg->data[1] = Msg->strength >>8; (LSB)
> 
> I have to get the 1's complement of Msg->strength.and then convert it 
> into decimal.I tried like this.
> 
> ReceivedMsg->data[0] = (Msg->strength & 0xFF) ^ 0xFF; 
> ReceivedMsg->data[1] = (Msg->strength >>8)  ^ 0xFF;
> 
> I get the 1's complement but i can't get its decimal 
> equivalent.Typecasting didnt work.
> 
> Many Thanks,
> kishore
> 
> 
> On Fri, May 23, 2008 at 6:32 PM, Urs Hunkeler <[EMAIL PROTECTED]> wrote:
> 
>     Hi,
> 
>     For the include statement, try:
> 
>     #include <stdio.h>
> 
>     The complement operator or the bit-wise XOR operator both should
>     work directly with integers. Can you provide us with a short example
>     of code that you would like to use?
> 
>     Cheers,
>     Urs
> 
>     ram kishore wrote:
> 
>         Hi,
> 
>              I added #include stdio.h as below to configuration file:
> 
>          #include stdio.h
>         configuration TOSBase {
>         }
>         implementation {
>          components Main, TOSBaseM, RadioCRCPacket as Comm, FramerM, UART,
>         LedsC;........
>         //some lines
>         }
>          I get the following error:
>              TOSBase.nc:38:10: #include expects "FILENAME" or <FILENAME>
>         <commandline>: failed to preprocess TOSBase.nc
> 
>         Somehow, I got the one's compliment using XOR operator (as said by
>         Hunkeler).But how can i convert into integer?
>         Is there any pre-defind C function? Or I have to write program
>         for that
>         conversion?
> 
>         Many regards,
>         Kishore
> 
>         On Thu, May 22, 2008 at 9:06 PM, Michael Schippling
>         <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
>         wrote:
> 
>             ones-compliment is negation, c.f.:
>               http://www.cis.cau.edu/~mititi/cis472/Binnum/tsld005.htm
>             
> <http://www.cis.cau.edu/%7Emititi/cis472/Binnum/tsld005.htm><http://www.cis.cau.edu/%7Emititi/cis472/Binnum/tsld005.htm>
> 
> 
>             I believe that you #include studio.h in exactly that way,
>             however you may be disappointed as to how many of the
>             functions are supported under TOS.
> 
>             MS
> 
>             ram kishore wrote:
> 
>                 Hi,
>                    I need to find 1's complement of the incoming hex
>                 message.How to add
>                 #include<stdio.h> to my application?
>                   Is there any alternative way of doing this?
> 
>                 Regards,
>                 Kishore
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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

Reply via email to