bugfix decoder.js for gps altidude

This commit is contained in:
Verkehrsrot 2019-07-28 12:05:21 +02:00
parent 3058973f66
commit 88db2cca2b
2 changed files with 1 additions and 11 deletions

View File

@ -151,12 +151,6 @@ var altitude = function (bytes) {
if (bytes.length !== altitude.BYTES) {
throw new Error('Altitude must have exactly 2 bytes');
}
var alt = bytesToInt(bytes);
if (alt > 32767) {
alt -= 65536;
}
return +(alt / 4 - 1000).toFixed(1);
};
altitude.BYTES = 2;

View File

@ -41,11 +41,7 @@ function Decoder(bytes, port) {
decoded.longitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
decoded.sats = bytes[i++];
decoded.hdop = (bytes[i++] << 8) | (bytes[i++]);
var alt = ((bytes[i++] << 8) | (bytes[i++]));
if (alt > 32767) {
alt -= 65536;
}
decoded.altitude = alt / 4 - 1000;
decoded.altitude = ((bytes[i++] << 8) | (bytes[i++])) / 4 - 1000;
}
if (port === 5) {