Sample programs 18.09.2026 12:55 18.09.2026 12:55

The prgSetTecoRouteTLS program automatically checks the connection settings between the Tecomat PLC and the TecoRoute service. If the PLC is not using port 8443, the program configures it for secure communication via TLS.

The check is performed after every PLC restart. Once a connection to the TecoRoute service has been successfully established, the program terminates.

Requirement: Communication with the TecoRoute server must be enabled in the PLC configuration.

Using the program

  1. Add the TecoRouteLib library to the project.
  2. Add the prgSetTecoRouteTLS program.
  3. Include an instance of the program in the project’s executable task.
  4. Compile the project and upload it to the PLC.
  5. Restart the PLC. The program will automatically check and, if necessary, adjust the TecoRoute settings.

Source code

PROGRAM prgSetTecoRouteTLS
VAR
    setRoutePort : BOOL := TRUE;  // Request to set up a secure connection
    init         : BOOL;
    routerPar    : TTecoRoutePar;
    routerStat   : TTecoRouteStat;
END_VAR

IF setRoutePort THEN

    // Loads the current connection parameters for TecoRoute
    fcGetTecoRoutePar(
        rq        := TRUE,
        actParSet := routerPar
    );

    IF NOT init THEN
        IF routerPar.destPort <> 8443 THEN
            // Port for a secure connection
            routerPar.destPort := 8443;

            init := fcSetTecoRoutePar(
                rq        := TRUE,
                newParSet := routerPar
            );
        ELSE
            init := TRUE;
        END_IF;
    END_IF;

    // Checks the current connection status with the TecoRoute service
    fcGetTecoRouteStat(
        rq     := TRUE,
        status := routerStat
    );

    IF init THEN
        IF FIND(
            IN1 := routerStat.serviceStat,
            IN2 := 'connected'
        ) > 0 THEN
            setRoutePort := FALSE;
        END_IF;
    END_IF;

END_IF;

END_PROGRAM

How It Works

When the PLC program starts, it:

  1. reads the current TecoRoute service parameters;
  2. checks the value of routerPar.destPort;
  3. sets port 8443 if necessary;
  4. monitors the communication status;
  5. stops further checks once it finds the text connected in the status information.

The value of setRoutePort is initialized when the program starts, so the check is repeated after every PLC restart.