diff --git a/sdrbase/util/radiosonde.cpp b/sdrbase/util/radiosonde.cpp index 124e1d4c2..b9f37cfb9 100644 --- a/sdrbase/util/radiosonde.cpp +++ b/sdrbase/util/radiosonde.cpp @@ -64,6 +64,9 @@ RS41Frame::RS41Frame(const QByteArray ba) : case RS41_ID_GPSPOS: decodeGPSPos(ba.mid(i+2, blockLength)); break; + case RS41_ID_POSDATETIME: + decodePosDateTime(ba.mid(i+2, blockLength)); + break; case RS41_ID_EMPTY: break; } @@ -169,6 +172,39 @@ void RS41Frame::decodeGPSPos(const QByteArray ba) } } +void RS41Frame::decodePosDateTime(const QByteArray ba) +{ + m_posValid = true; + int32_t ecefX = (int32_t)getUInt32(ba, 0x0); + int32_t ecefY = (int32_t)getUInt32(ba, 0x4); + int32_t ecefZ = (int32_t)getUInt32(ba, 0x8); + Coordinates::ecefToGeodetic(ecefX / 100.0, ecefY / 100.0, ecefZ / 100.0, m_latitude, m_longitude, m_height); + if ((m_height < -1000) || (m_height > 80000)) { + m_posValid = false; + return; + } + int32_t velX = (int16_t)getUInt16(ba, 0xc); + int32_t velY = (int16_t)getUInt16(ba, 0xe); + int32_t velZ = (int16_t)getUInt16(ba, 0x10); + Coordinates::ecefVelToSpeedHeading(m_latitude, m_longitude, velX / 100.0, velY / 100.0, velZ / 100.0, m_speed, m_verticalRate, m_heading); + + if (ba.size() >= 26) + { + m_gpsInfoValid = true; + uint16_t year = getUInt16(ba, 0x12); + uint8_t month = ba[0x14] & 0xff; + uint8_t day = ba[0x15] & 0xff; + uint8_t hour = ba[0x16] & 0xff; + uint8_t minute = ba[0x17] & 0xff; + uint8_t second = ba[0x18] & 0xff; + int msec = 0; + if ((ba[0x19] & 0xff) < 100) { + msec = (ba[0x19] & 0xff) * 10; + } + m_gpsDateTime = QDateTime(QDate(year, month, day), QTime(hour, minute, second, msec), Qt::UTC); + } +} + // Find the water vapor saturation pressure for a given temperature (for tCelsius < 0C). static float waterVapourSaturationPressure(float tCelsius) { diff --git a/sdrbase/util/radiosonde.h b/sdrbase/util/radiosonde.h index 001af7fca..869e6e43d 100644 --- a/sdrbase/util/radiosonde.h +++ b/sdrbase/util/radiosonde.h @@ -43,6 +43,7 @@ #define RS41_ID_GPSRAW 0x7d #define RS41_ID_GPSPOS 0x7b #define RS41_ID_EMPTY 0x76 +#define RS41_ID_POSDATETIME 0x82 #define RS41_RS_N 255 #define RS41_RS_K 231 @@ -108,6 +109,7 @@ public: void decodeMeas(const QByteArray ba); void decodeGPSInfo(const QByteArray ba); void decodeGPSPos(const QByteArray ba); + void decodePosDateTime(const QByteArray ba); float getPressureFloat(const RS41Subframe *subframe); QString getPressureString(const RS41Subframe *subframe);