1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-16 13:21:50 -05:00

Merge pull request #1342 from srcejon/fix_1333

AIS: Terminate NMEA sentences with CR/LF.
This commit is contained in:
Edouard Griffiths 2022-07-18 04:20:13 +02:00 committed by GitHub
commit cb09035fa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,7 +60,11 @@ QString AISMessage::toNMEA(const QByteArray bytes)
int c = 0; int c = 0;
for (int j = 0; j < 6; j++) for (int j = 0; j < 6; j++)
{ {
c = (c << 1) | ((bytes[i] >> (bits - 1)) & 0x1); if (i < bytes.size()) {
c = (c << 1) | ((bytes[i] >> (bits - 1)) & 0x1);
} else {
c = (c << 1);
}
bits--; bits--;
if (bits == 0) if (bits == 0)
{ {
@ -92,7 +96,7 @@ QString AISMessage::toNMEA(const QByteArray bytes)
sentence++; sentence++;
} }
return nmeaSentences.join("\n"); return nmeaSentences.join("\r\n").append("\r\n"); // NMEA-0183 requires CR and LF
} }
QString AISMessage::toNMEA() QString AISMessage::toNMEA()