Protocol and data transmission errors

Here you can unpack the complete PLC sources: TcPlcLibIEC870_5_101Slave_TutorialSample.zip

The station error messages are placed into a FIFO. Up to 10 error messages can be stored. At fatal communication errors (e.g. error of the linking layer, the check sum of the frame doesn't fit) the connection is cut and has to be build on new. Errors within the application layer (e.g. the ADSU send buffer is overflowed by to many frames) are only logged and doesn't cut the connection.

For this errors it is also possible to cut the connection out of the application. In addition to the error code also the error source is notified in the error message. This simplifies the localization of an error.

Example

The occurring error messages of an IEC 60870-5-101 sub station can be read out via the request:

PROGRAM MAIN
VAR
...

    server : FB_IEC870_5_101Slave;
...

END_VAR
...

REPEAT
    server.system.device.errors.RemoveError();
    IF server.system.device.errors.bOk  THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG,
            'IEC60870-5-101 slave error: 0x%s',
            DWORD_TO_HEXSTR( server.system.device.errors.getError.nErrId, 8, FALSE) );
    END_IF
UNTIL NOT server.system.device.errors.bOk
END_REPEAT

...