libIEC61850
1.0.1
Open-source IEC 61850 MMS/GOOSE/SV server and client library
|
Typedefs | |
typedef struct sSVClientASDU * | SVClientASDU |
opaque handle to a SV ASDU (Application service data unit) instance. More... | |
typedef struct sSVSubscriber * | SVSubscriber |
opaque handle to a SV subscriber instance More... | |
typedef void(* | SVUpdateListener) (SVSubscriber subscriber, void *parameter, SVClientASDU asdu) |
Callback function for received SV messages. More... | |
typedef struct sSVReceiver * | SVReceiver |
opaque handle to a SV receiver instance More... | |
Functions | |
SVReceiver | SVReceiver_create (void) |
Create a new SV receiver instance. More... | |
void | SVReceiver_disableDestAddrCheck (SVReceiver self) |
Disable check for destination address of the received SV messages. More... | |
void | SVReceiver_setInterfaceId (SVReceiver self, const char *interfaceId) |
Set the Ethernet interface ID for the receiver instance. More... | |
void | SVReceiver_addSubscriber (SVReceiver self, SVSubscriber subscriber) |
Add a subscriber instance to the receiver. More... | |
void | SVReceiver_removeSubscriber (SVReceiver self, SVSubscriber subscriber) |
Disconnect subscriber and receiver. More... | |
void | SVReceiver_start (SVReceiver self) |
Receiver starts listening for SV messages. More... | |
void | SVReceiver_stop (SVReceiver self) |
Receiver stops listening for SV messages. More... | |
void | SVReceiver_destroy (SVReceiver self) |
Destroy receiver instance (cleanup resources) More... | |
void | SVReceiver_startThreadless (SVReceiver self) |
void | SVReceiver_stopThreadless (SVReceiver self) |
bool | SVReceiver_tick (SVReceiver self) |
SVSubscriber | SVSubscriber_create (const uint8_t *ethAddr, uint16_t appID) |
void | SVSubscriber_setListener (SVSubscriber self, SVUpdateListener listener, void *parameter) |
Set a callback handler to process received SV messages. More... | |
void | SVSubscriber_destroy (SVSubscriber self) |
uint16_t | SVClientASDU_getSmpCnt (SVClientASDU self) |
return the SmpCnt value included in the SV ASDU More... | |
const char * | SVClientASDU_getSvId (SVClientASDU self) |
return the SvID value included in the SV ASDU More... | |
uint32_t | SVClientASDU_getConfRev (SVClientASDU self) |
return the ConfRev value included in the SV ASDU More... | |
int8_t | SVClientASDU_getINT8 (SVClientASDU self, int index) |
Get an INT8 data value in the data part of the ASDU. More... | |
int16_t | SVClientASDU_getINT16 (SVClientASDU self, int index) |
Get an INT16 data value in the data part of the ASDU. More... | |
int32_t | SVClientASDU_getINT32 (SVClientASDU self, int index) |
Get an INT32 data value in the data part of the ASDU. More... | |
uint8_t | SVClientASDU_getINT8U (SVClientASDU self, int index) |
Get an INT8U data value in the data part of the ASDU. More... | |
uint16_t | SVClientASDU_getINT16U (SVClientASDU self, int index) |
Get an INT16U data value in the data part of the ASDU. More... | |
uint32_t | SVClientASDU_getINT32U (SVClientASDU self, int index) |
Get an INT32U data value in the data part of the ASDU. More... | |
float | SVClientASDU_getFLOAT32 (SVClientASDU self, int index) |
Get an FLOAT32 data value in the data part of the ASDU. More... | |
double | SVClientASDU_getFLOAT64 (SVClientASDU self, int index) |
Get an FLOAT64 data value in the data part of the ASDU. More... | |
int | SVClientASDU_getDataSize (SVClientASDU self) |
Returns the size of the data part of the ASDU. More... | |
The sampled values (SV) subscriber API consists of three different objects. The SVReceiver object is responsible for handling all SV Ethernet messages for a specific Ethernet interface. If you want to receive SV messages on multiple Ethernet interfaces you have to use several SVReceiver instances. An SVSubscriber object is associated to a SV data stream that is identified by its appID and destination Ethernet address. The SVSubscriber object is used to install a callback handler SVUpdateListener that is invoked for each ASDU (application service data unit) received for the associated stream. An SVClientASDU is an object that represents a single ASDU. Each ASDU contains some meta information that can be obtained by specific access functions like e.g. SVClientASDU_getSmpCnt to access the "SmpCnt" (sample count) attribute of the ASDU. The actual measurement data contained in the ASDU does not consist of structured ASN.1 data but stored as raw binary data. Without a priori knowledge of the dataset associated with the ASDU data stream it is not possible to interpret the received data correctly. Therefore you have to provide the data access functions with an index value to indicate the data type and the start of the data in the data block of the ASDU. E.g. reading a data set consisting of two FLOAT32 values you can use two subsequent calls of SVClientASDU_getFLOAT32 one with index = 0 and the second one with index = 4.
IEC 61850 type | required bytes |
---|---|
BOOLEAN | 1 byte |
INT8 | 1 byte |
INT16 | 2 byte |
INT32 | 4 byte |
INT64 | 8 byte |
INT8U | 1 byte |
INT16U | 2 byte |
INT24U | 3 byte |
INT32U | 4 byte |
FLOAT32 | 4 byte |
FLOAT64 | 8 byte |
ENUMERATED | 4 byte |
CODED ENUM | 4 byte |
OCTET STRING | 20 byte |
VISIBLE STRING | 35 byte |
TimeStamp | 8 byte |
EntryTime | 6 byte |
BITSTRING | 4 byte |
The SV subscriber API can be used independent of the IEC 61850 client API. In order to access the SVCB via MMS you have to use the IEC 61850 client API. Please see ClientSVControlBlock object in section Client side SV control block handling functions.
typedef struct sSVClientASDU* SVClientASDU |
opaque handle to a SV ASDU (Application service data unit) instance.
Sampled Values (SV) ASDUs (application service data units) are the basic units for sampled value data. Each ASDU represents a single sample consisting of multiple measurement values with a single dedicated timestamp.
NOTE: SVClientASDU are statically allocated and are only valid inside of the SVUpdateListener function when called by the library. If you need the data contained in the ASDU elsewhere you have to copy and store the data by yourself!
typedef struct sSVReceiver* SVReceiver |
opaque handle to a SV receiver instance
typedef struct sSVSubscriber* SVSubscriber |
opaque handle to a SV subscriber instance
A subscriber is an instance associated with a single stream of measurement data. It is identified by the Ethernet destination address, the appID value (both are on SV message level) and the svID value that is part of each ASDU (SVClientASDU object).
typedef void(* SVUpdateListener) (SVSubscriber subscriber, void *parameter, SVClientASDU asdu) |
Callback function for received SV messages.
Will be called for each ASDU contained in a SV message!
subscriber | the subscriber that was associated with the received SV message |
parameter | a user provided parameter that is simply passed to the callback |
asdu | SV ASDU data structure. This structure is only valid inside of the callback function |
uint32_t SVClientASDU_getConfRev | ( | SVClientASDU | self | ) |
return the ConfRev value included in the SV ASDU
self | ASDU object instance |
int SVClientASDU_getDataSize | ( | SVClientASDU | self | ) |
Returns the size of the data part of the ASDU.
self | ASDU object instance |
float SVClientASDU_getFLOAT32 | ( | SVClientASDU | self, |
int | index | ||
) |
Get an FLOAT32 data value in the data part of the ASDU.
self | ASDU object instance |
index | the index (byte position of the start) of the data in the data part |
double SVClientASDU_getFLOAT64 | ( | SVClientASDU | self, |
int | index | ||
) |
Get an FLOAT64 data value in the data part of the ASDU.
self | ASDU object instance |
index | the index (byte position of the start) of the data in the data part |
int16_t SVClientASDU_getINT16 | ( | SVClientASDU | self, |
int | index | ||
) |
Get an INT16 data value in the data part of the ASDU.
self | ASDU object instance |
index | the index (byte position of the start) of the data in the data part |
uint16_t SVClientASDU_getINT16U | ( | SVClientASDU | self, |
int | index | ||
) |
Get an INT16U data value in the data part of the ASDU.
self | ASDU object instance |
index | the index (byte position of the start) of the data in the data part |
int32_t SVClientASDU_getINT32 | ( | SVClientASDU | self, |
int | index | ||
) |
Get an INT32 data value in the data part of the ASDU.
self | ASDU object instance |
index | the index (byte position of the start) of the data in the data part |
uint32_t SVClientASDU_getINT32U | ( | SVClientASDU | self, |
int | index | ||
) |
Get an INT32U data value in the data part of the ASDU.
self | ASDU object instance |
index | the index (byte position of the start) of the data in the data part |
int8_t SVClientASDU_getINT8 | ( | SVClientASDU | self, |
int | index | ||
) |
Get an INT8 data value in the data part of the ASDU.
self | ASDU object instance |
index | the index (byte position of the start) of the data in the data part |
uint8_t SVClientASDU_getINT8U | ( | SVClientASDU | self, |
int | index | ||
) |
Get an INT8U data value in the data part of the ASDU.
self | ASDU object instance |
index | the index (byte position of the start) of the data in the data part |
uint16_t SVClientASDU_getSmpCnt | ( | SVClientASDU | self | ) |
return the SmpCnt value included in the SV ASDU
The SmpCnt (sample counter) is increased for each ASDU to identify the sample.
self | ASDU object instance |
const char* SVClientASDU_getSvId | ( | SVClientASDU | self | ) |
return the SvID value included in the SV ASDU
self | ASDU object instance |
void SVReceiver_addSubscriber | ( | SVReceiver | self, |
SVSubscriber | subscriber | ||
) |
Add a subscriber instance to the receiver.
The given subscriber will be connected to the receiver instance.
self | the receiver instance reference |
subscriber | the subscriber instance to connect |
SVReceiver SVReceiver_create | ( | void | ) |
Create a new SV receiver instance.
A receiver is responsible for processing all SV message for a single Ethernet interface. In order to process messages from multiple Ethernet interfaces you have to create multiple instances.
void SVReceiver_destroy | ( | SVReceiver | self | ) |
Destroy receiver instance (cleanup resources)
self | the receiver instance reference |
void SVReceiver_disableDestAddrCheck | ( | SVReceiver | self | ) |
Disable check for destination address of the received SV messages.
Per default both the appID and the destination address are checked to identify relevant SV messages. Destination address check can be disabled for performance reason when the appIDs are unique in the local system.
self | the receiver instance reference |
void SVReceiver_removeSubscriber | ( | SVReceiver | self, |
SVSubscriber | subscriber | ||
) |
Disconnect subscriber and receiver.
self | the receiver instance reference |
subscriber | the subscriber instance to disconnect |
void SVReceiver_setInterfaceId | ( | SVReceiver | self, |
const char * | interfaceId | ||
) |
Set the Ethernet interface ID for the receiver instance.
Use this function if you want to use a different interface than the default interface set by CONFIG_ETHERNET_INTERFACE_ID (stack_config.h) NOTE: This function has to be called before calling SVReceiver_start.
self | the receiver instance reference |
interfaceId | the Ethernet interface id (platform specific e.g. eth0 for linux). |
void SVReceiver_start | ( | SVReceiver | self | ) |
Receiver starts listening for SV messages.
NOTE: This call will start a new background thread.
self | the receiver instance reference |
void SVReceiver_startThreadless | ( | SVReceiver | self | ) |
void SVReceiver_stop | ( | SVReceiver | self | ) |
Receiver stops listening for SV messages.
self | the receiver instance reference |
void SVReceiver_stopThreadless | ( | SVReceiver | self | ) |
bool SVReceiver_tick | ( | SVReceiver | self | ) |
SVSubscriber SVSubscriber_create | ( | const uint8_t * | ethAddr, |
uint16_t | appID | ||
) |
void SVSubscriber_destroy | ( | SVSubscriber | self | ) |
void SVSubscriber_setListener | ( | SVSubscriber | self, |
SVUpdateListener | listener, | ||
void * | parameter | ||
) |
Set a callback handler to process received SV messages.
If the received SV message contains multiple ASDUs (application service data units) the callback function will be called for each ASDU separately. If a callback function has already been installed for this SVSubscriber object the old callback will be replaced.
self | The subscriber object |
listener | the callback function to install |
a | user provided parameter that is provided to the callback function |