libiec61850  1.5.3
Typedefs | Enumerations | Functions
IEC 61850 GOOSE subscriber API

Typedefs

typedef struct sGooseSubscriber * GooseSubscriber
 
typedef void(* GooseListener) (GooseSubscriber subscriber, void *parameter)
 user provided callback function that will be invoked when a GOOSE message is received. More...
 
typedef struct sGooseReceiver * GooseReceiver
 

Enumerations

enum  GooseParseError {
  GOOSE_PARSE_ERROR_NO_ERROR = 0 , GOOSE_PARSE_ERROR_UNKNOWN_TAG , GOOSE_PARSE_ERROR_TAGDECODE , GOOSE_PARSE_ERROR_SUBLEVEL ,
  GOOSE_PARSE_ERROR_OVERFLOW , GOOSE_PARSE_ERROR_UNDERFLOW , GOOSE_PARSE_ERROR_TYPE_MISMATCH , GOOSE_PARSE_ERROR_LENGTH_MISMATCH ,
  GOOSE_PARSE_ERROR_INVALID_PADDING
}
 

Functions

LIB61850_API GooseSubscriber GooseSubscriber_create (char *goCbRef, MmsValue *dataSetValues)
 create a new GOOSE subscriber instance. More...
 
LIB61850_API char * GooseSubscriber_getGoId (GooseSubscriber self)
 Get the GoId value of the received GOOSE message. More...
 
LIB61850_API char * GooseSubscriber_getGoCbRef (GooseSubscriber self)
 Get the GOOSE Control Block reference value of the received GOOSE message. More...
 
LIB61850_API char * GooseSubscriber_getDataSet (GooseSubscriber self)
 Get the DatSet value of the received GOOSE message. More...
 
LIB61850_API void GooseSubscriber_setDstMac (GooseSubscriber self, uint8_t dstMac[6])
 set the destination mac address used by the subscriber to filter relevant messages. More...
 
LIB61850_API void GooseSubscriber_setAppId (GooseSubscriber self, uint16_t appId)
 set the APPID used by the subscriber to filter relevant messages. More...
 
LIB61850_API bool GooseSubscriber_isValid (GooseSubscriber self)
 Check if subscriber state is valid. More...
 
LIB61850_API GooseParseError GooseSubscriber_getParseError (GooseSubscriber self)
 Get parse error in case of invalid subscriber state. More...
 
LIB61850_API void GooseSubscriber_destroy (GooseSubscriber self)
 Destroy the GooseSubscriber instance. More...
 
LIB61850_API void GooseSubscriber_setListener (GooseSubscriber self, GooseListener listener, void *parameter)
 set a callback function that will be invoked when a GOOSE message has been received. More...
 
LIB61850_API int32_t GooseSubscriber_getAppId (GooseSubscriber self)
 Get the APPID value of the received GOOSE message. More...
 
LIB61850_API void GooseSubscriber_getSrcMac (GooseSubscriber self, uint8_t *buffer)
 Get the source MAC address of the received GOOSE message. More...
 
LIB61850_API void GooseSubscriber_getDstMac (GooseSubscriber self, uint8_t *buffer)
 Get the destination MAC address of the received GOOSE message. More...
 
LIB61850_API uint32_t GooseSubscriber_getStNum (GooseSubscriber self)
 return the state number (stNum) of the last received GOOSE message. More...
 
LIB61850_API uint32_t GooseSubscriber_getSqNum (GooseSubscriber self)
 return the sequence number (sqNum) of the last received GOOSE message. More...
 
LIB61850_API bool GooseSubscriber_isTest (GooseSubscriber self)
 returns the test flag of the last received GOOSE message More...
 
LIB61850_API uint32_t GooseSubscriber_getConfRev (GooseSubscriber self)
 returns the confRev value of the last received GOOSE message More...
 
LIB61850_API bool GooseSubscriber_needsCommission (GooseSubscriber self)
 returns the value of the ndsCom (needs commission) flag of the last received GOOSE message. More...
 
LIB61850_API uint32_t GooseSubscriber_getTimeAllowedToLive (GooseSubscriber self)
 Get the TimeAllowedToLive value of the last received message. More...
 
