From dc22dc76eccdc9f26bb2c52822b9916b4cda3746 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Sat, 27 Feb 2021 11:54:21 +0100 Subject: [PATCH] - IED server: fixed bug in log service - old-entry and old-entry-time not updated --- src/iec61850/inc_private/logging.h | 3 +++ src/iec61850/server/mms_mapping/logging.c | 15 +++++++++++++-- src/logging/log_storage.c | 6 ++++++ src/logging/logging_api.h | 10 ++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/iec61850/inc_private/logging.h b/src/iec61850/inc_private/logging.h index 9ec8f936..74caf056 100644 --- a/src/iec61850/inc_private/logging.h +++ b/src/iec61850/inc_private/logging.h @@ -81,6 +81,9 @@ LogInstance_create(LogicalNode* parentLN, const char* name); LIB61850_INTERNAL void LogInstance_setLogStorage(LogInstance* self, LogStorage logStorage); +LIB61850_INTERNAL void +LogInstance_updateStatus(LogInstance* self); + LIB61850_INTERNAL void LogInstance_logSingleData(LogInstance* self, const char* dataRef, MmsValue* value, uint8_t flag); diff --git a/src/iec61850/server/mms_mapping/logging.c b/src/iec61850/server/mms_mapping/logging.c index 6d9e4551..e27d5f89 100644 --- a/src/iec61850/server/mms_mapping/logging.c +++ b/src/iec61850/server/mms_mapping/logging.c @@ -163,13 +163,21 @@ LogInstance_logEntryFinished(LogInstance* self, uint64_t entryID) self->locked = false; } +void +LogInstance_updateStatus(LogInstance* self) +{ + if (self->logStorage) { + LogStorage_getOldestAndNewestEntries(self->logStorage, &(self->newEntryId), &(self->newEntryTime), + &(self->oldEntryId), &(self->oldEntryTime)); + } +} + void LogInstance_setLogStorage(LogInstance* self, LogStorage logStorage) { self->logStorage = logStorage; - LogStorage_getOldestAndNewestEntries(logStorage, &(self->newEntryId), &(self->newEntryTime), - &(self->oldEntryId), &(self->oldEntryTime)); + LogInstance_updateStatus(self); } LogControl* @@ -357,6 +365,9 @@ updateLogStatusInLCB(LogControl* self) LogInstance* logInstance = self->logInstance; if (logInstance != NULL) { + + LogInstance_updateStatus(logInstance); + MmsValue_setBinaryTime(self->oldEntrTm, logInstance->oldEntryTime); MmsValue_setBinaryTime(self->newEntrTm, logInstance->newEntryTime); diff --git a/src/logging/log_storage.c b/src/logging/log_storage.c index 40335513..a4a52f22 100644 --- a/src/logging/log_storage.c +++ b/src/logging/log_storage.c @@ -30,6 +30,12 @@ LogStorage_setMaxLogEntries(LogStorage self, int maxEntries) self->maxLogEntries = maxEntries; } +int +LogStorage_getMaxLogEntries(LogStorage self) +{ + return self->maxLogEntries; +} + uint64_t LogStorage_addEntry(LogStorage self, uint64_t timestamp) { diff --git a/src/logging/logging_api.h b/src/logging/logging_api.h index a4493535..7f5327fc 100644 --- a/src/logging/logging_api.h +++ b/src/logging/logging_api.h @@ -107,6 +107,16 @@ struct sLogStorage { LIB61850_API void LogStorage_setMaxLogEntries(LogStorage self, int maxEntries); +/** + * \brief Get the maximum allowed number of log entries for this log + * + * \param self the pointer of the LogStorage instance + * + * \return the maximum number of log entries + */ +LIB61850_API int +LogStorage_getMaxLogEntries(LogStorage self); + /** * \brief Add an entry to the log *