lib60870-C  2.3.2
C source code library for the IEC 60870-5-101/104 protocols
cs101_master.h
Go to the documentation of this file.
1 /*
2  * cs101_master.h
3  *
4  * Copyright 2017-2022 Michael Zillgith
5  *
6  * This file is part of lib60870-C
7  *
8  * lib60870-C is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * lib60870-C is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with lib60870-C. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * See COPYING file for the complete license text.
22  */
23 
30 #ifndef SRC_INC_API_CS101_MASTER_H_
31 #define SRC_INC_API_CS101_MASTER_H_
32 
33 #include "iec60870_master.h"
34 #include "link_layer_parameters.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
55 typedef struct sCS101_Master* CS101_Master;
56 
68 CS101_Master_create(SerialPort port, const LinkLayerParameters llParameters, const CS101_AppLayerParameters alParameters, IEC60870_LinkLayerMode mode);
69 
82 CS101_Master_createEx(SerialPort serialPort, const LinkLayerParameters llParameters, const CS101_AppLayerParameters alParameters, IEC60870_LinkLayerMode linkLayerMode,
83  int queueSize);
84 
91 void
93 
103 void
105 
111 void
113 
123 void
125 
126 
137 void
139 
143 void
145 
154 void
156 
162 void
164 
174 void
176 
177 
178 
186 
194 
205 bool
207 
214 void
216 
224 void
225 CS101_Master_sendInterrogationCommand(CS101_Master self, CS101_CauseOfTransmission cot, int ca, QualifierOfInterrogation qoi);
226 
234 void
235 CS101_Master_sendCounterInterrogationCommand(CS101_Master self, CS101_CauseOfTransmission cot, int ca, uint8_t qcc);
236 
246 void
248 
255 void
257 
265 void
267 
276 void
277 CS101_Master_sendProcessCommand(CS101_Master self, CS101_CauseOfTransmission cot, int ca, InformationObject command);
278 
279 
292 void
294 
301 void
303 
307 void
309 
316 void
318 
327 void
329 
338 #ifdef __cplusplus
339 }
340 #endif
341 
342 #endif /* SRC_INC_API_CS101_MASTER_H_ */
struct sCS101_ASDU * CS101_ASDU
Application Service Data Unit (ASDU) for the CS101/CS104 application layer.
Definition: iec60870_common.h:216
void(* IEC60870_RawMessageHandler)(void *parameter, uint8_t *msg, int msgSize, bool sent)
Callback handler for sent and received messages.
Definition: iec60870_common.h:105
void(* IEC60870_LinkLayerStateChangedHandler)(void *parameter, int address, LinkLayerState newState)
Callback handler for link layer state changes.
Definition: iec60870_common.h:91
IEC60870_LinkLayerMode
link layer mode for serial link layers
Definition: iec60870_common.h:64
uint8_t QualifierOfInterrogation
Qualifier of interrogation (QUI) according to IEC 60870-5-101:2003 7.2.6.22.
Definition: cs101_information_objects.h:146
void CS101_Master_sendTestCommand(CS101_Master self, int ca)
Send a test command (C_TS_NA_1 typeID: 104)
void CS101_Master_sendLinkLayerTestFunction(CS101_Master self)
Manually send link layer test function.
void CS101_Master_setDIR(CS101_Master self, bool dir)
Set the value of the DIR bit when sending messages (only balanced mode)
void CS101_Master_sendASDU(CS101_Master self, CS101_ASDU asdu)
Send a user specified ASDU.
void CS101_Master_setRawMessageHandler(CS101_Master self, IEC60870_RawMessageHandler handler, void *parameter)
Set the raw message callback (called when a message is sent or received)
void CS101_Master_useSlaveAddress(CS101_Master self, int address)
Set the slave address for the following send functions.
void CS101_Master_destroy(CS101_Master self)
Destroy the master instance and release all resources.
void CS101_Master_stop(CS101_Master self)
Stops the background thread that handles the link layer connections.
void CS101_Master_sendProcessCommand(CS101_Master self, CS101_CauseOfTransmission cot, int ca, InformationObject command)
Send a process command to the controlled (or other) station.
struct sCS101_Master * CS101_Master
CS101_Master type.
Definition: cs101_master.h:55
void CS101_Master_start(CS101_Master self)
Start a background thread that handles the link layer connections.
void CS101_Master_pollSingleSlave(CS101_Master self, int address)
Poll a slave (only unbalanced mode)
void CS101_Master_sendReadCommand(CS101_Master self, int ca, int ioa)
Sends a read command (C_RD_NA_1 typeID: 102)
LinkLayerParameters CS101_Master_getLinkLayerParameters(CS101_Master self)
Returns the link layer parameters object of this master instance.
bool CS101_Master_isChannelReady(CS101_Master self, int address)
Is the channel ready to transmit an ASDU (only unbalanced mode)
void CS101_Master_sendCounterInterrogationCommand(CS101_Master self, CS101_CauseOfTransmission cot, int ca, uint8_t qcc)
send a counter interrogation command
void CS101_Master_setLinkLayerStateChanged(CS101_Master self, IEC60870_LinkLayerStateChangedHandler handler, void *parameter)
Set a callback handler for link layer state changes.
void CS101_Master_run(CS101_Master self)
Receive a new message and run the protocol state machine(s).
void CS101_Master_setIdleTimeout(CS101_Master self, int timeoutInMs)
Set the idle timeout (only for balanced mode)
CS101_Master CS101_Master_create(SerialPort port, const LinkLayerParameters llParameters, const CS101_AppLayerParameters alParameters, IEC60870_LinkLayerMode mode)
Create a new master instance.
void CS101_Master_addSlave(CS101_Master self, int address)
Add a new slave connection.
void CS101_Master_sendInterrogationCommand(CS101_Master self, CS101_CauseOfTransmission cot, int ca, QualifierOfInterrogation qoi)
send an interrogation command
void CS101_Master_setOwnAddress(CS101_Master self, int address)
Set the own link layer address (only balanced mode)
CS101_Master CS101_Master_createEx(SerialPort serialPort, const LinkLayerParameters llParameters, const CS101_AppLayerParameters alParameters, IEC60870_LinkLayerMode linkLayerMode, int queueSize)
Create a new master instance and specify message queue size (for balanced mode)
CS101_AppLayerParameters CS101_Master_getAppLayerParameters(CS101_Master self)
Returns the application layer parameters object of this master instance.
void CS101_Master_setASDUReceivedHandler(CS101_Master self, CS101_ASDUReceivedHandler handler, void *parameter)
Register a callback handler for received ASDUs.
void CS101_Master_sendClockSyncCommand(CS101_Master self, int ca, CP56Time2a time)
Sends a clock synchronization command (C_CS_NA_1 typeID: 103)
Common master side definitions for IEC 60870-5-101/104 These types are used by CS101/CS104 master.
bool(* CS101_ASDUReceivedHandler)(void *parameter, int address, CS101_ASDU asdu)
Callback handler for received ASDUs.
Definition: iec60870_master.h:53
Definition: iec60870_common.h:255
Definition: iec60870_common.h:112
Definition: link_layer_parameters.h:42