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:1
Date: 2026-06-14
Compilation flags:
`static, context_switching_calls`
Uses:
ccsds_packets(SecondaryHeaderLength)
list
type
Remarks:
(none)
Inherited public predicates:
(none)

## Public predicates

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`

### `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`
Exceptions:
`Bytes`, `FirstHeaderPointer`, or `SecondaryHeaderLength` is a variable:
`instantiation_error`
`Bytes` is neither a variable nor a valid packet-zone byte sequence:
`domain_error(ccsds_packet_zone_bytes,Bytes)`
`FirstHeaderPointer` is neither a variable nor a valid first header pointer for `Bytes`:
`domain_error(ccsds_first_header_pointer,FirstHeaderPointer)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`

### `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`
Exceptions:
`PacketZone` or `SecondaryHeaderLength` is a variable:
`instantiation_error`
`PacketZone` is neither a variable nor a valid packet-zone term:
`domain_error(ccsds_packet_zone,PacketZone)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`

### `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`
Exceptions:
`Frame` or `SecondaryHeaderLength` is a variable:
`instantiation_error`
`Frame` is neither a variable nor a valid TM transfer frame term:
`domain_error(ccsds_tm_transfer_frame_term,Frame)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
The frame packet-zone bytes or first header pointer are invalid:
`domain_error(ccsds_packet_zone_bytes,Bytes)`

### `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`
Exceptions:
`PacketZone`, `SecondaryHeaderLength`, or `Frame` is a variable:
`instantiation_error`
`PacketZone` is neither a variable nor a valid packet-zone term:
`domain_error(ccsds_packet_zone,PacketZone)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Frame` is neither a variable nor a valid TM transfer frame term:
`domain_error(ccsds_tm_transfer_frame_term,Frame)`

### `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`
Exceptions:
`Bytes` or `SecondaryHeaderLength` is a variable:
`instantiation_error`
`Bytes` is neither a variable nor a valid AOS packet-zone byte sequence:
`domain_error(ccsds_aos_packet_zone_bytes,Bytes)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`

### `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`
Exceptions:
`PacketZone` or `SecondaryHeaderLength` is a variable:
`instantiation_error`
`PacketZone` is neither a variable nor a valid packet-zone term:
`domain_error(ccsds_packet_zone,PacketZone)`
`PacketZone` has neither packets nor a pure prefix or suffix and therefore cannot be encoded as an empty AOS packet zone:
`domain_error(ccsds_aos_packet_zone,PacketZone)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`

