diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index 68af0400..5cbea6dc 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -1356,6 +1356,30 @@ IedConnection_readBitStringAsIntegerBigEndian(IedConnection self, IedClientError return 0; } +uint32_t +IedConnection_readBitStringAsInteger(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_getBitStringAsInteger(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) { diff --git a/src/iec61850/inc/iec61850_client.h b/src/iec61850/inc/iec61850_client.h index c00255ed..18523f7d 100644 --- a/src/iec61850/inc/iec61850_client.h +++ b/src/iec61850/inc/iec61850_client.h @@ -944,6 +944,20 @@ IedConnection_readInt32Value(IedConnection self, IedClientError* error, const ch uint32_t IedConnection_readBitStringAsIntegerBigEndian(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc); + +/** + * \brief read a functional constrained data attribute (FCDA) of type BitString (LittleEndian) 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_readBitStringAsInteger(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 *