[Tinyos-help] Show data and Strings

2007-05-03 Thread [EMAIL PROTECTED]
HI, on one Tmote Sky i created an application(in Tinyos) that shows the raw 
data acquired from an other Tmote, trasmitted by radio. 
Now i show the data by the command "..Listen:" and i see a string like that:
"7e 00 0a 7d 1a 01 00 14 00 01 00 10 00"
where the last 2 bytes are the value of data. 
I want to know if it is possible to show a string like that:
"The value of SensorXXX is 10 00" 
or a string like that(where the value is converted in decimal)
"The value of SensorXXX is 4096".
Really, i want to know i can do it and i need of some examples to understand 
it. 
Thanks to all help me
PS. Very Thanks to Juan Antonio López Riquelme that help me a lot, can you help 
me again?
 
 
 



--
Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom
http://click.libero.it/infostrada



___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] Show data and Strings

2007-05-03 Thread Michael Schippling

You could use MIG to generate a Java class for your message type
and integrate it into the Listen program. Or here are my Q&D methods
for converting the byte array buffer elements into Java ints. You give
them the byte[] message buffer and the offset to the first byte of
the integer data that you want to "convert".

MS


// convert 2-byte buffer at byte 'start'
//  from a little-endian int into a signed Java int
// sign extend if necessary
protected static int tim( byte[] buf, int start )
{
int x = ((buf[start+1] << 8) & 0xff00) + (buf[start] & 0xff);
if( (x & 0x8000) != 0 )
{
// they were trying to tell us the value is negative...
// so extend the sign to 4 bytes
x = (x | 0x);
}
return x;
}

// convert 2-byte buffer at byte 'start'
//  from a little-endian int into an "unsigned" Java int
// do not sign extend...
protected static int ti( byte[] buf, int start )
{
int x = ((buf[start+1] << 8) & 0xff00) + (buf[start] & 0xff);
return x;
}

// convert from a Java int
//  into a little-endian int in the buffer at byte 'start'
protected static void fi( int data, byte[] buf, int start )
{
buf[start]   = (byte) (data & 0xff);
buf[start+1] = (byte) ((data >> 8) & 0xff);
}

[EMAIL PROTECTED] wrote:
HI, on one Tmote Sky i created an application(in Tinyos) that shows the raw data acquired from an other Tmote, trasmitted by radio. 
Now i show the data by the command "..Listen:" and i see a string like that:

"7e 00 0a 7d 1a 01 00 14 00 01 00 10 00"
where the last 2 bytes are the value of data. 
I want to know if it is possible to show a string like that:
"The value of SensorXXX is 10 00" 
or a string like that(where the value is converted in decimal)

"The value of SensorXXX is 4096".
Really, i want to know i can do it and i need of some examples to understand it. 
Thanks to all help me

PS. Very Thanks to Juan Antonio López Riquelme that help me a lot, can you help 
me again?
 
 
 




--
Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom
http://click.libero.it/infostrada



___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


[Tinyos-help] Show data and Strings,again

2007-05-04 Thread [EMAIL PROTECTED]
Thanks for answer, but i am confused i don't have understand how i can do what 
i want, have you an complete example(Main modules ...) to understand you to 
show message like i want. 
And aslo i want to write on video a string like: "The value of Temperature" it 
is possible? and i must use java or i can use only NesC?(i don't know well this 
programm language)?

Thanks to all, HELP ME!!!



 
-- Initial Header ---

>From  : "Michael Schippling" [EMAIL PROTECTED]
To  : "[EMAIL PROTECTED]" [EMAIL PROTECTED]
Cc  : "tinyos-help" tinyos-help@Millennium.Berkeley.EDU
Date  : Thu, 03 May 2007 12:33:07 -0600
Subject : Re: [Tinyos-help] Show data and Strings







> You could use MIG to generate a Java class for your message type
> and integrate it into the Listen program. Or here are my Q&D methods
> for converting the byte array buffer elements into Java ints. You give
> them the byte[] message buffer and the offset to the first byte of
> the integer data that you want to "convert".
> 
> MS
> 
> 
>   // convert 2-byte buffer at byte 'start'
>   //  from a little-endian int into a signed Java int
>   // sign extend if necessary
>   protected static int tim( byte[] buf, int start )
>   {
>   int x = ((buf[start+1] << 8) & 0xff00) + (buf[start] & 0xff);
>   if( (x & 0x8000) != 0 )
>   {
>   // they were trying to tell us the value is negative...
>   // so extend the sign to 4 bytes
>   x = (x | 0x);
>   }
>   return x;
>   }
> 
>   // convert 2-byte buffer at byte 'start'
>   //  from a little-endian int into an "unsigned" Java int
>   // do not sign extend...
>   protected static int ti( byte[] buf, int start )
>   {
>   int x = ((buf[start+1] << 8) & 0xff00) + (buf[start] & 0xff);
>   return x;
>   }
> 
>   // convert from a Java int
>   //  into a little-endian int in the buffer at byte 'start'
>   protected static void fi( int data, byte[] buf, int start )
>   {
>   buf[start]   = (byte) (data & 0xff);
>   buf[start+1] = (byte) ((data >> 8) & 0xff);
>   }
> 
> [EMAIL PROTECTED] wrote:
> > HI, on one Tmote Sky i created an application(in Tinyos) that shows the raw 
> > data acquired from an other Tmote, trasmitted by radio. 
> > Now i show the data by the command "..Listen:" and i see a string like that:
> > "7e 00 0a 7d 1a 01 00 14 00 01 00 10 00"
> > where the last 2 bytes are the value of data. 
> > I want to know if it is possible to show a string like that:
> > "The value of SensorXXX is 10 00" 
> > or a string like that(where the value is converted in decimal)
> > "The value of SensorXXX is 4096".
> > Really, i want to know i can do it and i need of some examples to 
> > understand it. 
> > Thanks to all help me
> > PS. Very Thanks to Juan Antonio López Riquelme that help me a lot, can you 
> > help me again?
> >  
> >  
> >  
> > 
> > 
> > 
> > --
> > Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom
> > http://click.libero.it/infostrada
> > 
> > 
> > 
> > ___
> > Tinyos-help mailing list
> > Tinyos-help@Millennium.Berkeley.EDU
> > https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
> 


