diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index 3ca81e11..68af0400 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -1332,6 +1332,30 @@ IedConnection_readUnsigned32Value(IedConnection self, IedClientError* error, con return retVal; } +uint32_t +IedConnection_readBitStringAsIntegerBigEndian(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc) +{ + MmsValue* value = IedConnection_readObject(self, error, objectReference, fc); + + if (value != NULL) { + if(MmsValue_getType(value) == MMS_BIT_STRING) + { + return MmsValue_getBitStringAsIntegerBigEndian(value); + } + else + { + if (MmsValue_getType(value) == MMS_DATA_ACCESS_ERROR) + *error = iedConnection_mapDataAccessErrorToIedError(MmsValue_getDataAccessError(value)); + else + *error = IED_ERROR_UNEXPECTED_VALUE_RECEIVED; + } + + MmsValue_delete(value); + } + + return 0; +} + int64_t IedConnection_readInt64Value(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc) { @@ -3827,4 +3851,3 @@ FileDirectoryEntry_getLastModified(FileDirectoryEntry self) { return self->lastModified; } - diff --git a/src/iec61850/inc/iec61850_client.h b/src/iec61850/inc/iec61850_client.h index ffe8ff1f..c00255ed 100644 --- a/src/iec61850/inc/iec61850_client.h +++ b/src/iec61850/inc/iec61850_client.h @@ -930,6 +930,20 @@ IedConnection_readStringValue(IedConnection self, IedClientError* error, const c LIB61850_API int32_t IedConnection_readInt32Value(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc); + +/** + * \brief read a functional constrained data attribute (FCDA) of type BitString (BigEndian) and return the result as uint32_t + * + * \param self the connection object to operate on + * \param error the error code if an error occurs + * \param object reference of the data attribute to read + * \param fc the functional constraint of the data attribute to read + * + * \return an uint32_t value of the read data attributes + */ +uint32_t +IedConnection_readBitStringAsIntegerBigEndian(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc); + /** * \brief read a functional constrained data attribute (FCDA) of type Integer or Unsigned and return the result as int64_t *