Program Listing for File PacketStructure.h
↰ Return to documentation for file (/home/docs/checkouts/readthedocs.org/user_builds/ska-telescope-ska-pst-recv/checkouts/latest/src/ska/pst/recv/formats/PacketStructure.h
)
/*
* Copyright 2022 Square Kilometre Array Observatory
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <cinttypes>
#ifndef SKA_PST_RECV_FORMATS_PacketStructure_h
#define SKA_PST_RECV_FORMATS_PacketStructure_h
namespace ska::pst::recv {
#define INIT_CBF_PST_HEADER_T {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
static constexpr uint32_t magic_word = 0xBEADFEED;
typedef struct cbf_psr_header
{
uint64_t packet_sequence_number;
uint64_t timestamp_attoseconds;
uint32_t timestamp_seconds;
uint32_t channel_separation;
uint64_t first_channel_freq;
float scale_1;
float scale_2;
float scale_3;
float scale_4;
uint32_t first_channel_number;
uint16_t channels_per_packet;
uint16_t valid_channels_per_packet;
uint16_t time_samples_per_packet;
uint16_t beam_number;
uint32_t magic_word;
uint8_t packet_destination;
uint8_t data_precision;
uint8_t num_power_samples_averaged;
uint8_t num_time_samples_per_relative_weight;
uint8_t os_ratio_numerator;
uint8_t os_ratio_denominator;
uint8_t cbf_version_major;
uint8_t cbf_version_minor;
uint64_t scan_id;
float offset_1;
float offset_2;
float offset_3;
float offset_4;
} __attribute__((packed, aligned(1))) cbf_psr_header_t;
typedef struct cbf_psr_packet
{
cbf_psr_header_t * header;
void * weights;
void * data;
} cbf_psr_packet_t;
void configure_packet_defaults(cbf_psr_header_t * header);
bool validate_packet_header(cbf_psr_header_t * header);
size_t get_scale1_byte_offset();
void print_packet_header(cbf_psr_header_t * header);
} // namespace ska::pst::recv
#endif // SKA_PST_RECV_FORMATS_PacketStructure_h