[Tinyos-help] Problem reading the temperature byte in TinyOS
packet
Michael Schippling
schip at santafe.edu
Sat Jun 2 09:39:30 PDT 2007
I think what you probably want is a Bitwise (not Logical) AND:
packet[18] & 0xFF
What you may be seeing is Java's attempt to help you by promoting
a byte that we wish was unsigned to a signed int.
MS
Shuvo Debnath wrote:
> Hello,
>
> I am using a mica2 mote and MTS310CA sensor running XServe, and am trying to read in the temperature byte. I have read all the documentation, and using Java, my function that converts a raw byte -> temperature works 100%, I tested this thouroughly. However I am having trouble actually getting the correct raw byte. When I read in the documented byte (18th in packet) I should be getting a value between 110-130 to correspond to room temperature (19-23 degrees C).
>
> However, instead I get very small numbers: Such as 2 or -13 depending on which sensor I read (I have multiple MTS310). I tried running the sensors against MoteView and the results are all accurate, so it is not a hardware issue.
>
> I suspect this is a Java issue but I am not sure. Does anyone have any suggestions? I need to get problem solved fairly quickly due to a very imminent deadline!
>
> If it helps, I am reading the packet by simply doing a:
>
> byte[] packet= reader.readPacket();
> if(packet.length==32)
> System.out.println("For Node:" + packet[7] + "RawTemperatureReading=" + packet[18]);
>
> A logical AND between the raw byte and 0xFF gives more extreme results (250+ on one sensor and < 10 on others).
>
> Thankyou in advance,
> Shuvo
>
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
More information about the Tinyos-help
mailing list