|
|
@ -129,6 +129,7 @@ preparePacketBuffer(SVPublisher self, CommParameters* parameters, const char* in
|
|
|
|
|
|
|
|
|
|
|
|
self->buffer = (uint8_t*) GLOBAL_MALLOC(SV_MAX_MESSAGE_SIZE);
|
|
|
|
self->buffer = (uint8_t*) GLOBAL_MALLOC(SV_MAX_MESSAGE_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (self->buffer) {
|
|
|
|
memcpy(self->buffer, dstAddr, 6);
|
|
|
|
memcpy(self->buffer, dstAddr, 6);
|
|
|
|
memcpy(self->buffer + 6, srcAddr, 6);
|
|
|
|
memcpy(self->buffer + 6, srcAddr, 6);
|
|
|
|
|
|
|
|
|
|
|
@ -171,6 +172,10 @@ preparePacketBuffer(SVPublisher self, CommParameters* parameters, const char* in
|
|
|
|
self->buffer[bufPos++] = 0x00;
|
|
|
|
self->buffer[bufPos++] = 0x00;
|
|
|
|
|
|
|
|
|
|
|
|
self->payloadStart = bufPos;
|
|
|
|
self->payloadStart = bufPos;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -303,7 +308,7 @@ SVPublisher_createEx(CommParameters* parameters, const char* interfaceId, bool u
|
|
|
|
self->asduList = NULL;
|
|
|
|
self->asduList = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (preparePacketBuffer(self, parameters, interfaceId, useVlanTag) == false) {
|
|
|
|
if (preparePacketBuffer(self, parameters, interfaceId, useVlanTag) == false) {
|
|
|
|
GLOBAL_FREEMEM(self);
|
|
|
|
SVPublisher_destroy(self);
|
|
|
|
self = NULL;
|
|
|
|
self = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -502,7 +507,6 @@ SVPublisher_setupComplete(SVPublisher self)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
SVPublisher_publish(SVPublisher self)
|
|
|
|
SVPublisher_publish(SVPublisher self)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -512,11 +516,26 @@ SVPublisher_publish(SVPublisher self)
|
|
|
|
Ethernet_sendPacket(self->ethernetSocket, self->buffer, self->payloadStart + self->payloadLength);
|
|
|
|
Ethernet_sendPacket(self->ethernetSocket, self->buffer, self->payloadStart + self->payloadLength);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
SVPublisher_destroy(SVPublisher self)
|
|
|
|
SVPublisher_destroy(SVPublisher self)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (self->ethernetSocket)
|
|
|
|
|
|
|
|
Ethernet_destroySocket(self->ethernetSocket);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (self->buffer)
|
|
|
|
GLOBAL_FREEMEM(self->buffer);
|
|
|
|
GLOBAL_FREEMEM(self->buffer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SVPublisher_ASDU asdu = self->asduList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (asdu) {
|
|
|
|
|
|
|
|
SVPublisher_ASDU nextAsdu = asdu->_next;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GLOBAL_FREEMEM(asdu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
asdu = nextAsdu;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GLOBAL_FREEMEM(self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|