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 | 0xffff0000);
}
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
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help