From 26137ac1b136959582e42a5ab6d5a61648821561 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Thu, 16 Apr 2015 22:17:14 +0000 Subject: [PATCH] Increased NetworkMessage schema number and Qt serialization format The Qt_5_0 QDataStream serialization format is buggy, moved to the Qt_5_2 format. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5231 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- NetworkMessage.cpp | 6 +++++- NetworkMessage.hpp | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/NetworkMessage.cpp b/NetworkMessage.cpp index 9b06c5233..5c7e0f1a0 100644 --- a/NetworkMessage.cpp +++ b/NetworkMessage.cpp @@ -25,7 +25,7 @@ namespace NetworkMessage { *this << magic; *this << schema_number; - setVersion (QDataStream::Qt_5_0); // Qt schema version + setVersion (QDataStream::Qt_5_2); // Qt schema version *this << static_cast (type) << id.toUtf8 (); } @@ -49,6 +49,10 @@ namespace NetworkMessage { parent->setVersion (QDataStream::Qt_5_0); } + else if (schema_ <= 2) + { + parent->setVersion (QDataStream::Qt_5_2); + } quint32 type; *parent >> type >> id_; if (type >= maximum_message_type_) diff --git a/NetworkMessage.hpp b/NetworkMessage.hpp index 7496e08a6..3ac9fa434 100644 --- a/NetworkMessage.hpp +++ b/NetworkMessage.hpp @@ -6,7 +6,9 @@ * ====================== * * All messages are written or read using the QDataStream derivatives - * defined below. + * defined below, note that we are using the default for floating + * point precision which means all are double precision i.e. 64-bit + * IEEE format. * * Message is big endian format * @@ -22,7 +24,20 @@ * * http://doc.qt.io/qt-5/datastreamformat.html * - * for the serialization details for each type. + * for the serialization details for each type, at the time of + * writing the above document is for Qt_5_0 format which is buggy + * so we use Qt_5_2 format, differences are: + * + * QDateTime: + * QDate qint64 Julian day number + * QTime quint32 Milli-seconds since midnight + * timespec quint8 0=local, 1=UTC, 2=Offset from UTC + * (seconds) + * 3=time zone + * offset qint32 only present if timespec=2 + * timezone several-fields only present if timespec=3 + * + * we will avoid using QDateTime fields with time zones for simplicity. * * Type utf8 is a utf-8 byte string formatted as a QByteArray for * serialization purposes (currently a quint32 size followed by size @@ -49,7 +64,7 @@ * New bool * Time QTime * snr qint32 - * Delta time (S) float + * Delta time (S) float (serialized as double) * Delta frequency (Hz) quint32 * Mode utf8 * Message utf8 @@ -124,7 +139,7 @@ namespace NetworkMessage // increment this if a newer Qt schema is required and add decode // logic to InputMessageStream below - static quint32 constexpr schema_number {1}; + static quint32 constexpr schema_number {2}; explicit Builder (QIODevice *, Type, QString const& id); explicit Builder (QByteArray *, Type, QString const& id);