- SV publisher: Changed SampledValuesPublisher_create to support setting of Communication parameters at runtime

This commit is contained in:
Michael Zillgith 2017-06-13 17:35:15 +02:00
parent 3ac4cd88df
commit c08fe41cbb
7 changed files with 31 additions and 19 deletions

View file

@ -59,7 +59,7 @@ static SV_ASDU asdu;
static void
setupSVPublisher(const char* svInterface)
{
svPublisher = SampledValuesPublisher_create(svInterface);
svPublisher = SampledValuesPublisher_create(NULL, svInterface);
asdu = SampledValuesPublisher_addASDU(svPublisher, "xxxxMUnn01", NULL, 1);

View file

@ -29,7 +29,7 @@ main(int argc, char** argv)
printf("Using interface %s\n", interface);
SampledValuesPublisher svPublisher = SampledValuesPublisher_create(interface);
SampledValuesPublisher svPublisher = SampledValuesPublisher_create(NULL, interface);
SV_ASDU asdu1 = SampledValuesPublisher_addASDU(svPublisher, "svpub1", NULL, 1);
@ -60,7 +60,7 @@ main(int argc, char** argv)
SampledValuesPublisher_publish(svPublisher);
//Thread_sleep(50);
Thread_sleep(50);
}
SampledValuesPublisher_destroy(svPublisher);

View file

@ -31,6 +31,9 @@
extern "C" {
#endif
#ifndef GOOSE_SV_COMM_PARAMETERS
#define GOOSE_SV_COMM_PARAMETERS
typedef struct sCommParameters {
uint8_t vlanPriority;
uint16_t vlanId;
@ -38,6 +41,8 @@ typedef struct sCommParameters {
uint8_t dstAddress[6];
} CommParameters;
#endif
typedef struct sGoosePublisher* GoosePublisher;
GoosePublisher

View file

@ -1274,8 +1274,13 @@ IedServer_setWriteAccessPolicy(IedServer self, FunctionalConstraint fc, AccessPo
void
IedServer_handleWriteAccess(IedServer self, DataAttribute* dataAttribute, WriteAccessHandler handler, void* parameter)
{
if (dataAttribute == NULL)
*((int*) NULL) = 1;
if (dataAttribute == NULL) {
if (DEBUG_IED_SERVER)
printf("IED_SERVER: IedServer_handleWriteAccess - dataAttribute == NULL!\n");
/* Cause a trap */
*((volatile int*) NULL) = 1;
}
MmsMapping_installWriteAccessHandler(self->mmsMapping, dataAttribute, handler, parameter);
}

View file

@ -154,6 +154,8 @@ exit_with_error:
MmsValue*
MmsValue_decodeMmsData(uint8_t* buffer, int bufPos, int bufferLength)
{
MmsValue* value = NULL;
int dataEndBufPos = bufPos + bufferLength;
uint8_t tag = buffer[bufPos++];
@ -165,8 +167,6 @@ MmsValue_decodeMmsData(uint8_t* buffer, int bufPos, int bufferLength)
if (bufPos + dataLength > dataEndBufPos)
goto exit_with_error;
MmsValue* value = NULL;
switch (tag) {
case 0xa1: /* MMS_ARRAY */

View file

@ -42,15 +42,6 @@
#define SV_MAX_MESSAGE_SIZE 1518
typedef struct sCommParameters {
uint8_t vlanPriority;
uint16_t vlanId;
uint16_t appId;
uint8_t dstAddress[6];
} CommParameters;
struct sSV_ASDU {
char* svID;
char* datset;
@ -264,13 +255,13 @@ encodeUtcTime(uint64_t timeval, uint8_t* buffer, int bufPos)
}
SampledValuesPublisher
SampledValuesPublisher_create(const char* interfaceId)
SampledValuesPublisher_create(CommParameters* parameters, const char* interfaceId)
{
SampledValuesPublisher self = (SampledValuesPublisher) GLOBAL_CALLOC(1, sizeof(struct sSampledValuesPublisher));
self->asduLIst = NULL;
preparePacketBuffer(self, NULL, interfaceId);
preparePacketBuffer(self, parameters, interfaceId);
return self;
}

View file

@ -31,6 +31,17 @@
extern "C" {
#endif
#ifndef GOOSE_SV_COMM_PARAMETERS
#define GOOSE_SV_COMM_PARAMETERS
typedef struct sCommParameters {
uint8_t vlanPriority;
uint16_t vlanId;
uint16_t appId;
uint8_t dstAddress[6];
} CommParameters;
#endif
#define IEC61850_SV_SMPSYNC_NOT_SYNCHRONIZED 0
#define IEC61850_SV_SMPSYNC_SYNCED_UNSPEC_LOCAL_CLOCK 1
@ -45,7 +56,7 @@ typedef struct sSampledValuesPublisher* SampledValuesPublisher;
typedef struct sSV_ASDU* SV_ASDU;
SampledValuesPublisher
SampledValuesPublisher_create(const char* interfaceId);
SampledValuesPublisher_create(CommParameters* parameters, const char* interfaceId);
SV_ASDU
SampledValuesPublisher_addASDU(SampledValuesPublisher self, char* svID, char* datset, uint32_t confRev);