Updating the DC+28 Encoding Range to include the alternate encoding

This commit is contained in:
Peter Beckman 2022-01-20 16:18:05 -05:00
parent f4e2226fb4
commit e9a805824d
1 changed files with 10 additions and 15 deletions

View File

@ -1107,22 +1107,16 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
return false;
}
// Mic-E Data is encoded in ASCII.
// 0: Longitude Degrees, 0-360
// 1: Longitude Minutes, 0-59
// 2: Longitude Hundreths of a minute, 0-99
// 3: Speed, units of 10
// 4: Speed, units of 1, Course, Units of 100
// 5: Course, 0-99 degrees
if (inRange(38, 127, charToIntAscii(info, idx))
&& inRange(38, 97, charToIntAscii(info, idx+1))
&& inRange(28, 127, charToIntAscii(info, idx+2))
&& inRange(48, 127, charToIntAscii(info, idx+3))
&& inRange(28, 125, charToIntAscii(info, idx+4))
&& inRange(28, 127, charToIntAscii(info, idx+5))
// Mic-E Data is encoded in ASCII Characters
if (inRange(38, 127, charToIntAscii(info, idx)) // 0: Longitude Degrees, 0-360
&& inRange(38, 97, charToIntAscii(info, idx+1)) // 1: Longitude Minutes, 0-59
&& inRange(28, 127, charToIntAscii(info, idx+2)) // 2: Longitude Hundreths of a minute, 0-99
&& inRange(28, 127, charToIntAscii(info, idx+3)) // 3: Speed (tens), 0-800
&& inRange(28, 125, charToIntAscii(info, idx+4)) // 4: Speed (ones), 0-9, and Course (hundreds), {0, 100, 200, 300}
&& inRange(28, 127, charToIntAscii(info, idx+5)) // 5: Course, 0-99 degrees
)
{
// Longitude, plus offset encoded in the AX.25 Destination
// Longitude; Degrees plus offset encoded in the AX.25 Destination
// Destination Byte 5, ASCII P through Z indicates an offset of +100
int deg = (charToIntAscii(info, idx) - 28) + longitudeOffset;
if (inRange(180, 189, deg))
@ -1134,7 +1128,8 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
int hundreths = charToIntAscii(info, idx+2);
// Course and Speed
// Speed (SP+28, units of 10) can use two encodings: ASCII 28-47 and 108-127 are the same
// Speed & Course (DC+28, Speed units of 1, Course units of 100 e.g. 0, 100, 200, 300) uses two encodings
int speed = ((charToIntAscii(info, idx+3) - 28) * 10) % 800; // Speed in 10 kts units
float decoded_speed_course = (float)(charToIntAscii(info, idx+4) - 28) / 10.0;
speed += floor(decoded_speed_course); // Speed in 1 kt units, added to above