IEC 60870-5-104 Client / Master Connection (GenServer), equivalent to cs104_connection.c.
Manages:
- TCP / TLS socket connection (
:gen_tcp/:ssl) STARTDT/STOPDT/TESTFRstate transitions- 15-bit
N(S)andN(R)sequence numbers andk/wsliding window T0,T1,T2,T3timers- Helper command methods (
send_interrogation_command/4,send_clock_sync_command/3, etc.)
Summary
Functions
Returns a specification to start this module under a supervisor.
Sends C_CS_NA_1 (TypeID 103) clock synchronization command.
Sends C_CI_NA_1 (TypeID 101) counter interrogation command.
Sends C_IC_NA_1 (TypeID 100) interrogation command.
Sends a process command InformationObject wrapped in an ASDU.
Sends C_RD_NA_1 (TypeID 102) read command.
Sends C_TS_NA_1 (TypeID 104) test command.
Sends C_TS_TA_1 (TypeID 107) test command with CP56Time2a timestamp.
Sets or updates the ASDU received handler on the connection. Matches CS104_Connection_setASDUReceivedHandler.
Sets or updates the connection event handler on the connection. Matches CS104_Connection_setConnectionHandler.
Starts a CS104.Connection process.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec close(GenServer.server()) :: :ok
@spec connect(GenServer.server()) :: :ok | {:error, term()}
@spec connect_async(GenServer.server()) :: :ok
@spec get_apci_parameters(GenServer.server()) :: IEC60870.APCIParameters.t()
@spec get_app_layer_parameters(GenServer.server()) :: IEC60870.AppLayerParameters.t()
@spec get_state(GenServer.server()) :: map()
@spec is_connected?(GenServer.server()) :: boolean()
@spec is_transmit_buffer_full?(GenServer.server()) :: boolean()
@spec send_asdu(GenServer.server(), IEC60870.ASDU.t()) :: :ok | {:error, term()}
Sends C_CS_NA_1 (TypeID 103) clock synchronization command.
Sends C_CI_NA_1 (TypeID 101) counter interrogation command.
Sends C_IC_NA_1 (TypeID 100) interrogation command.
Sends a process command InformationObject wrapped in an ASDU.
Sends C_RD_NA_1 (TypeID 102) read command.
@spec send_start_dt(GenServer.server()) :: :ok | {:error, term()}
@spec send_stop_dt(GenServer.server()) :: :ok | {:error, term()}
Sends C_TS_NA_1 (TypeID 104) test command.
Sends C_TS_TA_1 (TypeID 107) test command with CP56Time2a timestamp.
@spec send_test_fr(GenServer.server()) :: :ok | {:error, term()}
@spec set_apci_parameters(GenServer.server(), IEC60870.APCIParameters.t()) :: :ok
@spec set_app_layer_parameters(GenServer.server(), IEC60870.AppLayerParameters.t()) :: :ok
@spec set_asdu_handler( GenServer.server(), (pid(), IEC60870.ASDU.t() -> any()) | (IEC60870.ASDU.t() -> any()) | nil ) :: :ok
Sets or updates the ASDU received handler on the connection. Matches CS104_Connection_setASDUReceivedHandler.
@spec set_connection_handler( GenServer.server(), (pid(), atom() -> any()) | (atom() -> any()) | nil ) :: :ok
Sets or updates the connection event handler on the connection. Matches CS104_Connection_setConnectionHandler.
@spec set_originator_address(GenServer.server(), non_neg_integer()) :: :ok
Starts a CS104.Connection process.
Options:
:host- remote IP or hostname (default"127.0.0.1"):port- remote TCP port (default2404, or19998if:tls_optsis given):local_ip- optional local bind address:local_port- optional local bind port (default0):tls_opts- optional:ssloptions list for TLS connections:apci_params-%IEC60870.APCIParameters{}:al_params-%IEC60870.AppLayerParameters{}:owner- PID to receive{:iec60870_cs104, pid, event}messages:connection_handler-fn conn_pid, event -> any() end:asdu_handler-fn conn_pid, asdu -> any() end:raw_message_handler-fn conn_pid, raw_bytes, sent? -> any() end:auto_connect- boolean (defaultfalse):name- GenServer registration name