/* * Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc. * Copyright (C) 2018 Furrtek * * This file is part of PortaPack. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ #include "acars_packet.hpp" #include "crc.hpp" #include namespace acars { size_t Packet::length() const { return packet_.size(); } bool Packet::is_valid() const { return true; //length_valid() && crc_ok(); } Timestamp Packet::received_at() const { return packet_.timestamp(); } uint8_t Packet::block_id() const { return field_.read(96, 8); } std::string Packet::registration_number() const { std::string result; result.reserve(7); const size_t character_length = 8; for(size_t i=16; i<(16+7*character_length); i+=character_length) { result += (field_.read(i, character_length) & 0x7F); } return result; } uint32_t Packet::read(const size_t start_bit, const size_t length) const { return field_.read(start_bit, length); } /*std::string Packet::text( const size_t start_bit, const size_t character_count ) const { std::string result; result.reserve(character_count); const size_t character_length = 6; const size_t end_bit = start_bit + character_count * character_length; for(size_t i=start_bit; i acars_fcs { 0x1021, 0x0000, 0x0000 }; for(size_t i=0; i