[novafinedust] Fix measurement parsing overflow (#12543)
Fixes #12542 Signed-off-by: Stefan Triller <github@stefantriller.de>
This commit is contained in:
parent
4f4dfcca20
commit
3c0d27dad8
|
@ -227,6 +227,7 @@ public class SDS011Communicator {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Read remaining bytes: {}, full reply={}", remainingBytesRead,
|
logger.debug("Read remaining bytes: {}, full reply={}", remainingBytesRead,
|
||||||
HexUtils.bytesToHex(readBuffer));
|
HexUtils.bytesToHex(readBuffer));
|
||||||
|
logger.trace("Read bytes as numbers: {}", Arrays.toString(readBuffer));
|
||||||
}
|
}
|
||||||
return ReplyFactory.create(readBuffer);
|
return ReplyFactory.create(readBuffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class SensorMeasuredDataReply extends SensorReply {
|
||||||
* @return the measured PM2.5 value
|
* @return the measured PM2.5 value
|
||||||
*/
|
*/
|
||||||
public float getPm25() {
|
public float getPm25() {
|
||||||
int shiftedValue = (pm25highByte << 8 & 0xFF) | pm25lowByte & 0xFF;
|
int shiftedValue = ((pm25highByte & 0xFF) << 8) | pm25lowByte & 0xFF;
|
||||||
return ((float) shiftedValue) / 10;
|
return ((float) shiftedValue) / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class SensorMeasuredDataReply extends SensorReply {
|
||||||
* @return the measured PM10 value
|
* @return the measured PM10 value
|
||||||
*/
|
*/
|
||||||
public float getPm10() {
|
public float getPm10() {
|
||||||
int shiftedValue = (pm10highByte << 8 & 0xFF) | pm10lowByte & 0xFF;
|
int shiftedValue = ((pm10highByte & 0xFF) << 8) | pm10lowByte & 0xFF;
|
||||||
return ((float) shiftedValue) / 10;
|
return ((float) shiftedValue) / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue