IEC 60870-5-101 FT 1.2 frame codec and stream deframer (serial_transceiver_ft_1_2.c & link_layer.c).
Supports:
- Single-character ACK (
0xE5)::single_char_ack - Fixed-length frame (
0x10, C, Addr..., CS, 0x16):{:fixed_frame, control_map, address} - Variable-length frame (
0x68, L, L, 0x68, C, Addr..., UserData..., CS, 0x16):{:variable_frame, control_map, address, user_data}
Summary
Functions
Computes 8-bit modulo-256 sum of bytes in bin.
Decodes a single complete FT 1.2 frame given address_length (0, 1, or 2).
Decodes a link layer address according to address_length (0, 1, or 2).
Decodes an 8-bit control field byte into a map.
Encodes an FT 1.2 frame into wire binary given address_length (0, 1, or 2).
Encodes a link layer address according to address_length (0, 1, or 2).
Encodes a control field map into an 8-bit integer.
Extracts complete FT 1.2 frames from a stream buffer given address_length.
Returns {:ok, frames, remaining_buffer} or {:error, reason, remaining_buffer}.
Types
@type t() :: :single_char_ack | {:fixed_frame, control(), non_neg_integer()} | {:variable_frame, control(), non_neg_integer(), binary()}
Functions
@spec checksum(binary()) :: non_neg_integer()
Computes 8-bit modulo-256 sum of bytes in bin.
Decodes a single complete FT 1.2 frame given address_length (0, 1, or 2).
@spec decode_address(binary(), 0..2) :: {:ok, non_neg_integer(), binary()} | {:error, term()}
Decodes a link layer address according to address_length (0, 1, or 2).
@spec decode_control(non_neg_integer()) :: control()
Decodes an 8-bit control field byte into a map.
Encodes an FT 1.2 frame into wire binary given address_length (0, 1, or 2).
@spec encode_address(non_neg_integer(), 0..2) :: binary()
Encodes a link layer address according to address_length (0, 1, or 2).
@spec encode_control(map()) :: non_neg_integer()
Encodes a control field map into an 8-bit integer.
Extracts complete FT 1.2 frames from a stream buffer given address_length.
Returns {:ok, frames, remaining_buffer} or {:error, reason, remaining_buffer}.