LIB61850_API uint64_t GooseSubscriber_getTimestamp (GooseSubscriber self)
 Get the timestamp of the last received message. More...
 
LIB61850_API MmsValueGooseSubscriber_getDataSetValues (GooseSubscriber self)
 get the data set values received with the last report More...
 
LIB61850_API bool GooseSubscriber_isVlanSet (GooseSubscriber self)
 
LIB61850_API uint16_t GooseSubscriber_getVlanId (GooseSubscriber self)
 
LIB61850_API uint8_t GooseSubscriber_getVlanPrio (GooseSubscriber self)
 
LIB61850_API void GooseSubscriber_setObserver (GooseSubscriber self)
 Configure the Subscriber to listen to any received GOOSE message. More...
 
LIB61850_API GooseReceiver GooseReceiver_create (void)
 Create a new receiver instance. More...
 
LIB61850_API GooseReceiver GooseReceiver_createEx (uint8_t *buffer)
 Create a new receiver instance using the provided buffer instead of allocating an own buffer. More...
 
LIB61850_API void GooseReceiver_setInterfaceId (GooseReceiver self, const char *interfaceId)
 sets the interface for the GOOSE receiver More...
 
LIB61850_API const char * GooseReceiver_getInterfaceId (GooseReceiver self)
 return the interface ID used by the GOOSE receiver More...
 
LIB61850_API void GooseReceiver_addSubscriber (GooseReceiver self, GooseSubscriber subscriber)
 Add a subscriber to this receiver instance. More...
 
LIB61850_API void GooseReceiver_removeSubscriber (GooseReceiver self, GooseSubscriber subscriber)
 Remove a subscriber from this receiver instance. More...
 
LIB61850_API void GooseReceiver_start (GooseReceiver self)
 start the GOOSE receiver in a separate thread More...
 
LIB61850_API void GooseReceiver_stop (GooseReceiver self)
 stop the GOOSE receiver running in a separate thread More...
 
LIB61850_API bool GooseReceiver_isRunning (GooseReceiver self)
 Check if GOOSE receiver is running. More...
 
LIB61850_API void GooseReceiver_destroy (GooseReceiver self)
 Free all resource of the GooseReceiver and all installed GooseSubscribers. More...
 
LIB61850_API EthernetSocket GooseReceiver_startThreadless (GooseReceiver self)
 
LIB61850_API void GooseReceiver_stopThreadless (GooseReceiver self)
 
LIB61850_API bool GooseReceiver_tick (GooseReceiver self)
 Parse GOOSE messages if they are available. More...
 
LIB61850_API void GooseReceiver_handleMessage (GooseReceiver self, uint8_t *buffer, int size)
 Parse a GOOSE message. More...
 

Detailed Description

Typedef Documentation

◆ GooseListener

typedef void(* GooseListener) (GooseSubscriber subscriber, void *parameter)

user provided callback function that will be invoked when a GOOSE message is received.

Parameters
subscriberthe subscriber object that invoked the callback function,
parametera user provided parameter that will be passed to the callback function

◆ GooseReceiver

typedef struct sGooseReceiver* GooseReceiver

◆ GooseSubscriber

typedef struct sGooseSubscriber* GooseSubscriber

Enumeration Type Documentation

◆ GooseParseError

Enumerator
GOOSE_PARSE_ERROR_NO_ERROR 
GOOSE_PARSE_ERROR_UNKNOWN_TAG 
GOOSE_PARSE_ERROR_TAGDECODE 
GOOSE_PARSE_ERROR_SUBLEVEL 
GOOSE_PARSE_ERROR_OVERFLOW 
GOOSE_PARSE_ERROR_UNDERFLOW 
GOOSE_PARSE_ERROR_TYPE_MISMATCH 
GOOSE_PARSE_ERROR_LENGTH_MISMATCH 
GOOSE_PARSE_ERROR_INVALID_PADDING 

Function Documentation

◆ GooseReceiver_addSubscriber()

LIB61850_API void GooseReceiver_addSubscriber ( GooseReceiver  self,
GooseSubscriber  subscriber 
)

Add a subscriber to this receiver instance.

NOTE: Do not call this function while the receiver is running (after GooseReceiver_start has been called)!

