.. index:: single: ccsds_packet_services .. _ccsds_packet_services/0: .. rst-class:: right **object** ``ccsds_packet_services`` ========================= Helpers for CCSDS packet service packet-zone splitting and cross-frame TM/AOS packet reassembly. | **Availability:** | ``logtalk_load(ccsds_packet_services(loader))`` | **Author:** Paulo Moura | **Version:** 0:1:0 | **Date:** 2026-05-08 | **Compilation flags:** | ``static, context_switching_calls`` | **Uses:** | :ref:`ccsds_packets(SecondaryHeaderLength) ` | :ref:`list ` | :ref:`type ` | **Remarks:** | (none) | **Inherited public predicates:** | (none) .. contents:: :local: :backlinks: top Public predicates ----------------- .. index:: valid_reassembly_state/1 .. _ccsds_packet_services/0::valid_reassembly_state/1: ``valid_reassembly_state/1`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ True if the argument is a valid packet reassembly state term. | **Compilation flags:** | ``static`` | **Template:** | ``valid_reassembly_state(State)`` | **Mode and number of proofs:** | ``valid_reassembly_state(@compound)`` - ``zero_or_one`` ------------ .. index:: initial_reassembly_state/1 .. _ccsds_packet_services/0::initial_reassembly_state/1: ``initial_reassembly_state/1`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Returns the initial cross-frame packet reassembly state. | **Compilation flags:** | ``static`` | **Template:** | ``initial_reassembly_state(State)`` | **Mode and number of proofs:** | ``initial_reassembly_state(-compound)`` - ``one`` ------------ .. index:: pending_data/2 .. _ccsds_packet_services/0::pending_data/2: ``pending_data/2`` ^^^^^^^^^^^^^^^^^^ Extracts the currently buffered trailing packet fragment bytes from a packet reassembly state. | **Compilation flags:** | ``static`` | **Template:** | ``pending_data(State,Bytes)`` | **Mode and number of proofs:** | ``pending_data(+compound,-list(byte))`` - ``one`` ------------ .. index:: valid_channel_reassembly_state/1 .. _ccsds_packet_services/0::valid_channel_reassembly_state/1: ``valid_channel_reassembly_state/1`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ True if the argument is a valid frame-channel packet reassembly state term keyed by frame type, spacecraft identifier, and virtual channel identifier. | **Compilation flags:** | ``static`` | **Template:** | ``valid_channel_reassembly_state(State)`` | **Mode and number of proofs:** | ``valid_channel_reassembly_state(@compound)`` - ``zero_or_one`` ------------ .. index:: initial_channel_reassembly_state/1 .. _ccsds_packet_services/0::initial_channel_reassembly_state/1: ``initial_channel_reassembly_state/1`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Returns the initial frame-channel packet reassembly state. | **Compilation flags:** | ``static`` | **Template:** | ``initial_channel_reassembly_state(State)`` | **Mode and number of proofs:** | ``initial_channel_reassembly_state(-compound)`` - ``one`` ------------ .. index:: pending_fragments/2 .. _ccsds_packet_services/0::pending_fragments/2: ``pending_fragments/2`` ^^^^^^^^^^^^^^^^^^^^^^^ Extracts the non-empty pending packet fragments buffered per frame type, spacecraft identifier, and virtual channel identifier. | **Compilation flags:** | ``static`` | **Template:** | ``pending_fragments(State,PendingFragments)`` | **Mode and number of proofs:** | ``pending_fragments(+compound,-list(compound))`` - ``one`` ------------ .. index:: valid_discontinuity_policy/1 .. _ccsds_packet_services/0::valid_discontinuity_policy/1: ``valid_discontinuity_policy/1`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ True if the argument is a valid discontinuity recovery policy atom. Valid values are ``throw``, ``drop``, and ``resynchronize``. | **Compilation flags:** | ``static`` | **Template:** | ``valid_discontinuity_policy(Policy)`` | **Mode and number of proofs:** | ``valid_discontinuity_policy(@atom)`` - ``zero_or_one`` ------------ .. index:: valid/1 .. _ccsds_packet_services/0::valid/1: ``valid/1`` ^^^^^^^^^^^ True if the argument is a valid packet-zone term. | **Compilation flags:** | ``static`` | **Template:** | ``valid(PacketZone)`` | **Mode and number of proofs:** | ``valid(@compound)`` - ``zero_or_one`` ------------ .. index:: prefix_data/2 .. _ccsds_packet_services/0::prefix_data/2: ``prefix_data/2`` ^^^^^^^^^^^^^^^^^ Extracts the bytes that precede the first complete packet in a packet zone. | **Compilation flags:** | ``static`` | **Template:** | ``prefix_data(PacketZone,PrefixData)`` | **Mode and number of proofs:** | ``prefix_data(+compound,-list(byte))`` - ``one`` ------------ .. index:: packets/2 .. _ccsds_packet_services/0::packets/2: ``packets/2`` ^^^^^^^^^^^^^ Extracts the list of complete packets in a packet zone. | **Compilation flags:** | ``static`` | **Template:** | ``packets(PacketZone,Packets)`` | **Mode and number of proofs:** | ``packets(+compound,-list(compound))`` - ``one`` ------------ .. index:: suffix_data/2 .. _ccsds_packet_services/0::suffix_data/2: ``suffix_data/2`` ^^^^^^^^^^^^^^^^^ Extracts the bytes that trail the last complete packet in a packet zone. | **Compilation flags:** | ``static`` | **Template:** | ``suffix_data(PacketZone,SuffixData)`` | **Mode and number of proofs:** | ``suffix_data(+compound,-list(byte))`` - ``one`` ------------ .. index:: split_packet_zone/4 .. _ccsds_packet_services/0::split_packet_zone/4: ``split_packet_zone/4`` ^^^^^^^^^^^^^^^^^^^^^^^ Splits a packet-zone byte sequence using the first header pointer and parses any complete packets starting at that offset. A pointer value of 2047 denotes that no packet starts in the zone. | **Compilation flags:** | ``static`` | **Template:** | ``split_packet_zone(Bytes,FirstHeaderPointer,SecondaryHeaderLength,PacketZone)`` | **Mode and number of proofs:** | ``split_packet_zone(+list(byte),+integer,+integer,-compound)`` - ``one_or_error`` ------------ .. index:: join_packet_zone/4 .. _ccsds_packet_services/0::join_packet_zone/4: ``join_packet_zone/4`` ^^^^^^^^^^^^^^^^^^^^^^ Encodes a packet-zone term back into bytes and returns the corresponding first header pointer. When the packet list is empty, the pointer is set to 2047. | **Compilation flags:** | ``static`` | **Template:** | ``join_packet_zone(PacketZone,SecondaryHeaderLength,Bytes,FirstHeaderPointer)`` | **Mode and number of proofs:** | ``join_packet_zone(+compound,+integer,-list(byte),-integer)`` - ``one_or_error`` ------------ .. index:: extract_tm_packets/3 .. _ccsds_packet_services/0::extract_tm_packets/3: ``extract_tm_packets/3`` ^^^^^^^^^^^^^^^^^^^^^^^^ Extracts a TM transfer frame packet zone as a packet-zone term using the frame first header pointer and the given packet secondary header length. | **Compilation flags:** | ``static`` | **Template:** | ``extract_tm_packets(Frame,SecondaryHeaderLength,PacketZone)`` | **Mode and number of proofs:** | ``extract_tm_packets(+compound,+integer,-compound)`` - ``one_or_error`` ------------ .. index:: insert_tm_packets/4 .. _ccsds_packet_services/0::insert_tm_packets/4: ``insert_tm_packets/4`` ^^^^^^^^^^^^^^^^^^^^^^^ Updates a TM transfer frame data field and first header pointer from a packet-zone term while preserving the remaining frame fields unchanged. | **Compilation flags:** | ``static`` | **Template:** | ``insert_tm_packets(PacketZone,SecondaryHeaderLength,Frame,UpdatedFrame)`` | **Mode and number of proofs:** | ``insert_tm_packets(+compound,+integer,+compound,-compound)`` - ``one_or_error`` ------------ .. index:: split_aos_packet_zone/3 .. _ccsds_packet_services/0::split_aos_packet_zone/3: ``split_aos_packet_zone/3`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Splits an AOS M_PDU packet-service data field into a packet-zone term. The first two octets are interpreted as the M_PDU first header pointer field, where 2046 denotes idle data only and 2047 denotes that no packet starts in the packet zone. | **Compilation flags:** | ``static`` | **Template:** | ``split_aos_packet_zone(Bytes,SecondaryHeaderLength,PacketZone)`` | **Mode and number of proofs:** | ``split_aos_packet_zone(+list(byte),+integer,-compound)`` - ``one_or_error`` ------------ .. index:: join_aos_packet_zone/3 .. _ccsds_packet_services/0::join_aos_packet_zone/3: ``join_aos_packet_zone/3`` ^^^^^^^^^^^^^^^^^^^^^^^^^^ Encodes a packet-zone term as an AOS M_PDU packet-service data field, including the two-octet first header pointer field. | **Compilation flags:** | ``static`` | **Template:** | ``join_aos_packet_zone(PacketZone,SecondaryHeaderLength,Bytes)`` | **Mode and number of proofs:** | ``join_aos_packet_zone(+compound,+integer,-list(byte))`` - ``one_or_error`` ------------ .. index:: reassemble_packet_zone/5 .. _ccsds_packet_services/0::reassemble_packet_zone/5: ``reassemble_packet_zone/5`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reassembles complete packets from a packet-zone term and a prior packet reassembly state, returning any complete packets plus the updated trailing fragment state. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_packet_zone(PacketZone,SecondaryHeaderLength,State,Packets,UpdatedState)`` | **Mode and number of proofs:** | ``reassemble_packet_zone(+compound,+integer,+compound,-list(compound),-compound)`` - ``one_or_error`` ------------ .. index:: extract_aos_packets/3 .. _ccsds_packet_services/0::extract_aos_packets/3: ``extract_aos_packets/3`` ^^^^^^^^^^^^^^^^^^^^^^^^^ Extracts an AOS transfer frame packet zone as a packet-zone term using the two-octet M_PDU header at the beginning of the frame data field. | **Compilation flags:** | ``static`` | **Template:** | ``extract_aos_packets(Frame,SecondaryHeaderLength,PacketZone)`` | **Mode and number of proofs:** | ``extract_aos_packets(+compound,+integer,-compound)`` - ``one_or_error`` ------------ .. index:: insert_aos_packets/4 .. _ccsds_packet_services/0::insert_aos_packets/4: ``insert_aos_packets/4`` ^^^^^^^^^^^^^^^^^^^^^^^^ Updates an AOS transfer frame data field from a packet-zone term by regenerating the M_PDU first header pointer and packet-zone bytes while preserving the remaining frame fields unchanged. | **Compilation flags:** | ``static`` | **Template:** | ``insert_aos_packets(PacketZone,SecondaryHeaderLength,Frame,UpdatedFrame)`` | **Mode and number of proofs:** | ``insert_aos_packets(+compound,+integer,+compound,-compound)`` - ``one_or_error`` ------------ .. index:: reassemble_tm_packets/5 .. _ccsds_packet_services/0::reassemble_tm_packets/5: ``reassemble_tm_packets/5`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Extracts the packet zone from a TM transfer frame, using the default ``throw`` discontinuity recovery policy, and returns the complete packets plus the updated channel reassembly state. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_tm_packets(Frame,SecondaryHeaderLength,State,Packets,UpdatedState)`` | **Mode and number of proofs:** | ``reassemble_tm_packets(+compound,+integer,+compound,-list(compound),-compound)`` - ``one_or_error`` ------------ .. index:: reassemble_tm_packets/6 .. _ccsds_packet_services/0::reassemble_tm_packets/6: ``reassemble_tm_packets/6`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Extracts the packet zone from a TM transfer frame, applies the selected discontinuity recovery policy when frame-count continuity is broken, and returns the complete packets plus the updated channel reassembly state. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_tm_packets(Frame,SecondaryHeaderLength,Policy,State,Packets,UpdatedState)`` | **Mode and number of proofs:** | ``reassemble_tm_packets(+compound,+integer,+atom,+compound,-list(compound),-compound)`` - ``one_or_error`` ------------ .. index:: reassemble_tm_packets/7 .. _ccsds_packet_services/0::reassemble_tm_packets/7: ``reassemble_tm_packets/7`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Extracts the packet zone from a TM transfer frame, applies the selected discontinuity recovery policy when frame-count continuity is broken, and returns the complete packets, updated channel reassembly state, and explicit recovery events. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_tm_packets(Frame,SecondaryHeaderLength,Policy,State,Packets,UpdatedState,Events)`` | **Mode and number of proofs:** | ``reassemble_tm_packets(+compound,+integer,+atom,+compound,-list(compound),-compound,-list(compound))`` - ``one_or_error`` ------------ .. index:: reassemble_tm_frames/5 .. _ccsds_packet_services/0::reassemble_tm_frames/5: ``reassemble_tm_frames/5`` ^^^^^^^^^^^^^^^^^^^^^^^^^^ Reassembles complete packets across a sequence of TM transfer frames using the default ``throw`` discontinuity recovery policy. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_tm_frames(Frames,SecondaryHeaderLength,State,Packets,UpdatedState)`` | **Mode and number of proofs:** | ``reassemble_tm_frames(+list(compound),+integer,+compound,-list(compound),-compound)`` - ``one_or_error`` ------------ .. index:: reassemble_tm_frames/6 .. _ccsds_packet_services/0::reassemble_tm_frames/6: ``reassemble_tm_frames/6`` ^^^^^^^^^^^^^^^^^^^^^^^^^^ Reassembles complete packets across a sequence of TM transfer frames using the selected discontinuity recovery policy. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_tm_frames(Frames,SecondaryHeaderLength,Policy,State,Packets,UpdatedState)`` | **Mode and number of proofs:** | ``reassemble_tm_frames(+list(compound),+integer,+atom,+compound,-list(compound),-compound)`` - ``one_or_error`` ------------ .. index:: reassemble_tm_frames/7 .. _ccsds_packet_services/0::reassemble_tm_frames/7: ``reassemble_tm_frames/7`` ^^^^^^^^^^^^^^^^^^^^^^^^^^ Reassembles complete packets across a sequence of TM transfer frames using the selected discontinuity recovery policy and returns any recovery events in frame order. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_tm_frames(Frames,SecondaryHeaderLength,Policy,State,Packets,UpdatedState,Events)`` | **Mode and number of proofs:** | ``reassemble_tm_frames(+list(compound),+integer,+atom,+compound,-list(compound),-compound,-list(compound))`` - ``one_or_error`` ------------ .. index:: reassemble_aos_packets/5 .. _ccsds_packet_services/0::reassemble_aos_packets/5: ``reassemble_aos_packets/5`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Extracts the packet zone from an AOS transfer frame, using the default ``throw`` discontinuity recovery policy, and returns the complete packets plus the updated channel reassembly state. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_aos_packets(Frame,SecondaryHeaderLength,State,Packets,UpdatedState)`` | **Mode and number of proofs:** | ``reassemble_aos_packets(+compound,+integer,+compound,-list(compound),-compound)`` - ``one_or_error`` ------------ .. index:: reassemble_aos_packets/6 .. _ccsds_packet_services/0::reassemble_aos_packets/6: ``reassemble_aos_packets/6`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Extracts the packet zone from an AOS transfer frame, applies the selected discontinuity recovery policy when frame-count continuity is broken, and returns the complete packets plus the updated channel reassembly state. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_aos_packets(Frame,SecondaryHeaderLength,Policy,State,Packets,UpdatedState)`` | **Mode and number of proofs:** | ``reassemble_aos_packets(+compound,+integer,+atom,+compound,-list(compound),-compound)`` - ``one_or_error`` ------------ .. index:: reassemble_aos_packets/7 .. _ccsds_packet_services/0::reassemble_aos_packets/7: ``reassemble_aos_packets/7`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Extracts the packet zone from an AOS transfer frame, applies the selected discontinuity recovery policy when frame-count continuity is broken, and returns the complete packets, updated channel reassembly state, and explicit recovery events. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_aos_packets(Frame,SecondaryHeaderLength,Policy,State,Packets,UpdatedState,Events)`` | **Mode and number of proofs:** | ``reassemble_aos_packets(+compound,+integer,+atom,+compound,-list(compound),-compound,-list(compound))`` - ``one_or_error`` ------------ .. index:: reassemble_aos_frames/5 .. _ccsds_packet_services/0::reassemble_aos_frames/5: ``reassemble_aos_frames/5`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reassembles complete packets across a sequence of AOS transfer frames using the default ``throw`` discontinuity recovery policy. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_aos_frames(Frames,SecondaryHeaderLength,State,Packets,UpdatedState)`` | **Mode and number of proofs:** | ``reassemble_aos_frames(+list(compound),+integer,+compound,-list(compound),-compound)`` - ``one_or_error`` ------------ .. index:: reassemble_aos_frames/6 .. _ccsds_packet_services/0::reassemble_aos_frames/6: ``reassemble_aos_frames/6`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reassembles complete packets across a sequence of AOS transfer frames using the selected discontinuity recovery policy. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_aos_frames(Frames,SecondaryHeaderLength,Policy,State,Packets,UpdatedState)`` | **Mode and number of proofs:** | ``reassemble_aos_frames(+list(compound),+integer,+atom,+compound,-list(compound),-compound)`` - ``one_or_error`` ------------ .. index:: reassemble_aos_frames/7 .. _ccsds_packet_services/0::reassemble_aos_frames/7: ``reassemble_aos_frames/7`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Reassembles complete packets across a sequence of AOS transfer frames using the selected discontinuity recovery policy and returns any recovery events in frame order. | **Compilation flags:** | ``static`` | **Template:** | ``reassemble_aos_frames(Frames,SecondaryHeaderLength,Policy,State,Packets,UpdatedState,Events)`` | **Mode and number of proofs:** | ``reassemble_aos_frames(+list(compound),+integer,+atom,+compound,-list(compound),-compound,-list(compound))`` - ``one_or_error`` ------------ Protected predicates -------------------- (no local declarations; see entity ancestors if any) Private predicates ------------------ (no local declarations; see entity ancestors if any) Operators --------- (none)