Skip to content

Commit

Permalink
- GOOSE publisher: fixed bug in default parameter handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mzillgith committed Sep 8, 2023
1 parent 5012b3e commit ab8ac83
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/goose/goose_publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,17 @@ prepareGooseBuffer(GoosePublisher self, CommParameters* parameters, const char*
uint16_t appId;

if (parameters) {
dstAddr = defaultDstAddr;
priority = CONFIG_GOOSE_DEFAULT_PRIORITY;
vlanId = CONFIG_GOOSE_DEFAULT_VLAN_ID;
appId = CONFIG_GOOSE_DEFAULT_APPID;
}
else {
dstAddr = parameters->dstAddress;
priority = parameters->vlanPriority;
vlanId = parameters->vlanId;
appId = parameters->appId;
}
else {
dstAddr = defaultDstAddr;
priority = CONFIG_GOOSE_DEFAULT_PRIORITY;
vlanId = CONFIG_GOOSE_DEFAULT_VLAN_ID;
appId = CONFIG_GOOSE_DEFAULT_APPID;
}

if (interfaceID)
self->ethernetSocket = Ethernet_createSocket(interfaceID, dstAddr);
Expand All @@ -239,6 +239,12 @@ prepareGooseBuffer(GoosePublisher self, CommParameters* parameters, const char*
if (self->ethernetSocket) {
self->buffer = (uint8_t*) GLOBAL_MALLOC(GOOSE_MAX_MESSAGE_SIZE);

if (self->buffer == NULL) {
Ethernet_destroySocket(self->ethernetSocket);
self->ethernetSocket = NULL;
return false;
}

memcpy(self->buffer, dstAddr, 6);
memcpy(self->buffer + 6, srcAddr, 6);

Expand Down

0 comments on commit ab8ac83

Please sign in to comment.