Parameters
selfthe GooseReceiver instance
subscriberthe GooseSubscriber instance to add

◆ GooseReceiver_create()

LIB61850_API GooseReceiver GooseReceiver_create ( void  )

Create a new receiver instance.

A GooseReceiver instance is used to handle all GOOSE messages received on a specific network interface.

Returns
the new GooseReceiver instance

◆ GooseReceiver_createEx()

LIB61850_API GooseReceiver GooseReceiver_createEx ( uint8_t *  buffer)

Create a new receiver instance using the provided buffer instead of allocating an own buffer.

A GooseReceiver instance is used to handle all GOOSE messages received on a specific network interface.

Parameters
bufferbuffer to store Ethernet messages or NULL when using GooseReceiver_handleMessage
Returns
the new GooseReceiver instance

◆ GooseReceiver_destroy()

LIB61850_API void GooseReceiver_destroy ( GooseReceiver  self)

Free all resource of the GooseReceiver and all installed GooseSubscribers.

Parameters
selfthe GooseReceiver instance

◆ GooseReceiver_getInterfaceId()

LIB61850_API const char* GooseReceiver_getInterfaceId ( GooseReceiver  self)

return the interface ID used by the GOOSE receiver

Parameters
selfthe GosseReceiver instance
Returns
the Ethernet interface ID string

◆ GooseReceiver_handleMessage()

LIB61850_API void GooseReceiver_handleMessage ( GooseReceiver  self,
uint8_t *  buffer,
int  size 
)

Parse a GOOSE message.

Call after reception of an Ethernet frame (can be used as an alternative to GooseReceiver_tick to avoid implementing the Ethernet HAL)

Parameters
selfthe receiver object
buffera buffer containing the complete Ethernet message
sizesize of the Ethernet message

◆ GooseReceiver_isRunning()

LIB61850_API bool GooseReceiver_isRunning ( GooseReceiver  self)

Check if GOOSE receiver is running.

Can be used to check if GooseReceiver_start has been successful.

Parameters
selfthe GooseReceiver instance
Returns
true if GOOSE receiver is running, false otherwise

◆ GooseReceiver_removeSubscriber()

LIB61850_API void GooseReceiver_removeSubscriber ( GooseReceiver  self,
GooseSubscriber  subscriber 
)

Remove a subscriber from this receiver instance.

NOTE: Do not call this function while the receiver is running (after GooseReceiver_start has been called)!

Parameters
selfthe GooseReceiver instance
subscriberthe GooseSubscriber instance to remove

◆ GooseReceiver_setInterfaceId()

LIB61850_API void GooseReceiver_setInterfaceId ( GooseReceiver  self,
const char *  interfaceId 
)

sets the interface for the GOOSE receiver

Parameters
selfthe GooseReceiver instance
interfaceId

◆ GooseReceiver_start()

LIB61850_API void GooseReceiver_start ( GooseReceiver  self)

start the GOOSE receiver in a separate thread

Parameters
selfthe GooseReceiver instance

◆ GooseReceiver_startThreadless()

LIB61850_API EthernetSocket GooseReceiver_startThreadless ( GooseReceiver  self)

◆ GooseReceiver_stop()

LIB61850_API void GooseReceiver_stop ( GooseReceiver  self)

stop the GOOSE receiver running in a separate thread

This function is used to stop the receiver thread started with GooseReceiver_start

Parameters
selfthe GooseReceiver instance

◆ GooseReceiver_stopThreadless()

LIB61850_API void GooseReceiver_stopThreadless ( GooseReceiver  self)

◆ GooseReceiver_tick()

LIB61850_API bool GooseReceiver_tick ( GooseReceiver  self)

Parse GOOSE messages if they are available.

Call after reception of an Ethernet frame or periodically

Parameters
selfthe receiver object
Returns
true if a message was available and has been parsed, false otherwise

◆ GooseSubscriber_create()

LIB61850_API GooseSubscriber GooseSubscriber_create ( char *  goCbRef,
MmsValue dataSetValues 
)

create a new GOOSE subscriber instance.

A new GOOSE subscriber will be created and connected to a specific GOOSE control block reference.

The parameter goCbRef has to be given in MMS like notation (as it also will appear in the GOOSE message sent by the publisher). An example could be "simpleIOGenericIO/LLN0$GO$gcbEvents".

