1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

Found a few bugs in Code Review

This commit is contained in:
Peter Beckman 2022-01-19 00:33:08 -05:00
parent 668b2c7490
commit f07600f24e

View File

@ -1012,7 +1012,7 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
QString latDigits = ''; QString latDigits = '';
QString messageBits = ''; QString messageBits = '';
int messageType = 0; // 0 = Standard, 1 = Custom int messageType = 0; // 0 = Standard, 1 = Custom
int latitudeOffset = 0; int longitudeOffset = 0;
float latitudeDirection = -1; // Assume South because North is easier to code float latitudeDirection = -1; // Assume South because North is easier to code
float longitudeDirection = 1; float longitudeDirection = 1;
@ -1023,7 +1023,7 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
if (inRange(48, 57, charInt)) { if (inRange(48, 57, charInt)) {
latDigits.append(static_cast<char>(dest[i] % 48)); latDigits.append(static_cast<char>(dest[i] % 48));
} else if (inRange(65, 74, charInt)) { } else if (inRange(65, 74, charInt)) {
latDigits.append(static_cast<char>(dest[i] % 48)); latDigits.append(static_cast<char>(dest[i] % 65));
} else if (inRange(80, 89, charInt)) { } else if (inRange(80, 89, charInt)) {
latDigits.append(static_cast<char>(dest[i] % 80)); latDigits.append(static_cast<char>(dest[i] % 80));
} else { } else {
@ -1052,7 +1052,7 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
// Longitude Offset // Longitude Offset
if (i == 4) { if (i == 4) {
if (inRange(65, 75, charInt)) if (inRange(65, 75, charInt))
latitudeOffset = 100; longitudeOffset = 100;
} }
// Longitude Direction // Longitude Direction
@ -1063,6 +1063,7 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
} }
m_latitude = (((float)latDigits.mid(0, 2)) + latDigits.mid(2, 2)/60.00 + latDigits.mid(4, 2)/60.0/100.0) * latitudeDirection; m_latitude = (((float)latDigits.mid(0, 2)) + latDigits.mid(2, 2)/60.00 + latDigits.mid(4, 2)/60.0/100.0) * latitudeDirection;
m_hasPosition = true;
} else } else
return false; return false;
@ -1086,11 +1087,9 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
&& (charToInt(info, idx+7) == 47 || charToInt(info, idx+7) == 92) && (charToInt(info, idx+7) == 47 || charToInt(info, idx+7) == 92)
) )
{ {
// Longitude // Longitude, plus offset encoded in the AX.25 Destination
int deg = charToInt(info, idx) - 28; int deg = (charToInt(info, idx) - 28) + longitudeOffset;
// Destination Byte 5, ASCII P through Z is offset of +100 // Destination Byte 5, ASCII P through Z is offset of +100
if (inRange(80, 90, charToInt(dest, 4)))
deg += 100;
if (inRange(180, 189, deg)) if (inRange(180, 189, deg))
deg -= 80; deg -= 80;
if (inRange(190, 199, deg)) if (inRange(190, 199, deg))
@ -1118,8 +1117,9 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
} else } else
return false; return false;
return true;
// Altitude // Altitude
// #TODO // #TODO
return true;
} }