lib60870-C
2.3.2
C source code library for the IEC 60870-5-101/104 protocols
|
Typedefs | |
typedef struct sCS101_Slave * | CS101_Slave |
CS101_Slave type. | |
Functions | |
CS101_Slave | CS101_Slave_create (SerialPort serialPort, const LinkLayerParameters llParameters, const CS101_AppLayerParameters alParameters, IEC60870_LinkLayerMode linkLayerMode) |
Create a new balanced or unbalanced CS101 slave. More... | |
CS101_Slave | CS101_Slave_createEx (SerialPort serialPort, const LinkLayerParameters llParameters, const CS101_AppLayerParameters alParameters, IEC60870_LinkLayerMode linkLayerMode, int class1QueueSize, int class2QueueSize) |
Create a new balanced or unbalanced CS101 slave. More... | |
void | CS101_Slave_destroy (CS101_Slave self) |
Destroy the slave instance and cleanup all resources. More... | |
void | CS101_Slave_setDIR (CS101_Slave self, bool dir) |
Set the value of the DIR bit when sending messages (only balanced mode) More... | |
void | CS101_Slave_addPlugin (CS101_Slave self, CS101_SlavePlugin plugin) |
Register a plugin instance with this slave instance. More... | |
void | CS101_Slave_setIdleTimeout (CS101_Slave self, int timeoutInMs) |
Set the idle timeout. More... | |
void | CS101_Slave_setLinkLayerStateChanged (CS101_Slave self, IEC60870_LinkLayerStateChangedHandler handler, void *parameter) |
Set a callback handler for link layer state changes. | |
void | CS101_Slave_setLinkLayerAddress (CS101_Slave self, int address) |
Set the local link layer address. More... | |
void | CS101_Slave_setLinkLayerAddressOtherStation (CS101_Slave self, int address) |
Set the link layer address of the remote station. More... | |
bool | CS101_Slave_isClass1QueueFull (CS101_Slave self) |
Check if the class 1 ASDU is full. More... | |
void | CS101_Slave_enqueueUserDataClass1 (CS101_Slave self, CS101_ASDU asdu) |
Enqueue an ASDU into the class 1 data queue. More... | |
bool | CS101_Slave_isClass2QueueFull (CS101_Slave self) |
Check if the class 2 ASDU is full. More... | |
void | CS101_Slave_enqueueUserDataClass2 (CS101_Slave self, CS101_ASDU asdu) |
Enqueue an ASDU into the class 2 data queue. More... | |
void | CS101_Slave_flushQueues (CS101_Slave self) |
Remove all ASDUs from the class 1/2 data queues. More... | |
void | CS101_Slave_run (CS101_Slave self) |
Receive a new message and run the link layer state machines. More... | |
void | CS101_Slave_start (CS101_Slave self) |
Start a background thread that handles the link layer connections. More... | |
void | CS101_Slave_stop (CS101_Slave self) |
Stops the background thread that handles the link layer connections. More... | |
CS101_AppLayerParameters | CS101_Slave_getAppLayerParameters (CS101_Slave self) |
Returns the application layer parameters object of this slave instance. More... | |
LinkLayerParameters | CS101_Slave_getLinkLayerParameters (CS101_Slave self) |
Returns the link layer parameters object of this slave instance. More... | |
void | CS101_Slave_setResetCUHandler (CS101_Slave self, CS101_ResetCUHandler handler, void *parameter) |
Set the handler for the reset CU (communication unit) message. More... | |
void | CS101_Slave_setInterrogationHandler (CS101_Slave self, CS101_InterrogationHandler handler, void *parameter) |
Set the handler for the general interrogation message. More... | |
void | CS101_Slave_setCounterInterrogationHandler (CS101_Slave self, CS101_CounterInterrogationHandler handler, void *parameter) |
Set the handler for the counter interrogation message. More... | |
void | CS101_Slave_setReadHandler (CS101_Slave self, CS101_ReadHandler handler, void *parameter) |
Set the handler for the read message. More... | |
void | CS101_Slave_setClockSyncHandler (CS101_Slave self, CS101_ClockSynchronizationHandler handler, void *parameter) |
Set the handler for the clock synchronization message. More... | |
void | CS101_Slave_setResetProcessHandler (CS101_Slave self, CS101_ResetProcessHandler handler, void *parameter) |
Set the handler for the reset process message. More... | |
void | CS101_Slave_setDelayAcquisitionHandler (CS101_Slave self, CS101_DelayAcquisitionHandler handler, void *parameter) |
Set the handler for the delay acquisition message. More... | |
void | CS101_Slave_setASDUHandler (CS101_Slave self, CS101_ASDUHandler handler, void *parameter) |
Set the handler for a received ASDU. More... | |
void | CS101_Slave_setRawMessageHandler (CS101_Slave self, IEC60870_RawMessageHandler handler, void *parameter) |
Set the raw message callback (called when a message is sent or received) More... | |
void CS101_Slave_addPlugin | ( | CS101_Slave | self, |
CS101_SlavePlugin | plugin | ||
) |
Register a plugin instance with this slave instance.
the | plugin instance. |
CS101_Slave CS101_Slave_create | ( | SerialPort | serialPort, |
const LinkLayerParameters | llParameters, | ||
const CS101_AppLayerParameters | alParameters, | ||
IEC60870_LinkLayerMode | linkLayerMode | ||
) |
Create a new balanced or unbalanced CS101 slave.
NOTE: The CS101_Slave instance has two separate data queues for class 1 and class 2 data. This constructor uses the default max queue size for both queues.
serialPort | the serial port to be used |
llParameters | the link layer parameters to be used |
alParameters | the CS101 application layer parameters |
linkLayerMode | the link layer mode (either BALANCED or UNBALANCED) |
CS101_Slave CS101_Slave_createEx | ( | SerialPort | serialPort, |
const LinkLayerParameters | llParameters, | ||
const CS101_AppLayerParameters | alParameters, | ||
IEC60870_LinkLayerMode | linkLayerMode, | ||
int | class1QueueSize, | ||
int | class2QueueSize | ||
) |
Create a new balanced or unbalanced CS101 slave.
NOTE: The CS101_Slave instance has two separate data queues for class 1 and class 2 data.
serialPort | the serial port to be used |
llParameters | the link layer parameters to be used |
alParameters | the CS101 application layer parameters |
linkLayerMode | the link layer mode (either BALANCED or UNBALANCED) |
class1QueueSize | size of the class1 data queue |
class2QueueSize | size of the class2 data queue |
void CS101_Slave_destroy | ( | CS101_Slave | self | ) |
Destroy the slave instance and cleanup all resources.
self | CS101_Slave instance |
void CS101_Slave_enqueueUserDataClass1 | ( | CS101_Slave | self, |
CS101_ASDU | asdu | ||
) |
Enqueue an ASDU into the class 1 data queue.
self | CS101_Slave instance |
asdu | the ASDU instance to enqueue |
void CS101_Slave_enqueueUserDataClass2 | ( | CS101_Slave | self, |
CS101_ASDU | asdu | ||
) |
Enqueue an ASDU into the class 2 data queue.
self | CS101_Slave instance |
asdu | the ASDU instance to enqueue |
void CS101_Slave_flushQueues | ( | CS101_Slave | self | ) |
Remove all ASDUs from the class 1/2 data queues.
self | CS101_Slave instance |
CS101_AppLayerParameters CS101_Slave_getAppLayerParameters | ( | CS101_Slave | self | ) |
Returns the application layer parameters object of this slave instance.
self | CS101_Slave instance |
LinkLayerParameters CS101_Slave_getLinkLayerParameters | ( | CS101_Slave | self | ) |
Returns the link layer parameters object of this slave instance.
self | CS101_Slave instance |
bool CS101_Slave_isClass1QueueFull | ( | CS101_Slave | self | ) |
Check if the class 1 ASDU is full.
self | CS101_Slave instance |
bool CS101_Slave_isClass2QueueFull | ( | CS101_Slave | self | ) |
Check if the class 2 ASDU is full.
self | CS101_Slave instance |
void CS101_Slave_run | ( | CS101_Slave | self | ) |
Receive a new message and run the link layer state machines.
NOTE: Has to be called frequently, when the start/stop functions are not used. Otherwise it will be called by the background thread.
self | CS101_Slave instance |
void CS101_Slave_setASDUHandler | ( | CS101_Slave | self, |
CS101_ASDUHandler | handler, | ||
void * | parameter | ||
) |
Set the handler for a received ASDU.
NOTE: This a generic handler that will only be called when the ASDU has not been handled by one of the other callback handlers.
handler | the callback handler function |
parameter | user provided parameter to be passed to the callback handler |
void CS101_Slave_setClockSyncHandler | ( | CS101_Slave | self, |
CS101_ClockSynchronizationHandler | handler, | ||
void * | parameter | ||
) |
Set the handler for the clock synchronization message.
handler | the callback handler function |
parameter | user provided parameter to be passed to the callback handler |
void CS101_Slave_setCounterInterrogationHandler | ( | CS101_Slave | self, |
CS101_CounterInterrogationHandler | handler, | ||
void * | parameter | ||
) |
Set the handler for the counter interrogation message.
handler | the callback handler function |
parameter | user provided parameter to be passed to the callback handler |
void CS101_Slave_setDelayAcquisitionHandler | ( | CS101_Slave | self, |
CS101_DelayAcquisitionHandler | handler, | ||
void * | parameter | ||
) |
Set the handler for the delay acquisition message.
handler | the callback handler function |
parameter | user provided parameter to be passed to the callback handler |
void CS101_Slave_setDIR | ( | CS101_Slave | self, |
bool | dir | ||
) |
Set the value of the DIR bit when sending messages (only balanced mode)
NOTE: Default value is false (controlled station). In the case of two equivalent stations the value is defined by agreement.
dir | the value of the DIR bit when sending messages |
void CS101_Slave_setIdleTimeout | ( | CS101_Slave | self, |
int | timeoutInMs | ||
) |
Set the idle timeout.
Time with no activity after which the connection is considered in idle (LL_STATE_IDLE) state.
timeoutInMs | the timeout value in milliseconds |
void CS101_Slave_setInterrogationHandler | ( | CS101_Slave | self, |
CS101_InterrogationHandler | handler, | ||
void * | parameter | ||
) |
Set the handler for the general interrogation message.
handler | the callback handler function |
parameter | user provided parameter to be passed to the callback handler |
void CS101_Slave_setLinkLayerAddress | ( | CS101_Slave | self, |
int | address | ||
) |
Set the local link layer address.
self | CS101_Slave instance |
address | the link layer address (can be either 1 or 2 byte wide). |
void CS101_Slave_setLinkLayerAddressOtherStation | ( | CS101_Slave | self, |
int | address | ||
) |
Set the link layer address of the remote station.
self | CS101_Slave instance |
address | the link layer address (can be either 1 or 2 byte wide). |
void CS101_Slave_setRawMessageHandler | ( | CS101_Slave | self, |
IEC60870_RawMessageHandler | handler, | ||
void * | parameter | ||
) |
Set the raw message callback (called when a message is sent or received)
handler | user provided callback handler function |
parameter | user provided parameter that is passed to the callback handler |
void CS101_Slave_setReadHandler | ( | CS101_Slave | self, |
CS101_ReadHandler | handler, | ||
void * | parameter | ||
) |
Set the handler for the read message.
handler | the callback handler function |
parameter | user provided parameter to be passed to the callback handler |
void CS101_Slave_setResetCUHandler | ( | CS101_Slave | self, |
CS101_ResetCUHandler | handler, | ||
void * | parameter | ||
) |
Set the handler for the reset CU (communication unit) message.
handler | the callback handler function |
parameter | user provided parameter to be passed to the callback handler |
void CS101_Slave_setResetProcessHandler | ( | CS101_Slave | self, |
CS101_ResetProcessHandler | handler, | ||
void * | parameter | ||
) |
Set the handler for the reset process message.
handler | the callback handler function |
parameter | user provided parameter to be passed to the callback handler |
void CS101_Slave_start | ( | CS101_Slave | self | ) |
Start a background thread that handles the link layer connections.
NOTE: This requires threads. If you don't want to use a separate thread for the slave instance you have to call the CS101_Slave_run function periodically.
self | CS101_Slave instance |
void CS101_Slave_stop | ( | CS101_Slave | self | ) |
Stops the background thread that handles the link layer connections.
self | CS101_Slave instance |