The data set values contained in a GOOSE message will be written to the optionally provided MmsValue instance. The MmsValue object has to be of type MMS_ARRAY. The array elements need to be of the same type as the data set elements. It is intended that the provided MmsValue instance has been created by the IedConnection_getDataSet() method before.

If NULL is given as dataSetValues it will be created the first time when a appropriate GOOSE message is received.

Parameters
goCbRefa string containing the object reference of the GOOSE Control Block (GoCB) in MMS notation the GOOSE publisher uses.
dataSetValuesthe MmsValue object where the data set values will be written or NULL.

◆ GooseSubscriber_destroy()

LIB61850_API void GooseSubscriber_destroy ( GooseSubscriber  self)

Destroy the GooseSubscriber instance.

Do not call this function when the GooseSubscriber instance was added to a GooseReceiver. The GooseReceiver will call the destructor when GooseReceiver_destroy is called!

Parameters
selfGooseSubscriber instance to operate on.

◆ GooseSubscriber_getAppId()

LIB61850_API int32_t GooseSubscriber_getAppId ( GooseSubscriber  self)

Get the APPID value of the received GOOSE message.

Parameters
selfGooseSubscriber instance to operate on.

◆ GooseSubscriber_getConfRev()

LIB61850_API uint32_t GooseSubscriber_getConfRev ( GooseSubscriber  self)

returns the confRev value of the last received GOOSE message

Parameters
selfGooseSubscriber instance to operate on.
Returns
the confRev value of the last received GOOSE message. If the message does not contain such a value the result is always 0

◆ GooseSubscriber_getDataSet()

LIB61850_API char* GooseSubscriber_getDataSet ( GooseSubscriber  self)

Get the DatSet value of the received GOOSE message.

Parameters
selfGooseSubscriber instance to operate on.

◆ GooseSubscriber_getDataSetValues()

LIB61850_API MmsValue* GooseSubscriber_getDataSetValues ( GooseSubscriber  self)

get the data set values received with the last report

Note: To prevent data corruption. The MmsValue instance received should only be used inside of the callback function, when the GOOSE receiver is running in a separate thread.

Parameters
selfGooseSubscriber instance to operate on.
Returns
MmsValue instance of the report data set

◆ GooseSubscriber_getDstMac()

LIB61850_API void GooseSubscriber_getDstMac ( GooseSubscriber  self,
uint8_t *  buffer 
)

Get the destination MAC address of the received GOOSE message.

Parameters
selfGooseSubscriber instance to operate on.
bufferbuffer to store the MAC address (at least 6 byte)

◆ GooseSubscriber_getGoCbRef()

LIB61850_API char* GooseSubscriber_getGoCbRef ( GooseSubscriber  self)

Get the GOOSE Control Block reference value of the received GOOSE message.

Parameters
selfGooseSubscriber instance to operate on.

◆ GooseSubscriber_getGoId()

LIB61850_API char* GooseSubscriber_getGoId ( GooseSubscriber  self)

Get the GoId value of the received GOOSE message.

Parameters
selfGooseSubscriber instance to operate on.

◆ GooseSubscriber_getParseError()

LIB61850_API GooseParseError GooseSubscriber_getParseError ( GooseSubscriber  self)

Get parse error in case of invalid subscriber state.

Parameters
selfGooseSubscriber instance to operate on.
Returns
the error code representing a message parse problem of the last received message

◆ GooseSubscriber_getSqNum()

LIB61850_API uint32_t GooseSubscriber_getSqNum ( GooseSubscriber  self)

return the sequence number (sqNum) of the last received GOOSE message.

The sequence number is increased for every consecutive GOOSE message without state change. When a state change occurs (stNum is increased) then the sequence number (sqNum) will be reset.

Parameters
selfGooseSubscriber instance to operate on.
Returns
the sequence number of the last received GOOSE message

◆ GooseSubscriber_getSrcMac()

LIB61850_API void GooseSubscriber_getSrcMac ( GooseSubscriber  self,
uint8_t *  buffer 
)

Get the source MAC address of the received GOOSE message.

Parameters
selfGooseSubscriber instance to operate on.
bufferbuffer to store the MAC address (at least 6 byte)

