Hi Michael, Thanks for the response. Unfortunately it did not seem to fix the problem! I was doing a bitwise AND operation originally, but that was giving me very large results.
An example output of my listener using bitwise logical AND with 0xFF is: HexRawTemperature=d5 IntRawTemperature=213 (I printed both hex and int to make sure it was not a signing issue) adjTemp=852.0 (value after binary shifting packet[18] by 2 places to the left, as instructed in the documentation) Converted Temperature in Celsius = 62.624563 (Definitely not my room temperature!) Would you have any other suggestions? Does WindowsXP or Java do anything funny to packet streams? Thanks, Shuvo ----- Original Message ----- From: Michael Schippling <[EMAIL PROTECTED]> Date: Sunday, June 3, 2007 3:09 am Subject: Re: [Tinyos-help] Problem reading the temperature byte in TinyOS packet To: Shuvo Debnath <[EMAIL PROTECTED]> Cc: [email protected] > 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 > > [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