### `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`
Exceptions:
`PacketZone`, `SecondaryHeaderLength`, or `State` is a variable:
`instantiation_error`
`PacketZone` is neither a variable nor a valid packet-zone term:
`domain_error(ccsds_packet_zone,PacketZone)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`State` is neither a variable nor a valid packet reassembly state:
`domain_error(ccsds_packet_reassembly_state,State)`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frame` or `SecondaryHeaderLength` is a variable:
`instantiation_error`
`Frame` is neither a variable nor a valid AOS transfer frame term:
`domain_error(ccsds_aos_transfer_frame_term,Frame)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
The frame data field is not a valid AOS packet-zone byte sequence:
`domain_error(ccsds_aos_packet_zone_bytes,Bytes)`

### `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`
Exceptions:
`PacketZone`, `SecondaryHeaderLength`, or `Frame` is a variable:
`instantiation_error`
`PacketZone` is neither a variable nor a valid packet-zone term:
`domain_error(ccsds_packet_zone,PacketZone)`
`PacketZone` cannot be encoded as an AOS empty packet zone:
`domain_error(ccsds_aos_packet_zone,PacketZone)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Frame` is neither a variable nor a valid AOS transfer frame term:
`domain_error(ccsds_aos_transfer_frame_term,Frame)`

### `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`
Exceptions:
`Frame`, `SecondaryHeaderLength`, or `State` is a variable:
`instantiation_error`
`Frame` is neither a variable nor a valid TM transfer frame term:
`domain_error(ccsds_tm_transfer_frame_term,Frame)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
The TM frame sequence is discontinuous:
`domain_error(ccsds_tm_transfer_frame_sequence,tm_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current TM frame counter moduli differ:
`domain_error(ccsds_tm_transfer_frame_counter_modulus,tm_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frame`, `SecondaryHeaderLength`, `Policy`, or `State` is a variable:
`instantiation_error`
`Frame` is neither a variable nor a valid TM transfer frame term:
`domain_error(ccsds_tm_transfer_frame_term,Frame)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Policy` is neither a variable nor a valid discontinuity recovery policy:
`domain_error(ccsds_discontinuity_policy,Policy)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
The TM frame sequence is discontinuous under the `throw` recovery policy:
`domain_error(ccsds_tm_transfer_frame_sequence,tm_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current TM frame counter moduli differ:
`domain_error(ccsds_tm_transfer_frame_counter_modulus,tm_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frame`, `SecondaryHeaderLength`, `Policy`, or `State` is a variable:
`instantiation_error`
`Frame` is neither a variable nor a valid TM transfer frame term:
`domain_error(ccsds_tm_transfer_frame_term,Frame)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Policy` is neither a variable nor a valid discontinuity recovery policy:
`domain_error(ccsds_discontinuity_policy,Policy)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
The TM frame sequence is discontinuous under the `throw` recovery policy:
`domain_error(ccsds_tm_transfer_frame_sequence,tm_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current TM frame counter moduli differ:
`domain_error(ccsds_tm_transfer_frame_counter_modulus,tm_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frames`, `SecondaryHeaderLength`, or `State` is a variable:
`instantiation_error`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
An element `Frame` of `Frames` is neither a variable nor a valid TM transfer frame term:
`domain_error(ccsds_tm_transfer_frame_term,Frame)`
The TM frame sequence is discontinuous:
`domain_error(ccsds_tm_transfer_frame_sequence,tm_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current TM frame counter moduli differ:
`domain_error(ccsds_tm_transfer_frame_counter_modulus,tm_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frames`, `SecondaryHeaderLength`, `Policy`, or `State` is a variable:
`instantiation_error`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Policy` is neither a variable nor a valid discontinuity recovery policy:
`domain_error(ccsds_discontinuity_policy,Policy)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
An element `Frame` of `Frames` is neither a variable nor a valid TM transfer frame term:
`domain_error(ccsds_tm_transfer_frame_term,Frame)`
The TM frame sequence is discontinuous under the `throw` recovery policy:
`domain_error(ccsds_tm_transfer_frame_sequence,tm_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current TM frame counter moduli differ:
`domain_error(ccsds_tm_transfer_frame_counter_modulus,tm_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frames`, `SecondaryHeaderLength`, `Policy`, or `State` is a variable:
`instantiation_error`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Policy` is neither a variable nor a valid discontinuity recovery policy:
`domain_error(ccsds_discontinuity_policy,Policy)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
An element `Frame` of `Frames` is neither a variable nor a valid TM transfer frame term:
`domain_error(ccsds_tm_transfer_frame_term,Frame)`
The TM frame sequence is discontinuous under the `throw` recovery policy:
`domain_error(ccsds_tm_transfer_frame_sequence,tm_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current TM frame counter moduli differ:
`domain_error(ccsds_tm_transfer_frame_counter_modulus,tm_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frame`, `SecondaryHeaderLength`, or `State` is a variable:
`instantiation_error`
`Frame` is neither a variable nor a valid AOS transfer frame term:
`domain_error(ccsds_aos_transfer_frame_term,Frame)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
The AOS frame sequence is discontinuous:
`domain_error(ccsds_aos_transfer_frame_sequence,aos_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current AOS frame counter moduli differ:
`domain_error(ccsds_aos_transfer_frame_counter_modulus,aos_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frame`, `SecondaryHeaderLength`, `Policy`, or `State` is a variable:
`instantiation_error`
`Frame` is neither a variable nor a valid AOS transfer frame term:
`domain_error(ccsds_aos_transfer_frame_term,Frame)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Policy` is neither a variable nor a valid discontinuity recovery policy:
`domain_error(ccsds_discontinuity_policy,Policy)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
The AOS frame sequence is discontinuous under the `throw` recovery policy:
`domain_error(ccsds_aos_transfer_frame_sequence,aos_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current AOS frame counter moduli differ:
`domain_error(ccsds_aos_transfer_frame_counter_modulus,aos_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frame`, `SecondaryHeaderLength`, `Policy`, or `State` is a variable:
`instantiation_error`
`Frame` is neither a variable nor a valid AOS transfer frame term:
`domain_error(ccsds_aos_transfer_frame_term,Frame)`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Policy` is neither a variable nor a valid discontinuity recovery policy:
`domain_error(ccsds_discontinuity_policy,Policy)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
The AOS frame sequence is discontinuous under the `throw` recovery policy:
`domain_error(ccsds_aos_transfer_frame_sequence,aos_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current AOS frame counter moduli differ:
`domain_error(ccsds_aos_transfer_frame_counter_modulus,aos_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frames`, `SecondaryHeaderLength`, or `State` is a variable:
`instantiation_error`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
An element `Frame` of `Frames` is neither a variable nor a valid AOS transfer frame term:
`domain_error(ccsds_aos_transfer_frame_term,Frame)`
The AOS frame sequence is discontinuous:
`domain_error(ccsds_aos_transfer_frame_sequence,aos_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current AOS frame counter moduli differ:
`domain_error(ccsds_aos_transfer_frame_counter_modulus,aos_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frames`, `SecondaryHeaderLength`, `Policy`, or `State` is a variable:
`instantiation_error`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Policy` is neither a variable nor a valid discontinuity recovery policy:
`domain_error(ccsds_discontinuity_policy,Policy)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
An element `Frame` of `Frames` is neither a variable nor a valid AOS transfer frame term:
`domain_error(ccsds_aos_transfer_frame_term,Frame)`
The AOS frame sequence is discontinuous under the `throw` recovery policy:
`domain_error(ccsds_aos_transfer_frame_sequence,aos_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current AOS frame counter moduli differ:
`domain_error(ccsds_aos_transfer_frame_counter_modulus,aos_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

### `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`
Exceptions:
`Frames`, `SecondaryHeaderLength`, `Policy`, or `State` is a variable:
`instantiation_error`
`SecondaryHeaderLength` is neither a variable nor a valid CCSDS packet secondary header length:
`domain_error(ccsds_secondary_header_length,SecondaryHeaderLength)`
`Policy` is neither a variable nor a valid discontinuity recovery policy:
`domain_error(ccsds_discontinuity_policy,Policy)`
`State` is neither a variable nor a valid channel reassembly state term:
`domain_error(ccsds_channel_reassembly_state,State)`
An element `Frame` of `Frames` is neither a variable nor a valid AOS transfer frame term:
`domain_error(ccsds_aos_transfer_frame_term,Frame)`
The AOS frame sequence is discontinuous under the `throw` recovery policy:
`domain_error(ccsds_aos_transfer_frame_sequence,aos_transfer_frame_sequence(SpacecraftId,VirtualChannelId,ExpectedFrameCount,VirtualChannelFrameCount))`
The stored and current AOS frame counter moduli differ:
`domain_error(ccsds_aos_transfer_frame_counter_modulus,aos_transfer_frame_counter_modulus(SpacecraftId,VirtualChannelId,StoredCounterModulus,CounterModulus))`
A pending fragment cannot be continued by the packet zone prefix data:
`domain_error(ccsds_packet_reassembly_continuation,packet_reassembly_state(PendingData))`
A continuation fragment is followed by a new packet before the previous packet is completed:
`domain_error(ccsds_packet_reassembly_continuation,incomplete_continuation_before_new_packet)`

## Protected predicates

(no local declarations; see entity ancestors if any)

## Private predicates

(no local declarations; see entity ancestors if any)

## Operators

(none)