--- a/iec60870/iec60870_runtime.c Fri Apr 10 15:25:38 2026 +0200
+++ b/iec60870/iec60870_runtime.c Mon Apr 13 15:25:10 2026 +0200
@@ -5,23 +5,63 @@
+#include "cs104_slave.h" +CS101_AppLayerParameters alParams; +int __init_%(locstr)s(int argc, char **argv) { + fprintf(stderr, "iec60870 extension: __init_iec60870\n"); + // TODO: multi-server/client support? + /* create a new slave/server instance with default connection parameters and + * default message queue size */ + slave = CS104_Slave_create(10, 10); + CS104_Slave_setLocalAddress(slave, "0.0.0.0"); -int __init_iec60870(int argc, char **argv) {
- fprintf(stderr, "iec60870 extension: __init_iec60870\n");
+ /* Set mode to a single redundancy group + * NOTE: library has to be compiled with CONFIG_CS104_SUPPORT_SERVER_MODE_SINGLE_REDUNDANCY_GROUP enabled (=1) + CS104_Slave_setServerMode(slave, CS104_MODE_SINGLE_REDUNDANCY_GROUP); + /* get the connection parameters - we need them to create correct ASDUs - + * you can also modify the parameters here when default parameters are not to be used */ + alParams = CS104_Slave_getAppLayerParameters(slave); + /* when you have to tweak the APCI parameters (t0-t3, k, w) you can access them here */ + CS104_APCIParameters apciParams = CS104_Slave_getConnectionParameters(slave); + // printf("APCI parameters:\n"); + // printf(" t0: %%i\n", apciParams->t0); + // printf(" t1: %%i\n", apciParams->t1); + // printf(" t2: %%i\n", apciParams->t2); + // printf(" t3: %%i\n", apciParams->t3); + // printf(" k: %%i\n", apciParams->k); + // printf(" w: %%i\n", apciParams->w); // TODO: initialize resources, threads, state
-void __publish_iec60870(void) {
+void __publish_%(locstr)s(void) { // TODO: sync data from PLC to extension outputs (if needed)
+ fprintf(stderr, "iec60870 extension: __publish_iec60870\n"); -void __retrieve_iec60870(void) {
+void __retrieve_%(locstr)s(void) { // TODO: sync data from extension inputs to PLC (if needed)
-int __cleanup_iec60870(void) {
+int __cleanup_%(locstr)s(void) { fprintf(stderr, "iec60870 extension: __cleanup_iec60870\n");
// TODO: release resources, stop threads