- GOOSE subscriber: always copy GoID and DatSet from GOOSE message; always create new MmsValue instance for GOOSE data set when subscriber is observer

pull/265/head
Michael Zillgith 5 years ago
parent 2bc47a6a6c
commit aabe20031f

@ -595,16 +595,13 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
printf("GOOSE_SUBSCRIBER: Found dataSet\n"); printf("GOOSE_SUBSCRIBER: Found dataSet\n");
{ {
if (matchingSubscriber) { if (matchingSubscriber) {
if (matchingSubscriber->isObserver) if (elementLength > 64) {
{ if (DEBUG_GOOSE_SUBSCRIBER)
if (elementLength > 64) { printf("GOOSE_SUBSCRIBER: datSet too long!\n");
if (DEBUG_GOOSE_SUBSCRIBER) }
printf("GOOSE_SUBSCRIBER: datSet too long!\n"); else {
} memcpy(matchingSubscriber->datSet, buffer + bufPos, elementLength);
else { matchingSubscriber->datSet[elementLength] = 0;
memcpy(matchingSubscriber->datSet, buffer + bufPos, elementLength);
matchingSubscriber->datSet[elementLength] = 0;
}
} }
} }
} }
@ -615,16 +612,13 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
printf("GOOSE_SUBSCRIBER: Found goId\n"); printf("GOOSE_SUBSCRIBER: Found goId\n");
{ {
if (matchingSubscriber) { if (matchingSubscriber) {
if (matchingSubscriber->isObserver) if (elementLength > 64) {
{ if (DEBUG_GOOSE_SUBSCRIBER)
if (elementLength > 64) { printf("GOOSE_SUBSCRIBER: goId too long!\n");
if (DEBUG_GOOSE_SUBSCRIBER) }
printf("GOOSE_SUBSCRIBER: goId too long!\n"); else {
} memcpy(matchingSubscriber->goId, buffer + bufPos, elementLength);
else { matchingSubscriber->goId[elementLength] = 0;
memcpy(matchingSubscriber->goId, buffer + bufPos, elementLength);
matchingSubscriber->goId[elementLength] = 0;
}
} }
} }
} }
@ -704,6 +698,11 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
MmsValue_setUtcTime(matchingSubscriber->timestamp, 0); MmsValue_setUtcTime(matchingSubscriber->timestamp, 0);
} }
if (matchingSubscriber->isObserver && matchingSubscriber->dataSetValues != NULL) {
MmsValue_delete(matchingSubscriber->dataSetValues);
matchingSubscriber->dataSetValues = NULL;
}
if (matchingSubscriber->dataSetValues == NULL) if (matchingSubscriber->dataSetValues == NULL)
matchingSubscriber->dataSetValues = parseAllDataUnknownValue(matchingSubscriber, dataSetBufferAddress, dataSetBufferLength, false); matchingSubscriber->dataSetValues = parseAllDataUnknownValue(matchingSubscriber, dataSetBufferAddress, dataSetBufferLength, false);
else else

Loading…
Cancel
Save