From 7d1a552cde17a93f14451b7fb34c5f4e450030bd Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Sat, 4 Jan 2020 17:18:04 +0100 Subject: [PATCH] - GOOSE publisher: fixed problem with overflow of stNum and sqNum (see #199) --- src/goose/goose_publisher.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/goose/goose_publisher.c b/src/goose/goose_publisher.c index 4ba245da..4540e487 100644 --- a/src/goose/goose_publisher.c +++ b/src/goose/goose_publisher.c @@ -159,6 +159,11 @@ GoosePublisher_increaseStNum(GoosePublisher self) MmsValue_setUtcTimeMs(self->timestamp, currentTime); self->stNum++; + + /* check for overflow */ + if (self->stNum == 0) + self->stNum = 1; + self->sqNum = 0; return currentTime; @@ -387,11 +392,14 @@ GoosePublisher_publish(GoosePublisher self, LinkedList dataSet) int32_t payloadLength = createGoosePayload(self, dataSet, buffer, maxPayloadSize); - self->sqNum++; - if (payloadLength == -1) return -1; + self->sqNum++; + + if (self->sqNum == 0) + self->sqNum = 1; + int lengthIndex = self->lengthField; size_t gooseLength = payloadLength + 8;