Merge branch 'master' of mz-automation.de:libiec61850

This commit is contained in:
Michael Zillgith 2015-01-29 11:53:15 +01:00
commit f94af555ee
34 changed files with 266 additions and 156 deletions

View file

@ -149,6 +149,7 @@ extern DataSetEntry ds_Device1_LLN0_dataset1_fcda2;
DataSetEntry ds_Device1_LLN0_dataset1_fcda0 = {
"Device1",
false,
"LLN0$ST$Mod$q",
-1,
NULL,
@ -158,6 +159,7 @@ DataSetEntry ds_Device1_LLN0_dataset1_fcda0 = {
DataSetEntry ds_Device1_LLN0_dataset1_fcda1 = {
"Device1",
false,
"MMXU1$ST$Mod$q",
-1,
NULL,
@ -167,6 +169,7 @@ DataSetEntry ds_Device1_LLN0_dataset1_fcda1 = {
DataSetEntry ds_Device1_LLN0_dataset1_fcda2 = {
"Device1",
false,
"MMXU1$CF$Mod$ctlModel",
-1,
NULL,

View file

@ -315,6 +315,7 @@ extern DataSetEntry ds_Inverter_LLN0_dataset1_fcda4;
DataSetEntry ds_Inverter_LLN0_dataset1_fcda0 = {
"Inverter",
false,
"LLN0$ST$Mod$q",
-1,
NULL,
@ -324,6 +325,7 @@ DataSetEntry ds_Inverter_LLN0_dataset1_fcda0 = {
DataSetEntry ds_Inverter_LLN0_dataset1_fcda1 = {
"Battery",
false,
"LLN0$ST$Mod$q",
-1,
NULL,
@ -333,6 +335,7 @@ DataSetEntry ds_Inverter_LLN0_dataset1_fcda1 = {
DataSetEntry ds_Inverter_LLN0_dataset1_fcda2 = {
"Inverter",
false,
"MMXU1$ST$Mod$q",
-1,
NULL,
@ -342,6 +345,7 @@ DataSetEntry ds_Inverter_LLN0_dataset1_fcda2 = {
DataSetEntry ds_Inverter_LLN0_dataset1_fcda3 = {
"Inverter",
false,
"MMXU1$CF$Mod$ctlModel",
-1,
NULL,
@ -351,6 +355,7 @@ DataSetEntry ds_Inverter_LLN0_dataset1_fcda3 = {
DataSetEntry ds_Inverter_LLN0_dataset1_fcda4 = {
"Inverter",
false,
"MMXU1$MX$TotW$mag",
-1,
NULL,

View file

@ -162,6 +162,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3;
DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO1$stVal",
-1,
NULL,
@ -171,6 +172,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO2$stVal",
-1,
NULL,
@ -180,6 +182,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO3$stVal",
-1,
NULL,
@ -189,6 +192,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO4$stVal",
-1,
NULL,
@ -211,6 +215,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events2_fcda3;
DataSetEntry ds_GenericIO_LLN0_Events2_fcda0 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO1",
-1,
NULL,
@ -220,6 +225,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda0 = {
DataSetEntry ds_GenericIO_LLN0_Events2_fcda1 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO2",
-1,
NULL,
@ -229,6 +235,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda1 = {
DataSetEntry ds_GenericIO_LLN0_Events2_fcda2 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO3",
-1,
NULL,
@ -238,6 +245,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda2 = {
DataSetEntry ds_GenericIO_LLN0_Events2_fcda3 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO4",
-1,
NULL,
@ -264,6 +272,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Measurements_fcda7;
DataSetEntry ds_GenericIO_LLN0_Measurements_fcda0 = {
"GenericIO",
false,
"GGIO1$MX$AnIn1$mag$f",
-1,
NULL,
@ -273,6 +282,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda0 = {
DataSetEntry ds_GenericIO_LLN0_Measurements_fcda1 = {
"GenericIO",
false,
"GGIO1$MX$AnIn1$q",
-1,
NULL,
@ -282,6 +292,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda1 = {
DataSetEntry ds_GenericIO_LLN0_Measurements_fcda2 = {
"GenericIO",
false,
"GGIO1$MX$AnIn2$mag$f",
-1,
NULL,
@ -291,6 +302,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda2 = {
DataSetEntry ds_GenericIO_LLN0_Measurements_fcda3 = {
"GenericIO",
false,
"GGIO1$MX$AnIn2$q",
-1,
NULL,
@ -300,6 +312,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda3 = {
DataSetEntry ds_GenericIO_LLN0_Measurements_fcda4 = {
"GenericIO",
false,
"GGIO1$MX$AnIn3$mag$f",
-1,
NULL,
@ -309,6 +322,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda4 = {
DataSetEntry ds_GenericIO_LLN0_Measurements_fcda5 = {
"GenericIO",
false,
"GGIO1$MX$AnIn3$q",
-1,
NULL,
@ -318,6 +332,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda5 = {
DataSetEntry ds_GenericIO_LLN0_Measurements_fcda6 = {
"GenericIO",
false,
"GGIO1$MX$AnIn4$mag$f",
-1,
NULL,
@ -327,6 +342,7 @@ DataSetEntry ds_GenericIO_LLN0_Measurements_fcda6 = {
DataSetEntry ds_GenericIO_LLN0_Measurements_fcda7 = {
"GenericIO",
false,
"GGIO1$MX$AnIn4$q",
-1,
NULL,

View file

@ -159,6 +159,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3;
DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO1$stVal",
-1,
NULL,
@ -168,6 +169,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO2$stVal",
-1,
NULL,
@ -177,6 +179,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO3$stVal",
-1,
NULL,
@ -186,6 +189,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO4$stVal",
-1,
NULL,

View file

@ -159,6 +159,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3;
DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO1$stVal",
-1,
NULL,
@ -168,6 +169,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO2$stVal",
-1,
NULL,
@ -177,6 +179,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO3$stVal",
-1,
NULL,
@ -186,6 +189,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO4$stVal",
-1,
NULL,

View file

@ -160,6 +160,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3;
DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO1$stVal",
-1,
NULL,
@ -169,6 +170,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO2$stVal",
-1,
NULL,
@ -178,6 +180,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO3$stVal",
-1,
NULL,
@ -187,6 +190,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO4$stVal",
-1,
NULL,
@ -209,6 +213,7 @@ extern DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda3;
DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda0 = {
"GenericIO",
false,
"GGIO1$MX$AnIn1",
-1,
NULL,
@ -218,6 +223,7 @@ DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda0 = {
DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda1 = {
"GenericIO",
false,
"GGIO1$MX$AnIn2",
-1,
NULL,
@ -227,6 +233,7 @@ DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda1 = {
DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda2 = {
"GenericIO",
false,
"GGIO1$MX$AnIn3",
-1,
NULL,
@ -236,6 +243,7 @@ DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda2 = {
DataSetEntry ds_GenericIO_LLN0_AnalogValues_fcda3 = {
"GenericIO",
false,
"GGIO1$MX$AnIn4",
-1,
NULL,

View file

@ -161,6 +161,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events_fcda3;
DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO1$stVal",
-1,
NULL,
@ -170,6 +171,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda0 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO2$stVal",
-1,
NULL,
@ -179,6 +181,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda1 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO3$stVal",
-1,
NULL,
@ -188,6 +191,7 @@ DataSetEntry ds_GenericIO_LLN0_Events_fcda2 = {
DataSetEntry ds_GenericIO_LLN0_Events_fcda3 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO4$stVal",
-1,
NULL,
@ -210,6 +214,7 @@ extern DataSetEntry ds_GenericIO_LLN0_Events2_fcda3;
DataSetEntry ds_GenericIO_LLN0_Events2_fcda0 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO1",
-1,
NULL,
@ -219,6 +224,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda0 = {
DataSetEntry ds_GenericIO_LLN0_Events2_fcda1 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO2",
-1,
NULL,
@ -228,6 +234,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda1 = {
DataSetEntry ds_GenericIO_LLN0_Events2_fcda2 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO3",
-1,
NULL,
@ -237,6 +244,7 @@ DataSetEntry ds_GenericIO_LLN0_Events2_fcda2 = {
DataSetEntry ds_GenericIO_LLN0_Events2_fcda3 = {
"GenericIO",
false,
"GGIO1$ST$SPCSO4",
-1,
NULL,

View file

@ -148,7 +148,7 @@ Conversions_msTimeToGeneralizedTime(uint64_t msTime, uint8_t* buffer)
}
static int
getSecondsOffset(char* offsetString)
getSecondsOffset(const char* offsetString)
{
int hourOffset = StringUtils_digitsToInt(offsetString, 2);
@ -166,7 +166,7 @@ getSecondsOffset(char* offsetString)
}
uint64_t
Conversions_generalizedTimeToMsTime(char* gtString)
Conversions_generalizedTimeToMsTime(const char* gtString)
{
int gtStringLen = strlen(gtString);
@ -205,12 +205,12 @@ Conversions_generalizedTimeToMsTime(char* gtString)
int msOffset = 0;
char* parsePos = gtString + 14;
const char* parsePos = gtString + 14;
/* parse optional fraction of second field */
if (*(parsePos) == '.') {
parsePos++;
char* fractionOfSecondStart = parsePos;
const char* fractionOfSecondStart = parsePos;
int fractionOfSecondLen = 0;
@ -266,7 +266,7 @@ Conversions_generalizedTimeToMsTime(char* gtString)
}
void
memcpyReverseByteOrder(uint8_t* dst, uint8_t* src, int size)
memcpyReverseByteOrder(uint8_t* dst, const uint8_t* src, int size)
{
int i = 0;
for (i = 0; i < size; i++) {

View file

@ -35,9 +35,9 @@ void
Conversions_msTimeToGeneralizedTime(uint64_t msTime, uint8_t* buffer);
uint64_t
Conversions_generalizedTimeToMsTime(char* gtString);
Conversions_generalizedTimeToMsTime(const char* gtString);
void
memcpyReverseByteOrder(uint8_t* dst, uint8_t* src, int size);
memcpyReverseByteOrder(uint8_t* dst, const uint8_t* src, int size);
#endif /* CONVERSIONS_H_ */

View file

@ -50,7 +50,7 @@ char*
createStringInBuffer(char* buffer, int count, ...);
char*
createStringFromBuffer(uint8_t* buf, int size);
createStringFromBuffer(const uint8_t* buf, int size);
void
StringUtils_replace(char* string, char oldChar, char newChar);
@ -62,7 +62,7 @@ int
StringUtils_digitToInt(char digit);
int
StringUtils_digitsToInt(char* digits, int count);
StringUtils_digitsToInt(const char* digits, int count);
int
StringUtils_createBufferFromHexString(char* hexString, uint8_t* buffer);

View file

@ -61,7 +61,7 @@ copyStringToBuffer(const char* string, char* buffer)
char*
createStringFromBuffer(uint8_t* buf, int size)
createStringFromBuffer(const uint8_t* buf, int size)
{
char* newStr = (char*) GLOBAL_MALLOC(size + 1);
@ -159,7 +159,7 @@ StringUtils_digitToInt(char digit)
}
int
StringUtils_digitsToInt(char* digits, int count)
StringUtils_digitsToInt(const char* digits, int count)
{
int i = 0;
int value = 0;

View file

@ -65,7 +65,7 @@ struct sControlObjectClient
};
static void
convertToMmsAndInsertFC(char* newItemId, char* originalObjectName, char* fc)
convertToMmsAndInsertFC(char* newItemId, const char* originalObjectName, const char* fc)
{
int originalLength = strlen(originalObjectName);
@ -106,7 +106,7 @@ resetLastApplError(ControlObjectClient self)
}
ControlObjectClient
ControlObjectClient_create(char* objectReference, IedConnection connection)
ControlObjectClient_create(const char* objectReference, IedConnection connection)
{
ControlObjectClient self = NULL;
@ -423,6 +423,9 @@ ControlObjectClient_operate(ControlObjectClient self, MmsValue* ctlVal, uint64_t
goto exit_function;
}
MmsValue_update(self->ctlVal, ctlVal);
self->opertime = operTime;
success = true;
exit_function:
@ -503,6 +506,8 @@ ControlObjectClient_selectWithValue(ControlObjectClient self, MmsValue* ctlVal)
return false;
}
MmsValue_update(self->ctlVal, ctlVal);
return true;
}

View file

@ -45,7 +45,7 @@ struct sClientGooseControlBlock {
};
ClientGooseControlBlock
ClientGooseControlBlock_create(char* objectReference)
ClientGooseControlBlock_create(const char* objectReference)
{
ClientGooseControlBlock self = (ClientGooseControlBlock) GLOBAL_CALLOC(1, sizeof(struct sClientGooseControlBlock));
@ -100,7 +100,7 @@ ClientGooseControlBlock_getGoID(ClientGooseControlBlock self)
}
void
ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, char* goID)
ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, const char* goID)
{
if (self->goID == NULL)
self->goID = MmsValue_newVisibleString(goID);
@ -118,7 +118,7 @@ ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self)
}
void
ClientGooseControlBlock_setDatSet(ClientGooseControlBlock self, char* datSet)
ClientGooseControlBlock_setDatSet(ClientGooseControlBlock self, const char* datSet)
{
if (self->datSet == NULL)
self->datSet = MmsValue_newVisibleString(datSet);
@ -285,7 +285,7 @@ private_ClientGooseControlBlock_updateValues(ClientGooseControlBlock self, MmsVa
}
ClientGooseControlBlock
IedConnection_getGoCBValues(IedConnection self, IedClientError* error, char* goCBReference, ClientGooseControlBlock updateGoCB)
IedConnection_getGoCBValues(IedConnection self, IedClientError* error, const char* goCBReference, ClientGooseControlBlock updateGoCB)
{
MmsError mmsError = MMS_ERROR_NONE;
*error = IED_ERROR_OK;
@ -297,9 +297,9 @@ IedConnection_getGoCBValues(IedConnection self, IedClientError* error, char* goC
MmsMapping_getMmsDomainFromObjectReference(goCBReference, domainId);
char* itemIdStart = goCBReference + strlen(domainId) + 1;
const char* itemIdStart = goCBReference + strlen(domainId) + 1;
char* separator = strchr(itemIdStart, '.');
const char* separator = strchr(itemIdStart, '.');
if (separator == NULL) {
*error = IED_ERROR_OBJECT_REFERENCE_INVALID;

View file

@ -222,7 +222,7 @@ ClientReport_getDataSetValues(ClientReport self)
}
static ClientReport
lookupReportHandler(IedConnection self, char* rcbReference)
lookupReportHandler(IedConnection self, const char* rcbReference)
{
LinkedList element = LinkedList_getNext(self->enabledReports);
@ -239,7 +239,7 @@ lookupReportHandler(IedConnection self, char* rcbReference)
}
void
IedConnection_installReportHandler(IedConnection self, char* rcbReference, char* rptId, ReportCallbackFunction handler,
IedConnection_installReportHandler(IedConnection self, const char* rcbReference, const char* rptId, ReportCallbackFunction handler,
void* handlerParameter)
{
ClientReport report = lookupReportHandler(self, rcbReference);
@ -268,7 +268,7 @@ IedConnection_installReportHandler(IedConnection self, char* rcbReference, char*
}
void
IedConnection_uninstallReportHandler(IedConnection self, char* rcbReference)
IedConnection_uninstallReportHandler(IedConnection self, const char* rcbReference)
{
ClientReport report = lookupReportHandler(self, rcbReference);
@ -279,7 +279,7 @@ IedConnection_uninstallReportHandler(IedConnection self, char* rcbReference)
}
void
IedConnection_triggerGIReport(IedConnection self, IedClientError* error, char* rcbReference)
IedConnection_triggerGIReport(IedConnection self, IedClientError* error, const char* rcbReference)
{
char domainId[65];
char itemId[129];

View file

@ -32,9 +32,9 @@
#include "mms_mapping.h"
static bool
isBufferedRcb(char* objectReference)
isBufferedRcb(const char* objectReference)
{
char* separator = strchr(objectReference, '.');
const char* separator = strchr(objectReference, '.');
if (separator == NULL)
return false; //TODO report an error
@ -46,7 +46,7 @@ isBufferedRcb(char* objectReference)
}
ClientReportControlBlock
ClientReportControlBlock_create(char* objectReference)
ClientReportControlBlock_create(const char* objectReference)
{
ClientReportControlBlock self = (ClientReportControlBlock) GLOBAL_CALLOC(1, sizeof(struct sClientReportControlBlock));
@ -103,7 +103,7 @@ ClientReportControlBlock_getRptId(ClientReportControlBlock self)
}
void
ClientReportControlBlock_setRptId(ClientReportControlBlock self, char* rptId)
ClientReportControlBlock_setRptId(ClientReportControlBlock self, const char* rptId)
{
if (self->rptId == NULL)
self->rptId = MmsValue_newVisibleString(rptId);
@ -160,7 +160,7 @@ ClientReportControlBlock_getDataSetReference(ClientReportControlBlock self)
}
void
ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, char* dataSetReference)
ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, const char* dataSetReference)
{
if (self->datSet == NULL)
self->datSet = MmsValue_newVisibleString(dataSetReference);
@ -423,7 +423,7 @@ private_ClientReportControlBlock_updateValues(ClientReportControlBlock self, Mms
ClientReportControlBlock
IedConnection_getRCBValues(IedConnection self, IedClientError* error, char* rcbReference,
IedConnection_getRCBValues(IedConnection self, IedClientError* error, const char* rcbReference,
ClientReportControlBlock updateRcb)
{
MmsError mmsError = MMS_ERROR_NONE;

View file

@ -501,7 +501,7 @@ connectionLostHandler(MmsConnection connection, void* parameter)
}
void
IedConnection_connect(IedConnection self, IedClientError* error, char* hostname, int tcpPort)
IedConnection_connect(IedConnection self, IedClientError* error, const char* hostname, int tcpPort)
{
MmsError mmsError;

View file

@ -63,13 +63,13 @@ Quality_unsetFlag(Quality* self, int flag)
Quality
Quality_fromMmsValue(MmsValue* mmsValue)
Quality_fromMmsValue(const MmsValue* mmsValue)
{
return (Quality) MmsValue_getBitStringAsInteger(mmsValue);
}
Dbpos
Dbpos_fromMmsValue(MmsValue* mmsValue)
Dbpos_fromMmsValue(const MmsValue* mmsValue)
{
return (Dbpos) MmsValue_getBitStringAsIntegerBigEndian(mmsValue);
}
@ -131,7 +131,7 @@ FunctionalConstraint_toString(FunctionalConstraint fc) {
}
FunctionalConstraint
FunctionalConstraint_fromString(char* fcString)
FunctionalConstraint_fromString(const char* fcString)
{
if (fcString[0] == 'S') {
if (fcString[1] == 'T')

View file

@ -186,7 +186,7 @@ IedConnection_setConnectTimeout(IedConnection self, uint32_t timeoutInMs);
* \param tcpPort the TCP port number of the server to connect to
*/
void
IedConnection_connect(IedConnection self, IedClientError* error, char* hostname, int tcpPort);
IedConnection_connect(IedConnection self, IedClientError* error, const char* hostname, int tcpPort);
/**
* \brief Abort the connection
@ -325,7 +325,7 @@ IedConnection_getMmsConnection(IedConnection self);
**************************************************/
ClientGooseControlBlock
ClientGooseControlBlock_create(char* dataAttributeReference);
ClientGooseControlBlock_create(const char* dataAttributeReference);
void
ClientGooseControlBlock_destroy(ClientGooseControlBlock self);
@ -340,13 +340,13 @@ char*
ClientGooseControlBlock_getGoID(ClientGooseControlBlock self);
void
ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, char* goID);
ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, const char* goID);
char*
ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self);
void
ClientGooseControlBlock_setDatSet(ClientGooseControlBlock self, char* datSet);
ClientGooseControlBlock_setDatSet(ClientGooseControlBlock self, const char* datSet);
uint32_t
ClientGooseControlBlock_getConfRev(ClientGooseControlBlock self);
@ -420,7 +420,7 @@ ClientGooseControlBlock_setDstAddress_appid(ClientGooseControlBlock self, uint16
* the updateRcb parameter.
*/
ClientGooseControlBlock
IedConnection_getGoCBValues(IedConnection self, IedClientError* error, char* goCBReference, ClientGooseControlBlock updateGoCB);
IedConnection_getGoCBValues(IedConnection self, IedClientError* error, const char* goCBReference, ClientGooseControlBlock updateGoCB);
/**
* \brief Write access to attributes of a GOOSE control block (GoCB) at the connected server
@ -493,7 +493,7 @@ IedConnection_setGoCBValues(IedConnection self, IedClientError* error, ClientGoo
* the updateRcb parameter.
*/
ClientReportControlBlock
IedConnection_getRCBValues(IedConnection self, IedClientError* error, char* rcbReference,
IedConnection_getRCBValues(IedConnection self, IedClientError* error, const char* rcbReference,
ClientReportControlBlock updateRcb);
/** Describes the reason for the inclusion of the element in the report */
@ -624,7 +624,7 @@ typedef void (*ReportCallbackFunction) (void* parameter, ClientReport report);
* \param handlerParameter user provided parameter that will be passed to the callback function
*/
void
IedConnection_installReportHandler(IedConnection self, char* rcbReference, char* rptId, ReportCallbackFunction handler,
IedConnection_installReportHandler(IedConnection self, const char* rcbReference, const char* rptId, ReportCallbackFunction handler,
void* handlerParameter);
/**
@ -634,7 +634,7 @@ IedConnection_installReportHandler(IedConnection self, char* rcbReference, char*
* \param rcbReference object reference of the report control block
*/
void
IedConnection_uninstallReportHandler(IedConnection self, char* rcbReference);
IedConnection_uninstallReportHandler(IedConnection self, const char* rcbReference);
/**
* \brief Trigger a general interrogation (GI) report for the specified report control block (RCB)
@ -646,7 +646,7 @@ IedConnection_uninstallReportHandler(IedConnection self, char* rcbReference);
* \param rcbReference object reference of the report control block
*/
void
IedConnection_triggerGIReport(IedConnection self, IedClientError* error, char* rcbReference);
IedConnection_triggerGIReport(IedConnection self, IedClientError* error, const char* rcbReference);
/****************************************
* Access to received reports
@ -788,7 +788,7 @@ ReasonForInclusion_getValueAsString(ReasonForInclusion reasonCode);
**************************************************/
ClientReportControlBlock
ClientReportControlBlock_create(char* rcbReference);
ClientReportControlBlock_create(const char* rcbReference);
void
ClientReportControlBlock_destroy(ClientReportControlBlock self);
@ -803,7 +803,7 @@ char*
ClientReportControlBlock_getRptId(ClientReportControlBlock self);
void
ClientReportControlBlock_setRptId(ClientReportControlBlock self, char* rptId);
ClientReportControlBlock_setRptId(ClientReportControlBlock self, const char* rptId);
bool
ClientReportControlBlock_getRptEna(ClientReportControlBlock self);
@ -837,7 +837,7 @@ ClientReportControlBlock_getDataSetReference(ClientReportControlBlock self);
* \param dataSetReference the reference of the data set
*/
void
ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, char* dataSetReference);
ClientReportControlBlock_setDataSetReference(ClientReportControlBlock self, const char* dataSetReference);
uint32_t
ClientReportControlBlock_getConfRev(ClientReportControlBlock self);
@ -1256,7 +1256,7 @@ typedef enum {
* \return the newly created instance or NULL if the creation failed
*/
ControlObjectClient
ControlObjectClient_create(char* objectReference, IedConnection connection);
ControlObjectClient_create(const char* objectReference, IedConnection connection);
void
ControlObjectClient_destroy(ControlObjectClient self);

View file

@ -212,7 +212,7 @@ FunctionalConstraint_toString(FunctionalConstraint fc);
* \brief parse a string treated as a functional constraint representation
*/
FunctionalConstraint
FunctionalConstraint_fromString(char* fcString);
FunctionalConstraint_fromString(const char* fcString);
/** @} */
@ -262,7 +262,7 @@ bool
Quality_isFlagSet(Quality* self, int flag);
Quality
Quality_fromMmsValue(MmsValue* mmsValue);
Quality_fromMmsValue(const MmsValue* mmsValue);
/** @} */
@ -288,7 +288,7 @@ typedef enum {
* \return the corresponding Dbpos value
*/
Dbpos
Dbpos_fromMmsValue(MmsValue* mmsValue);
Dbpos_fromMmsValue(const MmsValue* mmsValue);
/**
* \brief conver Dbpos to MMS bit string

View file

@ -340,7 +340,7 @@ IedServer_getAttributeValue(IedServer self, DataAttribute* dataAttribute);
* \return true or false
*/
bool
IedServer_getBooleanAttributeValue(IedServer self, DataAttribute* dataAttribute);
IedServer_getBooleanAttributeValue(IedServer self, const DataAttribute* dataAttribute);
/**
* \brief Get data attribute value of an integer data attribute
@ -354,7 +354,7 @@ IedServer_getBooleanAttributeValue(IedServer self, DataAttribute* dataAttribute)
* \return the value as 32 bit integer
*/
int32_t
IedServer_getInt32AttributeValue(IedServer self, DataAttribute* dataAttribute);
IedServer_getInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute);
/**
* \brief Get data attribute value of an integer data attribute
@ -368,7 +368,7 @@ IedServer_getInt32AttributeValue(IedServer self, DataAttribute* dataAttribute);
* \return the value as 64 bit integer
*/
int64_t
IedServer_getInt64AttributeValue(IedServer self, DataAttribute* dataAttribute);
IedServer_getInt64AttributeValue(IedServer self, const DataAttribute* dataAttribute);
/**
* \brief Get data attribute value of an unsigned integer data attribute
@ -382,7 +382,7 @@ IedServer_getInt64AttributeValue(IedServer self, DataAttribute* dataAttribute);
* \return the value as 32 bit unsigned integer
*/
uint32_t
IedServer_getUInt32AttributeValue(IedServer self, DataAttribute* dataAttribute);
IedServer_getUInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute);
/**
* \brief Get data attribute value of a floating point data attribute
@ -396,7 +396,7 @@ IedServer_getUInt32AttributeValue(IedServer self, DataAttribute* dataAttribute);
* \return the value as 32 bit float
*/
float
IedServer_getFloatAttributeValue(IedServer self, DataAttribute* dataAttribute);
IedServer_getFloatAttributeValue(IedServer self, const DataAttribute* dataAttribute);
/**
* \brief Get data attribute value of a UTC time data attribute
@ -410,7 +410,7 @@ IedServer_getFloatAttributeValue(IedServer self, DataAttribute* dataAttribute);
* \return the value as 32 bit float
*/
uint64_t
IedServer_getUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute);
IedServer_getUTCTimeAttributeValue(IedServer self, const DataAttribute* dataAttribute);
/**
* \brief Get data attribute value of a bit string data attribute as integer value
@ -428,7 +428,7 @@ IedServer_getUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute)
* \return the value a 32 bit integer.
*/
uint32_t
IedServer_getBitStringAttributeValue(IedServer self, DataAttribute* dataAttribute);
IedServer_getBitStringAttributeValue(IedServer self, const DataAttribute* dataAttribute);
/**
* \brief Get data attribute value of a string type data attribute
@ -442,7 +442,7 @@ IedServer_getBitStringAttributeValue(IedServer self, DataAttribute* dataAttribut
* \return the value as a C string (null terminated string)
*/
char*
IedServer_getStringAttributeValue(IedServer self, DataAttribute* dataAttribute);
IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute);
/**
@ -597,11 +597,26 @@ IedServer_updateVisibleStringAttributeValue(IedServer self, DataAttribute* dataA
*
* \param self the instance of IedServer to operate on.
* \param dataAttribute the data attribute handle
* \param value the new UTC time value of the data attribute.
* \param value the new UTC time value of the data attribute as a ms timestamp
*/
void
IedServer_updateUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute, uint64_t value);
/**
* \brief Update the value of an IEC 61850 UTC time (timestamp) data attribute.
*
* Update the value of a UTC time data attribute without handling MmsValue instances.
*
* This function will also check if a trigger condition is satisfied in the case when a report or GOOSE
* control block is enabled.
*
* \param self the instance of IedServer to operate on.
* \param dataAttribute the data attribute handle
* \param value the new UTC time value of the data attribute as a Timestamp
*/
void
IedServer_updateTimestampAttributeValue(IedServer self, DataAttribute* dataAttribute, Timestamp* timestamp);
/**
* \brief Update a quality ("q") IEC 61850 data attribute.
*

View file

@ -24,6 +24,7 @@
#include "iec61850_server.h"
#include "mms_mapping.h"
#include "mms_mapping_internal.h"
#include "mms_value_internal.h"
#include "control.h"
#include "stack_config.h"
#include "ied_server_private.h"
@ -656,7 +657,7 @@ IedServer_getAttributeValue(IedServer self, DataAttribute* dataAttribute)
}
bool
IedServer_getBooleanAttributeValue(IedServer self, DataAttribute* dataAttribute)
IedServer_getBooleanAttributeValue(IedServer self, const DataAttribute* dataAttribute)
{
assert(self != NULL);
assert(dataAttribute != NULL);
@ -667,7 +668,7 @@ IedServer_getBooleanAttributeValue(IedServer self, DataAttribute* dataAttribute)
}
int32_t
IedServer_getInt32AttributeValue(IedServer self, DataAttribute* dataAttribute)
IedServer_getInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute)
{
assert(self != NULL);
assert(dataAttribute != NULL);
@ -679,7 +680,7 @@ IedServer_getInt32AttributeValue(IedServer self, DataAttribute* dataAttribute)
}
int64_t
IedServer_getInt64AttributeValue(IedServer self, DataAttribute* dataAttribute)
IedServer_getInt64AttributeValue(IedServer self, const DataAttribute* dataAttribute)
{
assert(self != NULL);
assert(dataAttribute != NULL);
@ -691,7 +692,7 @@ IedServer_getInt64AttributeValue(IedServer self, DataAttribute* dataAttribute)
}
uint32_t
IedServer_getUInt32AttributeValue(IedServer self, DataAttribute* dataAttribute)
IedServer_getUInt32AttributeValue(IedServer self, const DataAttribute* dataAttribute)
{
assert(self != NULL);
assert(dataAttribute != NULL);
@ -703,7 +704,7 @@ IedServer_getUInt32AttributeValue(IedServer self, DataAttribute* dataAttribute)
}
float
IedServer_getFloatAttributeValue(IedServer self, DataAttribute* dataAttribute)
IedServer_getFloatAttributeValue(IedServer self, const DataAttribute* dataAttribute)
{
assert(self != NULL);
assert(dataAttribute != NULL);
@ -714,7 +715,7 @@ IedServer_getFloatAttributeValue(IedServer self, DataAttribute* dataAttribute)
}
uint64_t
IedServer_getUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute)
IedServer_getUTCTimeAttributeValue(IedServer self, const DataAttribute* dataAttribute)
{
assert(self != NULL);
assert(dataAttribute != NULL);
@ -725,7 +726,7 @@ IedServer_getUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute)
}
uint32_t
IedServer_getBitStringAttributeValue(IedServer self, DataAttribute* dataAttribute)
IedServer_getBitStringAttributeValue(IedServer self, const DataAttribute* dataAttribute)
{
assert(self != NULL);
assert(dataAttribute != NULL);
@ -737,7 +738,7 @@ IedServer_getBitStringAttributeValue(IedServer self, DataAttribute* dataAttribut
}
char*
IedServer_getStringAttributeValue(IedServer self, DataAttribute* dataAttribute)
IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute)
{
assert(self != NULL);
assert(dataAttribute != NULL);
@ -957,6 +958,23 @@ IedServer_updateUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribu
}
}
void
IedServer_updateTimestampAttributeValue(IedServer self, DataAttribute* dataAttribute, Timestamp* timestamp)
{
assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_UTC_TIME);
assert(dataAttribute != NULL);
assert(self != NULL);
if (memcmp(dataAttribute->mmsValue->value.utcTime, timestamp->val, 8) == 0) {
checkForUpdateTrigger(self, dataAttribute);
}
else {
MmsValue_setUtcTimeByBuffer(dataAttribute->mmsValue, timestamp->val);
checkForChangedTriggers(self, dataAttribute);
}
}
void
IedServer_updateQuality(IedServer self, DataAttribute* dataAttribute, Quality quality)
{

View file

@ -44,7 +44,7 @@
#define STATE_UNSELECTED 0
#define STATE_READY 1
#define STATE_WAIT_FOR_ACTICATION_TIME 2
#define STATE_WAIT_FOR_ACTIVATION_TIME 2
#define STATE_PERFORM_TEST 3
#define STATE_WAIT_FOR_EXECUTION 4
#define STATE_OPERATE 5
@ -197,15 +197,15 @@ initialize(ControlObject* self)
printf("No control model found for variable %s\n", ctlModelName);
}
free(ctlModelName);
GLOBAL_FREEMEM(ctlModelName);
char* sboClassName = createString(4, self->lnName, "$CF$", self->name, "$sboClass");
self->sboClass = MmsServer_getValueFromCache(mmsServer, self->mmsDomain, sboClassName);
free(sboClassName);
GLOBAL_FREEMEM(sboClassName);
self->ctlObjectName = (char*) malloc(130);
self->ctlObjectName = (char*) GLOBAL_MALLOC(130);
createStringInBuffer(self->ctlObjectName, 5, MmsDomain_getName(self->mmsDomain), "/",
self->lnName, "$CO$", self->name);
@ -239,8 +239,8 @@ initialize(ControlObject* self)
if (DEBUG_IED_SERVER)
printf("timeout for %s is %i\n", sboTimeoutName, self->selectTimeout);
free(controlObjectReference);
free(sboTimeoutName);
GLOBAL_FREEMEM(controlObjectReference);
GLOBAL_FREEMEM(sboTimeoutName);
}
else {
self->sbo = MmsValue_newVisibleString(NULL);
@ -345,13 +345,13 @@ executeStateMachine:
switch (state) {
case STATE_WAIT_FOR_ACTICATION_TIME:
case STATE_WAIT_FOR_ACTIVATION_TIME:
case STATE_WAIT_FOR_EXECUTION:
{
ControlHandlerResult dynamicCheckResult = CONTROL_RESULT_OK;
bool isTimeActivatedControl = false;
if (state == STATE_WAIT_FOR_ACTICATION_TIME)
if (state == STATE_WAIT_FOR_ACTIVATION_TIME)
isTimeActivatedControl = true;
if (self->waitForExecutionHandler != NULL) {
@ -475,7 +475,7 @@ ControlObject_destroy(ControlObject* self)
MmsValue_delete(self->emptyString);
if (self->ctlObjectName != NULL)
free(self->ctlObjectName);
GLOBAL_FREEMEM(self->ctlObjectName);
if (self->error != NULL)
MmsValue_delete(self->error);
@ -493,14 +493,14 @@ ControlObject_destroy(ControlObject* self)
MmsValue_delete(self->origin);
if (self->name != NULL)
free(self->name);
GLOBAL_FREEMEM(self->name);
#if (CONFIG_MMS_THREADLESS_STACK != 1)
if (self->stateLock != NULL)
Semaphore_destroy(self->stateLock);
#endif
free(self);
GLOBAL_FREEMEM(self);
}
void
@ -667,7 +667,7 @@ Control_processControlActions(MmsMapping* self, uint64_t currentTimeInMs)
while (element != NULL) {
ControlObject* controlObject = (ControlObject*) element->data;
if (controlObject->state == STATE_WAIT_FOR_ACTICATION_TIME) {
if (controlObject->state == STATE_WAIT_FOR_ACTIVATION_TIME) {
if (controlObject->operateTime <= currentTimeInMs) {
@ -1214,10 +1214,10 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
if (DEBUG_IED_SERVER)
printf("IED_SERVER: writeAccessControlObject: %s\n", variableIdOrig);
char variableId[129];
char variableId[65];
strncpy(variableId, variableIdOrig, 128);
variableId[128] = 0;
strncpy(variableId, variableIdOrig, 64);
variableId[64] = 0;
char* separator = strchr(variableId, '$');
@ -1395,7 +1395,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
int state = getState(controlObject);
if (state == STATE_WAIT_FOR_ACTICATION_TIME) {
if (state == STATE_WAIT_FOR_ACTIVATION_TIME) {
indication = DATA_ACCESS_ERROR_TEMPORARILY_UNAVAILABLE;
ControlObject_sendLastApplError(controlObject, connection, "Oper",
@ -1452,7 +1452,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
initiateControlTask(controlObject);
setState(controlObject, STATE_WAIT_FOR_ACTICATION_TIME);
setState(controlObject, STATE_WAIT_FOR_ACTIVATION_TIME);
if (DEBUG_IED_SERVER)
printf("Oper: activate time activated control\n");

View file

@ -933,6 +933,7 @@ createBufferedReportControlBlock(ReportControlBlock* reportControlBlock,
namedVariable = (MmsVariableSpecification*) GLOBAL_CALLOC(1, sizeof(MmsVariableSpecification));
namedVariable->name = copyString("TimeOfEntry");
namedVariable->type = MMS_BINARY_TIME;
namedVariable->typeSpec.binaryTime = 6;
rcb->typeSpec.structure.elements[12] = namedVariable;
mmsValue->value.structure.components[12] = MmsValue_newBinaryTime(false);

View file

@ -132,7 +132,7 @@ MmsValue_setElement(MmsValue* complexValue, int index, MmsValue* elementValue);
*************************************************************************************/
MmsDataAccessError
MmsValue_getDataAccessError(MmsValue* self);
MmsValue_getDataAccessError(const MmsValue* self);
/**
* \brief Get the int64_t value of a MmsValue object.
@ -142,7 +142,7 @@ MmsValue_getDataAccessError(MmsValue* self);
* \return signed 64 bit integer
*/
int64_t
MmsValue_toInt64(MmsValue* self);
MmsValue_toInt64(const MmsValue* self);
/**
* \brief Get the int32_t value of a MmsValue object.
@ -152,7 +152,7 @@ MmsValue_toInt64(MmsValue* self);
* \return signed 32 bit integer
*/
int32_t
MmsValue_toInt32(MmsValue* value);
MmsValue_toInt32(const MmsValue* value);
/**
* \brief Get the uint32_t value of a MmsValue object.
@ -162,7 +162,7 @@ MmsValue_toInt32(MmsValue* value);
* \return unsigned 32 bit integer
*/
uint32_t
MmsValue_toUint32(MmsValue* value);
MmsValue_toUint32(const MmsValue* value);
/**
* \brief Get the double value of a MmsValue object.
@ -172,7 +172,7 @@ MmsValue_toUint32(MmsValue* value);
* \return 64 bit floating point value
*/
double
MmsValue_toDouble(MmsValue* self);
MmsValue_toDouble(const MmsValue* self);
/**
* \brief Get the float value of a MmsValue object.
@ -182,7 +182,7 @@ MmsValue_toDouble(MmsValue* self);
* \return 32 bit floating point value
*/
float
MmsValue_toFloat(MmsValue* self);
MmsValue_toFloat(const MmsValue* self);
/**
* \brief Get the unix timestamp of a MmsValue object of type MMS_UTCTIME.
@ -192,7 +192,7 @@ MmsValue_toFloat(MmsValue* self);
* \return unix timestamp of the MMS_UTCTIME variable.
*/
uint32_t
MmsValue_toUnixTimestamp(MmsValue* self);
MmsValue_toUnixTimestamp(const MmsValue* self);
/**
* \brief Set the float value of a MmsValue object.
@ -290,13 +290,13 @@ MmsValue_setBoolean(MmsValue* value, bool boolValue);
* \return the MmsValue value as bool value
*/
bool
MmsValue_getBoolean(MmsValue* value);
MmsValue_getBoolean(const MmsValue* value);
char*
MmsValue_toString(MmsValue* self);
void
MmsValue_setVisibleString(MmsValue* self, char* string);
MmsValue_setVisibleString(MmsValue* self, const char* string);
/**
@ -319,7 +319,7 @@ MmsValue_setBitStringBit(MmsValue* self, int bitPos, bool value);
* \return the value of the bit (true = 1 / false = 0)
*/
bool
MmsValue_getBitStringBit(MmsValue* self, int bitPos);
MmsValue_getBitStringBit(const MmsValue* self, int bitPos);
/**
* \brief Delete all bits (set to zero) of an MmsType object of type MMS_BITSTRING
@ -336,7 +336,7 @@ MmsValue_deleteAllBitStringBits(MmsValue* self);
* \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING.
*/
int
MmsValue_getBitStringSize(MmsValue* self);
MmsValue_getBitStringSize(const MmsValue* self);
/**
* \brief Get the number of bytes required by this bitString
@ -344,7 +344,7 @@ MmsValue_getBitStringSize(MmsValue* self);
* \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING.
*/
int
MmsValue_getBitStringByteSize(MmsValue* self);
MmsValue_getBitStringByteSize(const MmsValue* self);
/**
* \brief Count the number of set bits in a bit string.
@ -352,7 +352,7 @@ MmsValue_getBitStringByteSize(MmsValue* self);
* \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING.
*/
int
MmsValue_getNumberOfSetBits(MmsValue* self);
MmsValue_getNumberOfSetBits(const MmsValue* self);
/**
* Set all bits (set to one) of an MmsType object of type MMS_BITSTRING
@ -371,7 +371,7 @@ MmsValue_setAllBitStringBits(MmsValue* self);
* \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING.
*/
uint32_t
MmsValue_getBitStringAsInteger(MmsValue* self);
MmsValue_getBitStringAsInteger(const MmsValue* self);
/**
* \brief Convert an unsigned integer to a bit string
@ -394,7 +394,7 @@ MmsValue_setBitStringFromInteger(MmsValue* self, uint32_t intValue);
* \param self MmsValue instance to operate on. Has to be of a type MMS_BITSTRING.
*/
uint32_t
MmsValue_getBitStringAsIntegerBigEndian(MmsValue* self);
MmsValue_getBitStringAsIntegerBigEndian(const MmsValue* self);
/**
* \brief Convert an unsigned integer to a bit string (big endian bit order)
@ -435,7 +435,19 @@ MmsValue_setUtcTimeMs(MmsValue* self, uint64_t timeval);
* \param buffer buffer containing the encoded UTCTime.
*/
void
MmsValue_setUtcTimeByBuffer(MmsValue* self, uint8_t* buffer);
MmsValue_setUtcTimeByBuffer(MmsValue* self, const uint8_t* buffer);
/**
* \brief return the raw buffer containing the UTC time data
*
* Note: This will return the address of the raw byte buffer. The array length is 8 byte.
*
* \param self MmsValue instance to operate on. Has to be of a type MMS_UTCTIME.
*
* \return the buffer containing the raw data
*/
uint8_t*
MmsValue_getUtcTimeBuffer(MmsValue* self);
/**
* \brief Get a millisecond time value from an MmsValue object of MMS_UTCTIME type.
@ -445,7 +457,7 @@ MmsValue_setUtcTimeByBuffer(MmsValue* self, uint8_t* buffer);
* \return the value in milliseconds since epoch (1970/01/01 00:00 UTC)
*/
uint64_t
MmsValue_getUtcTimeInMs(MmsValue* value);
MmsValue_getUtcTimeInMs(const MmsValue* value);
/**
* \brief set the TimeQuality byte of the UtcTime
@ -479,7 +491,7 @@ MmsValue_setUtcTimeQuality(MmsValue* self, uint8_t timeQuality);
* \return the byte representing the time quality
*/
uint8_t
MmsValue_getUtcTimeQuality(MmsValue* self);
MmsValue_getUtcTimeQuality(const MmsValue* self);
/**
* \brief Update an MmsValue object of type MMS_BINARYTIME with a millisecond time.
@ -498,7 +510,7 @@ MmsValue_setBinaryTime(MmsValue* self, uint64_t timestamp);
* \return the value in milliseconds since epoch (1970/01/01 00:00 UTC)
*/
uint64_t
MmsValue_getBinaryTimeAsUtcMs(MmsValue* self);
MmsValue_getBinaryTimeAsUtcMs(const MmsValue* self);
/**
* \brief Set the value of an MmsValue object of type MMS_OCTET_STRING.
@ -522,7 +534,7 @@ MmsValue_setOctetString(MmsValue* self, uint8_t* buf, int size);
* \return size in bytes
*/
uint16_t
MmsValue_getOctetStringSize(MmsValue* self);
MmsValue_getOctetStringSize(const MmsValue* self);
/**
* \brief Returns the maximum size in bytes of an MmsValue object of type MMS_OCTET_STRING.
@ -559,7 +571,7 @@ MmsValue_getOctetStringBuffer(MmsValue* self);
* \return indicates if the update has been successful (false if not)
*/
bool
MmsValue_update(MmsValue* self, MmsValue* source);
MmsValue_update(MmsValue* self, const MmsValue* source);
/**
* \brief Check if two instances of MmsValue have the same value.
@ -573,7 +585,7 @@ MmsValue_update(MmsValue* self, MmsValue* source);
* \return true if both instances are of the same type and have the same value
*/
bool
MmsValue_equals(MmsValue* self, MmsValue* otherValue);
MmsValue_equals(const MmsValue* self, const MmsValue* otherValue);
/**
* \brief Check if two (complex) instances of MmsValue have the same type.
@ -588,7 +600,7 @@ MmsValue_equals(MmsValue* self, MmsValue* otherValue);
* \return true if both instances and all their children are of the same type.
*/
bool
MmsValue_equalTypes(MmsValue* self, MmsValue* otherValue);
MmsValue_equalTypes(const MmsValue* self, const MmsValue* otherValue);
/*************************************************************************************
* Constructors and destructors
@ -745,7 +757,7 @@ MmsValue_deleteIfNotNull(MmsValue* value);
* \return new MmsValue instance of type MMS_VISIBLE_STRING
*/
MmsValue*
MmsValue_newVisibleString(char* string);
MmsValue_newVisibleString(const char* string);
/**
* \brief Create a new MmsValue instance of type MMS_VISIBLE_STRING.
@ -822,7 +834,7 @@ MmsValue*
MmsValue_newMmsString(char* string);
void
MmsValue_setMmsString(MmsValue* value, char* string);
MmsValue_setMmsString(MmsValue* value, const char* string);
/**
* \brief Create a new MmsValue instance of type MMS_UTCTIME.

View file

@ -299,7 +299,7 @@ mmsClient_createReadNamedVariableListRequest(uint32_t invokeId, const char* doma
ReadRequest_t* readRequest = createReadRequest(mmsPdu);
if (specWithResult) {
readRequest->specificationWithResult = (BOOLEAN_t*) calloc(1, sizeof(BOOLEAN_t));
readRequest->specificationWithResult = (BOOLEAN_t*) GLOBAL_CALLOC(1, sizeof(BOOLEAN_t));
(*(readRequest->specificationWithResult)) = true;
}
else
@ -339,7 +339,7 @@ mmsClient_createReadAssociationSpecificNamedVariableListRequest(
ReadRequest_t* readRequest = createReadRequest(mmsPdu);
if (specWithResult) {
readRequest->specificationWithResult = (BOOLEAN_t*) calloc(1, sizeof(BOOLEAN_t));
readRequest->specificationWithResult = (BOOLEAN_t*) GLOBAL_CALLOC(1, sizeof(BOOLEAN_t));
(*(readRequest->specificationWithResult)) = true;
}
else

View file

@ -176,8 +176,6 @@ createNewDomainVariableSpecification(const char* domainId, const char* itemId)
{
VariableSpecification_t* varSpec = (VariableSpecification_t*) GLOBAL_CALLOC(1, sizeof(ListOfVariableSeq_t));
//VariableSpecification_t* varSpec = (VariableSpecification_t*) calloc(1, sizeof(VariableSpecification_t));
varSpec->present = VariableSpecification_PR_name;
varSpec->choice.name.present = ObjectName_PR_domainspecific;
varSpec->choice.name.choice.domainspecific.domainId.buf = (uint8_t*) domainId;
@ -191,10 +189,8 @@ createNewDomainVariableSpecification(const char* domainId, const char* itemId)
static void
deleteDataElement(Data_t* dataElement)
{
if (dataElement == NULL ) {
printf("deleteDataElement NULL argument\n");
if (dataElement == NULL)
return;
}
if (dataElement->present == Data_PR_structure) {
int elementCount = dataElement->choice.structure->list.count;

View file

@ -38,20 +38,20 @@
#include <time.h> /* for ctime_r */
static inline int
bitStringByteSize(MmsValue* value)
bitStringByteSize(const MmsValue* value)
{
int bitSize = value->value.bitString.size;
return (bitSize / 8) + ((bitSize % 8) > 0);
}
int
MmsValue_getBitStringByteSize(MmsValue* self)
MmsValue_getBitStringByteSize(const MmsValue* self)
{
return bitStringByteSize(self);
}
static void
updateStructuredComponent(MmsValue* self, MmsValue* update)
updateStructuredComponent(MmsValue* self, const MmsValue* update)
{
int componentCount;
MmsValue** selfValues;
@ -96,7 +96,7 @@ MmsValue_newUnsignedFromBerInteger(Asn1PrimitiveValue* berInteger)
}
bool
MmsValue_equals(MmsValue* self, MmsValue* otherValue)
MmsValue_equals(const MmsValue* self, const MmsValue* otherValue)
{
if (self->type == otherValue->type) {
switch (self->type) {
@ -189,7 +189,7 @@ MmsValue_equals(MmsValue* self, MmsValue* otherValue)
}
bool
MmsValue_equalTypes(MmsValue* self, MmsValue* otherValue)
MmsValue_equalTypes(const MmsValue* self, const MmsValue* otherValue)
{
if (self->type == otherValue->type) {
switch (self->type) {
@ -220,7 +220,7 @@ MmsValue_equalTypes(MmsValue* self, MmsValue* otherValue)
}
bool
MmsValue_update(MmsValue* self, MmsValue* update)
MmsValue_update(MmsValue* self, const MmsValue* update)
{
if (self->type == update->type) {
switch (self->type) {
@ -314,7 +314,7 @@ MmsValue_newBitString(int bitSize)
}
static int
getBitStringByteSize(MmsValue* self)
getBitStringByteSize(const MmsValue* self)
{
int byteSize;
@ -361,13 +361,13 @@ MmsValue_setAllBitStringBits(MmsValue* self)
}
int
MmsValue_getBitStringSize(MmsValue* self)
MmsValue_getBitStringSize(const MmsValue* self)
{
return self->value.bitString.size;
}
int
MmsValue_getNumberOfSetBits(MmsValue* self)
MmsValue_getNumberOfSetBits(const MmsValue* self)
{
int setBitsCount = 0;
@ -404,7 +404,7 @@ MmsValue_setBitStringBit(MmsValue* self, int bitPos, bool value)
}
bool
MmsValue_getBitStringBit(MmsValue* self, int bitPos)
MmsValue_getBitStringBit(const MmsValue* self, int bitPos)
{
if (bitPos < self->value.bitString.size) {
int bytePos = bitPos / 8;
@ -423,7 +423,7 @@ MmsValue_getBitStringBit(MmsValue* self, int bitPos)
}
uint32_t
MmsValue_getBitStringAsInteger(MmsValue* self)
MmsValue_getBitStringAsInteger(const MmsValue* self)
{
uint32_t value = 0;
@ -454,7 +454,7 @@ MmsValue_setBitStringFromInteger(MmsValue* self, uint32_t intValue)
}
uint32_t
MmsValue_getBitStringAsIntegerBigEndian(MmsValue* self)
MmsValue_getBitStringAsIntegerBigEndian(const MmsValue* self)
{
uint32_t value = 0;
@ -654,7 +654,7 @@ MmsValue_setBoolean(MmsValue* self, bool boolValue)
}
bool
MmsValue_getBoolean(MmsValue* self)
MmsValue_getBoolean(const MmsValue* self)
{
return self->value.boolean;
}
@ -711,13 +711,13 @@ MmsValue_setUtcTimeQuality(MmsValue* self, uint8_t timeQuality)
}
uint8_t
MmsValue_getUtcTimeQuality(MmsValue* self)
MmsValue_getUtcTimeQuality(const MmsValue* self)
{
return self->value.utcTime[7];
}
void
MmsValue_setUtcTimeByBuffer(MmsValue* self, uint8_t* buffer)
MmsValue_setUtcTimeByBuffer(MmsValue* self, const uint8_t* buffer)
{
uint8_t* valueArray = self->value.utcTime;
@ -727,11 +727,17 @@ MmsValue_setUtcTimeByBuffer(MmsValue* self, uint8_t* buffer)
}
}
uint8_t*
MmsValue_getUtcTimeBuffer(MmsValue* self)
{
return self->value.utcTime;
}
uint64_t
MmsValue_getUtcTimeInMs(MmsValue* self)
MmsValue_getUtcTimeInMs(const MmsValue* self)
{
uint32_t timeval32;
uint8_t* valueArray = self->value.utcTime;
const uint8_t* valueArray = self->value.utcTime;
#if (ORDER_LITTLE_ENDIAN == 1)
memcpyReverseByteOrder((uint8_t*) &timeval32, valueArray, 4);
@ -800,7 +806,7 @@ MmsValue_newIntegerFromInt64(int64_t integer)
* Convert signed integer to int32_t
*/
int32_t
MmsValue_toInt32(MmsValue* self)
MmsValue_toInt32(const MmsValue* self)
{
int32_t integerValue = 0;
@ -811,7 +817,7 @@ MmsValue_toInt32(MmsValue* self)
}
uint32_t
MmsValue_toUint32(MmsValue* self)
MmsValue_toUint32(const MmsValue* self)
{
uint32_t integerValue = 0;
@ -825,7 +831,7 @@ MmsValue_toUint32(MmsValue* self)
* Convert signed integer to int64_t and do sign extension if required
*/
int64_t
MmsValue_toInt64(MmsValue* self)
MmsValue_toInt64(const MmsValue* self)
{
int64_t integerValue = 0;
@ -836,7 +842,7 @@ MmsValue_toInt64(MmsValue* self)
}
float
MmsValue_toFloat(MmsValue* self)
MmsValue_toFloat(const MmsValue* self)
{
if (self->type == MMS_FLOAT) {
if (self->value.floatingPoint.formatWidth == 32) {
@ -858,7 +864,7 @@ MmsValue_toFloat(MmsValue* self)
}
double
MmsValue_toDouble(MmsValue* self)
MmsValue_toDouble(const MmsValue* self)
{
if (self->type == MMS_FLOAT) {
double val;
@ -878,7 +884,7 @@ MmsValue_toDouble(MmsValue* self)
uint32_t
MmsValue_toUnixTimestamp(MmsValue* self)
MmsValue_toUnixTimestamp(const MmsValue* self)
{
uint32_t timestamp;
uint8_t* timeArray = (uint8_t*) &timestamp;
@ -1289,7 +1295,7 @@ MmsValue_setOctetString(MmsValue* self, uint8_t* buf, int size)
}
uint16_t
MmsValue_getOctetStringSize(MmsValue* self)
MmsValue_getOctetStringSize(const MmsValue* self)
{
return self->value.octetString.size;
}
@ -1435,7 +1441,7 @@ exit_function:
}
static inline void
setVisibleStringValue(MmsValue* self, char* string)
setVisibleStringValue(MmsValue* self, const char* string)
{
if (self->value.visibleString.buf != NULL) {
if (string != NULL) {
@ -1464,7 +1470,7 @@ exit_function:
}
static MmsValue*
MmsValue_newString(char* string, MmsType type)
MmsValue_newString(const char* string, MmsType type)
{
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
@ -1497,7 +1503,7 @@ exit_function:
}
MmsValue*
MmsValue_newVisibleString(char* string)
MmsValue_newVisibleString(const char* string)
{
return MmsValue_newString(string, MMS_VISIBLE_STRING);
}
@ -1602,11 +1608,11 @@ MmsValue_setBinaryTime(MmsValue* self, uint64_t timestamp)
}
uint64_t
MmsValue_getBinaryTimeAsUtcMs(MmsValue* self)
MmsValue_getBinaryTimeAsUtcMs(const MmsValue* self)
{
uint64_t timestamp = 0;
uint8_t* binaryTimeBuf = self->value.binaryTime.buf;
const uint8_t* binaryTimeBuf = self->value.binaryTime.buf;
if (self->value.binaryTime.size == 6) {
@ -1636,13 +1642,13 @@ MmsValue_getBinaryTimeAsUtcMs(MmsValue* self)
}
MmsDataAccessError
MmsValue_getDataAccessError(MmsValue* self)
MmsValue_getDataAccessError(const MmsValue* self)
{
return self->value.dataAccessError;
}
void
MmsValue_setMmsString(MmsValue* self, char* string)
MmsValue_setMmsString(MmsValue* self, const char* string)
{
if (self->type == MMS_STRING) {
assert(self->value.visibleString.buf != NULL);
@ -1652,7 +1658,7 @@ MmsValue_setMmsString(MmsValue* self, char* string)
}
static MmsValue*
MmsValue_newStringFromByteArray(uint8_t* byteArray, int size, MmsType type)
MmsValue_newStringFromByteArray(const uint8_t* byteArray, int size, MmsType type)
{
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
@ -1687,7 +1693,7 @@ MmsValue_newMmsStringFromByteArray(uint8_t* byteArray, int size)
}
void
MmsValue_setVisibleString(MmsValue* self, char* string)
MmsValue_setVisibleString(MmsValue* self, const char* string)
{
if (self->type == MMS_VISIBLE_STRING) {
assert(self->value.visibleString.buf != NULL);

View file

@ -51,7 +51,7 @@ MmsDevice_destroy(MmsDevice* self)
MmsVariableSpecification_destroy(self->namedVariables[i]);
}
free (self->namedVariables);
GLOBAL_FREEMEM(self->namedVariables);
}
#endif /* (CONFIG_MMS_SUPPORT_VMD_SCOPE_NAMED_VARIABLES == 1) */

View file

@ -315,14 +315,15 @@ exit_reject_invalid_pdu:
static void
createFileReadResponse(uint32_t invokeId, ByteBuffer* response, MmsFileReadStateMachine* frsm)
createFileReadResponse(MmsServerConnection* connection, uint32_t invokeId,
ByteBuffer* response, MmsFileReadStateMachine* frsm)
{
/* determine remaining bytes in file */
uint32_t bytesLeft = frsm->fileSize - frsm->readPosition;
uint32_t fileChunkSize = 0;
uint32_t maxFileChunkSize = CONFIG_MMS_MAXIMUM_PDU_SIZE - 15;
uint32_t maxFileChunkSize = connection->maxPduSize - 20;
uint32_t fileReadResponseSize = 1; /* for tag */
@ -384,7 +385,7 @@ mmsServer_handleFileReadRequest(
MmsFileReadStateMachine* frsm = getFrsm(connection, frsmId);
if (frsm != NULL)
createFileReadResponse(invokeId, response, frsm);
createFileReadResponse(connection, invokeId, response, frsm);
else
mmsServer_createConfirmedErrorPdu(invokeId, response, MMS_ERROR_FILE_OTHER);
}
@ -452,6 +453,11 @@ createFileDirectoryResponse(uint32_t invokeId, ByteBuffer* response, char* direc
DirectoryHandle directory = FileSystem_openDirectory(directoryName);
if (continueAfterFileName != NULL) {
if (strlen(continueAfterFileName) == 0)
continueAfterFileName = NULL;
}
if (directory != NULL) {
bool isDirectory;
char* fileName = FileSystem_readDirectory(directory, &isDirectory);

View file

@ -526,7 +526,7 @@ IsoServer_waitReady(IsoServer self, unsigned int timeoutMs)
} else {
IsoConnection_destroy(isoConnection);
lastConnection->next = openConnection->next;
free(openConnection);
GLOBAL_FREEMEM(openConnection);
openConnection = lastConnection->next;
}

View file

@ -482,4 +482,6 @@ EXPORTS
IedServer_getBitStringAttributeValue
IedServer_getStringAttributeValue
ModelNode_getChildWithFc
IedServer_updateTimestampAttributeValue
MmsValue_getUtcTimeBuffer

View file

@ -506,4 +506,5 @@ EXPORTS
IedServer_getBitStringAttributeValue
IedServer_getStringAttributeValue
ModelNode_getChildWithFc
IedServer_updateTimestampAttributeValue
MmsValue_getUtcTimeBuffer

Binary file not shown.

View file

@ -827,7 +827,7 @@ public class StaticModelGenerator {
sgcbString += sgcb.getActSG() + ", " + sgcb.getNumOfSGs() + ", 0, false, 0, 0, ";
if (currentSGCBVariableNumber < (sgcbVariableNames.size() - 1))
sgcbString += "&" + sgcbVariableNames.get(currentGseVariableNumber + 1);
sgcbString += "&" + sgcbVariableNames.get(currentSGCBVariableNumber + 1);
else
sgcbString += "NULL";