--
Leggi GRATIS le tue mail con il telefonino i-mode™ di Wind
http://i-mode.wind.it/



___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


Re: [Tinyos-help] Show data and Strings,again

2007-05-04 Thread Urs Hunkeler
Hi Simone,

NesC is the programming language of the motes. Once the motes
communicate their information to a computer, you likely want to use a
different programming language. You're not required to use Java, but
usually it's easiest to just use Java on the PC side.

You can find more information about the mig tool in the tutorials:
http://www.tinyos.net/tinyos-2.x/doc/html/tutorial/lesson4.html

If you're using TinyOS-2, have a look at the Java code (not the NesC
code) in the apps/test/TestPrintf directory. In the main-method you see
how a connection to the mote is established using the MoteIF class. You
then have to create a class that implements the MessageListener
interface. This class will have a method called messageReceived. This
method will be called every time the mote sends a message to the PC. One
of the parameters of this method is the message itself. As it is nicely
wrapped in a Java object, it's really easy to extract the data. So
assume that you get mig to generate a message class called MyMsg and
your message contains an integer called data (the sensor readings). In
the messageReceived method you would then convert the more generic
Message to MyMsg and show the value with something like this:

public void messageReceived(int to, Message message) {
  MyMsg msg = (MyMsg)message;
  System.out.println("The data is: " + msg.get_data());
}

Cheers,
Urs


[EMAIL PROTECTED] schrieb:
> Thanks for answer, but i am confused i don't have understand how i can do 
> what i want, have you an complete example(Main modules ...) to understand you 
> to show message like i want. 
> And aslo i want to write on video a string like: "The value of Temperature" 
> it is possible? and i must use java or i can use only NesC?(i don't know well 
> this programm language)?
> 
> Thanks to all, HELP ME!!!
> 
> 
> 
>  
> -- Initial Header ---
> 
>> >From  : "Michael Schippling" [EMAIL PROTECTED]
> To  : "[EMAIL PROTECTED]" [EMAIL PROTECTED]
> Cc  : "tinyos-help" tinyos-help@Millennium.Berkeley.EDU
> Date  : Thu, 03 May 2007 12:33:07 -0600
> Subject : Re: [Tinyos-help] Show data and Strings
> 
> 
> 
>> You could use MIG to generate a Java class for your message type
>> and integrate it into the Listen program. Or here are my Q&D methods
>> for converting the byte array buffer elements into Java ints. You give
>> them the byte[] message buffer and the offset to the first byte of
>> the integer data that you want to "convert".
>>
>> MS
>>
>>
>>  // convert 2-byte buffer at byte 'start'
>>  //  from a little-endian int into a signed Java int
>>  // sign extend if necessary
>>  protected static int tim( byte[] buf, int start )
>>  {
>>  int x = ((buf[start+1] << 8) & 0xff00) + (buf[start] & 0xff);
>>  if( (x & 0x8000) != 0 )
>>  {
>>  // they were trying to tell us the value is negative...
>>  // so extend the sign to 4 bytes
>>  x = (x | 0x);
>>  }
>>  return x;
>>  }
>>
>>  // convert 2-byte buffer at byte 'start'
>>  //  from a little-endian int into an "unsigned" Java int
>>  // do not sign extend...
>>  protected static int ti( byte[] buf, int start )
>>  {
>>  int x = ((buf[start+1] << 8) & 0xff00) + (buf[start] & 0xff);
>>  return x;
>>  }
>>
>>  // convert from a Java int
>>  //  into a little-endian int in the buffer at byte 'start'
>>  protected static void fi( int data, byte[] buf, int start )
>>  {
>>  buf[start]   = (byte) (data & 0xff);
>>  buf[start+1] = (byte) ((data >> 8) & 0xff);
>>  }
>>
>> [EMAIL PROTECTED] wrote:
>>> HI, on one Tmote Sky i created an application(in Tinyos) that shows the raw 
>>> data acquired from an other Tmote, trasmitted by radio. 
>>> Now i show the data by the command "..Listen:" and i see a string like that:
>>> "7e 00 0a 7d 1a 01 00 14 00 01 00 10 00"
>>> where the last 2 bytes are the value of data. 
>>> I want to know if it is possible to show a string like that:
>>> "The value of SensorXXX is 10 00" 
>>> or a string like that(where the value is converted in decimal)
>>> "The value of SensorXXX is 4096".
>>> Really, i want to know i can do it and i need of some examples to 
>>> understand it. 
>>> Thanks to all help me
>>> PS. Very Thanks to Juan Antonio López Riquelme that help me a lot, can you 
>>> help me again?
___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help