IEC60870.CS104.MasterConnection (ExIEC60870 v0.1.0)

Copy Markdown View Source

Represents a connected Master (Client) peer on a CS104.Slave server (MasterConnection in cs104_slave.c).

Provides peer response helpers that can be safely called both inside Slave callbacks (interrogation_handler, asdu_handler, etc.) and from external processes:

Summary

Functions

Closes the master connection.

Returns the IEC60870.AppLayerParameters of this master connection.

Returns {ip_string, port} of the connected peer.

Checks whether this connection is currently in the active (STARTDT) state.

Checks whether this connection is ready to transmit an ASDU (IMasterConnection_isReady).

Sends an ACTIVATION_CON (or DEACTIVATION_CON if the request was DEACTIVATION) response mirroring the request ASDU with negative flag set as specified. Matches IMasterConnection_sendACT_CON in cs104_slave.c.

Sends an ACTIVATION_TERMINATION (:activation_termination) response mirroring the request ASDU. Matches IMasterConnection_sendACT_TERM in cs104_slave.c.

Sends an ASDU over this specific master connection (or queues it in the high-priority queue). Safe to call from inside Slave callbacks or external processes.

Types

t()

@type t() :: pid()

Functions

close(conn_pid)

@spec close(t()) :: :ok

Closes the master connection.

get_app_layer_parameters(conn_pid)

@spec get_app_layer_parameters(t()) :: IEC60870.AppLayerParameters.t()

Returns the IEC60870.AppLayerParameters of this master connection.

get_peer_address(conn_pid)

@spec get_peer_address(t()) ::
  {:ok, {String.t(), non_neg_integer()}} | {:error, term()}

Returns {ip_string, port} of the connected peer.

is_active?(conn_pid)

@spec is_active?(t()) :: boolean()

Checks whether this connection is currently in the active (STARTDT) state.

is_ready?(conn_pid)

@spec is_ready?(t()) :: boolean()

Checks whether this connection is ready to transmit an ASDU (IMasterConnection_isReady).

send_act_con(conn_pid, asdu, negative \\ false)

@spec send_act_con(t(), IEC60870.ASDU.t(), boolean()) :: :ok | {:error, term()}

Sends an ACTIVATION_CON (or DEACTIVATION_CON if the request was DEACTIVATION) response mirroring the request ASDU with negative flag set as specified. Matches IMasterConnection_sendACT_CON in cs104_slave.c.

send_act_term(conn_pid, asdu)

@spec send_act_term(t(), IEC60870.ASDU.t()) :: :ok | {:error, term()}

Sends an ACTIVATION_TERMINATION (:activation_termination) response mirroring the request ASDU. Matches IMasterConnection_sendACT_TERM in cs104_slave.c.

send_asdu(conn_pid, asdu)

@spec send_asdu(t(), IEC60870.ASDU.t()) :: :ok

Sends an ASDU over this specific master connection (or queues it in the high-priority queue). Safe to call from inside Slave callbacks or external processes.