A free GPL’d IEC 60870-5-104 Protocol Tester

IEC 60870-5-104 is an internationally standardized protocol for data acquisition and control of power substations. This protocol is supported by most vendors, available in RTU’s, substation data concentrators and HMI’s.

I was in need of an implementation of the 104 protocol to use in 3 projects:

  • A historical data recorder that get all data from the SAGE system used in a control center (50.000 points).
  • A standalone IEC 104 protocol tester.
  • A protocol converter from IEC 104 to a custom format used to push data onto a HMI of my creation.

A quick Google search can show two free software implementations:

If you know of another one, please leave a comment below.

My intention was to have a GUI that can show point values and also issue commands. I considered both not well suited to my needs and decided to implement the protocol in C++ with a QT GUI. QT is a modern multi-platform GUI toolkit (http://qt-project.org). The code was compiled and tested with Linux and Windows operating systems.

Project link: https://sourceforge.net/projects/qtester104/

The base protocol class (iec140_class.cpp) was created in pure C++ without any platform or non-standard library dependencies, can be used to develop software with other compiler/library/sdk.

The iec104_class.h presents some pure virtual function that need to be user defined on a derived class.

// make a tcp connection, user provided
virtual void connectTCP() = 0;
// tcp disconnect, user provided
virtual void disconnectTCP() = 0;
// read tcp data, user provided
virtual int readTCP( char * buf, int szmax ) = 0;
// send tcp data, user provided
virtual void sendTCP( char * data, int sz ) = 0;

There are some other non-mandatory virtual functions that the user can re-implement:

// user point processing, user provided. (on each call there are only objects of the same type)
virtual void dataIndication( iec_obj * /*obj*/, int /*numpoints*/ ){};
// inform user that ACTCONFIRM of Interrogation was received from slave
virtual void interrogationActConfIndication(){};
// inform user that ACTTERM of Interrogation was received from slave
virtual void interrogationActTermIndication(){};
// inform user of command activation
virtual void commandActConfIndication( iec_obj * /*obj*/ ){};
// inform user of command termination
virtual void commandActTermIndication( iec_obj * /*obj*/ ){};
// user process APDU
virtual void userprocAPDU(iec_apdu * /* papdu */, int /* sz */){};

The qiec104.cpp and qiec104.h files inherits the iec104_class and re-implements those functions using the QT TCP/IP libraries. The mainwindow.cpp uses the qiec104.cpp data and provides a GUI.

The GUI consists of some input fields and buttons to configure the remote system (secondary, also called slave), plus bellow other fields and buttons to issue commands, a text box with protocol log messages and a grid with point addresses, values and types.

The same binary executable serve as a protocol tester and a protocol converter to the HMI.

The base class iec104_class.cpp was also used to create the historic data recorder module. This software process 50.000 points of real time data, feeding MySQL tables with SOE and current values and a daily binary file with minute to minute snapshots of the power system state.

You can use it as a standalone IEC60870-5-104 protocol tester, it works as a master and can scan and send commands to slave devices, or as part of my other project OSHMI-Open Substation HMI.


Ricardo Olsen in-2c-14px, MEng. :: https://dscsys.com

Copyright © 2013 Ricardo L. Olsen. All rights reserved.


Links, books, resources

I’ll be maintaining here a list of resources on HMI design, supervisory control, protocols, etc. Suggestions are welcome.

Books on HMI design:

  • The High Performance HMI Handbook – Bill Hollifield –  ISBN-10: 0977896919

The best book on how to design an HMI. Albeit focused on the process control industry, the concepts can be applied to power systems HMI’s. Available at Amazon (book) and Barnes & Noble (book and ebook).

  • Machine, Meet Human: Designing a Useful Interface – Nathaniel O’Shaughnessey – ISBN-10: 1456468480
  • Effective Operator Display Design: Asm Consortium Guideline – ASM Consortium – ISBN-10: 1440431647

Books on protocols, SCADA:

  • Practical Modern SCADA Protocols: DNP3, 60870.5 and Related Systems – Gordon Clarke, Deon Reynders – ISBN-10: 0750657995
  • SCADA para Subestación de Transmisión de Energía Eléctrica: Control Supervisor y Adquisición de Datos (SCADA) para Subestación de Transmisión de Energía Eléctrica (Spanish Edition) – Carlos Orlando Omaña Pérez, Heissen Ermir Mojica Velasco – ISBN-10: 3846576131
  • The Alarm Management Handbook – Bill Hollifield, Eddie Habibi – ISBN-10: 0977896927

Links about protocol documentation:

Useful links on HMI design:

Generic computer usability sites:

Open source protocol implementations:

Vendor sites:


Ricardo Olsen in-2c-14px, MEng. :: https://dscsys.com

Copyright © 2013 Ricardo L. Olsen. All rights reserved.

About this blog

Hi, my name is R. Olsen, I work for a power transmission utility in the south of Brazil. My job includes configuring and developing supervisory control systems for substations and control centers.

I’ll be writing here about supervisory control systems, SCADA, HMI, and related subjects.

I hope to share some useful knowledge, insights and projects about these subjects.

English is not my native language, I’m sorry about any error in my writing and I expect to be criticised, feel free to correct me.

Thank You.

Ricardo Olsen in-2c-14px, MEng. :: https://dscsys.com