◆ GooseSubscriber_getStNum()

LIB61850_API uint32_t GooseSubscriber_getStNum ( GooseSubscriber  self)

return the state number (stNum) of the last received GOOSE message.

The state number is increased if any of the values in the GOOSE data set changed due to a valid trigger condition

Parameters
selfGooseSubscriber instance to operate on.
Returns
the state number of the last received GOOSE message

◆ GooseSubscriber_getTimeAllowedToLive()

LIB61850_API uint32_t GooseSubscriber_getTimeAllowedToLive ( GooseSubscriber  self)

Get the TimeAllowedToLive value of the last received message.

Parameters
selfGooseSubscriber instance to operate on.
Returns
the TimeAllowedToLive value of the last received GOOSE message in milliseconds.

◆ GooseSubscriber_getTimestamp()

LIB61850_API uint64_t GooseSubscriber_getTimestamp ( GooseSubscriber  self)

Get the timestamp of the last received message.

Parameters
selfGooseSubscriber instance to operate on.
Returns
the timestamp value of the last received GOOSE message in milliseconds since epoch (1.1.1970 UTC).

◆ GooseSubscriber_getVlanId()

LIB61850_API uint16_t GooseSubscriber_getVlanId ( GooseSubscriber  self)

◆ GooseSubscriber_getVlanPrio()

LIB61850_API uint8_t GooseSubscriber_getVlanPrio ( GooseSubscriber  self)

◆ GooseSubscriber_isTest()

LIB61850_API bool GooseSubscriber_isTest ( GooseSubscriber  self)

returns the test flag of the last received GOOSE message

IMPORTANT: Goose messages with test=TRUE have to be ignored to be standard compliant!

Parameters
selfGooseSubscriber instance to operate on.
Returns
the state of the test flag of the last received GOOSE message.

◆ GooseSubscriber_isValid()

LIB61850_API bool GooseSubscriber_isValid ( GooseSubscriber  self)

Check if subscriber state is valid.

A GOOSE subscriber is valid if TimeAllowedToLive timeout is not elapsed and GOOSE message were received with correct state and sequence ID.

◆ GooseSubscriber_isVlanSet()

LIB61850_API bool GooseSubscriber_isVlanSet ( GooseSubscriber  self)

◆ GooseSubscriber_needsCommission()

LIB61850_API bool GooseSubscriber_needsCommission ( GooseSubscriber  self)

returns the value of the ndsCom (needs commission) flag of the last received GOOSE message.

IMPORTANT: Goose messages with ndsCom=TRUE have to be ignored to be standard compliant!

Parameters
selfGooseSubscriber instance to operate on.
Returns
the state of the ndsCom flag of the last received GOOSE message.

◆ GooseSubscriber_setAppId()

LIB61850_API void GooseSubscriber_setAppId ( GooseSubscriber  self,
uint16_t  appId 
)

set the APPID used by the subscriber to filter relevant messages.

If APPID is set the subscriber will ignore all messages with other APPID values.

Parameters
selfGooseSubscriber instance to operate on.
appIdthe APPID value the subscriber should use to filter messages

◆ GooseSubscriber_setDstMac()

LIB61850_API void GooseSubscriber_setDstMac ( GooseSubscriber  self,
uint8_t  dstMac[6] 
)

set the destination mac address used by the subscriber to filter relevant messages.

If dstMac is set the subscriber will ignore all messages with other dstMac values.

Parameters
selfGooseSubscriber instance to operate on.
dstMacthe destination mac address

◆ GooseSubscriber_setListener()

LIB61850_API void GooseSubscriber_setListener ( GooseSubscriber  self,
GooseListener  listener,
void *  parameter 
)

set a callback function that will be invoked when a GOOSE message has been received.

Parameters
selfGooseSubscriber instance to operate on.
listeneruser provided callback function
parametera user provided parameter that will be passed to the callback function

◆ GooseSubscriber_setObserver()

LIB61850_API void GooseSubscriber_setObserver ( GooseSubscriber  self)

Configure the Subscriber to listen to any received GOOSE message.

NOTE: When the observer flag is set the subscriber also has access to the goCbRef, goId, and datSet values of the received GOOSE message