|
|
|
@ -35,7 +35,7 @@
|
|
|
|
|
|
|
|
|
|
#define GOOSE_MAX_MESSAGE_SIZE 1518
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
static bool
|
|
|
|
|
prepareGooseBuffer(GoosePublisher self, CommParameters* parameters, const char* interfaceID, bool useVlanTags);
|
|
|
|
|
|
|
|
|
|
struct sGoosePublisher {
|
|
|
|
@ -68,11 +68,19 @@ GoosePublisher_createEx(CommParameters* parameters, const char* interfaceID, boo
|
|
|
|
|
{
|
|
|
|
|
GoosePublisher self = (GoosePublisher) GLOBAL_CALLOC(1, sizeof(struct sGoosePublisher));
|
|
|
|
|
|
|
|
|
|
prepareGooseBuffer(self, parameters, interfaceID, useVlanTag);
|
|
|
|
|
if (self) {
|
|
|
|
|
|
|
|
|
|
if (prepareGooseBuffer(self, parameters, interfaceID, useVlanTag)) {
|
|
|
|
|
self->timestamp = MmsValue_newUtcTimeByMsTime(Hal_getTimeInMs());
|
|
|
|
|
|
|
|
|
|
GoosePublisher_reset(self);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
GoosePublisher_destroy(self);
|
|
|
|
|
self = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
@ -86,7 +94,9 @@ GoosePublisher_create(CommParameters* parameters, const char* interfaceID)
|
|
|
|
|
void
|
|
|
|
|
GoosePublisher_destroy(GoosePublisher self)
|
|
|
|
|
{
|
|
|
|
|
if (self->ethernetSocket) {
|
|
|
|
|
Ethernet_destroySocket(self->ethernetSocket);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MmsValue_delete(self->timestamp);
|
|
|
|
|
|
|
|
|
@ -99,7 +109,9 @@ GoosePublisher_destroy(GoosePublisher self)
|
|
|
|
|
if (self->dataSetRef != NULL)
|
|
|
|
|
GLOBAL_FREEMEM(self->dataSetRef);
|
|
|
|
|
|
|
|
|
|
if (self->buffer)
|
|
|
|
|
GLOBAL_FREEMEM(self->buffer);
|
|
|
|
|
|
|
|
|
|
GLOBAL_FREEMEM(self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -164,7 +176,7 @@ GoosePublisher_setTimeAllowedToLive(GoosePublisher self, uint32_t timeAllowedToL
|
|
|
|
|
self->timeAllowedToLive = timeAllowedToLive;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
static bool
|
|
|
|
|
prepareGooseBuffer(GoosePublisher self, CommParameters* parameters, const char* interfaceID, bool useVlanTags)
|
|
|
|
|
{
|
|
|
|
|
uint8_t srcAddr[6];
|
|
|
|
@ -199,6 +211,7 @@ prepareGooseBuffer(GoosePublisher self, CommParameters* parameters, const char*
|
|
|
|
|
else
|
|
|
|
|
self->ethernetSocket = Ethernet_createSocket(CONFIG_ETHERNET_INTERFACE_ID, dstAddr);
|
|
|
|
|
|
|
|
|
|
if (self->ethernetSocket) {
|
|
|
|
|
self->buffer = (uint8_t*) GLOBAL_MALLOC(GOOSE_MAX_MESSAGE_SIZE);
|
|
|
|
|
|
|
|
|
|
memcpy(self->buffer, dstAddr, 6);
|
|
|
|
@ -243,6 +256,12 @@ prepareGooseBuffer(GoosePublisher self, CommParameters* parameters, const char*
|
|
|
|
|
self->buffer[bufPos++] = 0x00;
|
|
|
|
|
|
|
|
|
|
self->payloadStart = bufPos;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t
|
|
|
|
|