diff --git a/include/util/ILogEntry.h b/include/util/ILogEntry.h index 7507200..1f35cd1 100644 --- a/include/util/ILogEntry.h +++ b/include/util/ILogEntry.h @@ -9,7 +9,8 @@ class ILogEntry { public: - virtual size_t size(void) const = 0; + virtual size_t size(void) const = 0; // size of the log entry, including header + virtual size_t length(void) const = 0; // length of the payload (without header) virtual size_t serialize(std::function write) const = 0; virtual size_t deserialize(std::function read) = 0; virtual ~ILogEntry() = default; diff --git a/include/util/LogMessage.h b/include/util/LogMessage.h index e2d5994..08eedb5 100644 --- a/include/util/LogMessage.h +++ b/include/util/LogMessage.h @@ -12,6 +12,8 @@ constexpr uint32_t messagePayloadSize = 233; * Note: this struct does have vtable pointers, i.e. sizeof(LogMessageHeader)-8 is the real data size */ struct LogMessageHeader : public ILogEntry { + size_t length(void) const override { return _size; } + uint16_t _size; time_t time; uint32_t from; diff --git a/source/graphics/TFT/TFTView_320x240.cpp b/source/graphics/TFT/TFTView_320x240.cpp index a468139..49382d1 100644 --- a/source/graphics/TFT/TFTView_320x240.cpp +++ b/source/graphics/TFT/TFTView_320x240.cpp @@ -6347,8 +6347,8 @@ void TFTView_320x240::restoreMessage(const LogMessage &msg) pos += sprintf(buf, "%04x ", msg.from & 0xffff); } uint32_t len = timestamp(buf + pos, msg.time, false); - memcpy(buf + pos + len, msg.bytes, msg.size()); - buf[pos + len + msg.size()] = 0; + memcpy(buf + pos + len, msg.bytes, msg.length()); + buf[pos + len + msg.length()] = 0; lv_obj_t *container = newMessageContainer(msg.from, msg.to, msg.ch); lv_obj_add_flag(container, LV_OBJ_FLAG_HIDDEN);