acars to ext but disabled (#2288)

This commit is contained in:
Totoo
2024-10-07 15:58:37 +02:00
committed by GitHub
parent b9771b2350
commit 09c2c43be0
14 changed files with 353 additions and 295 deletions

View File

@@ -1,107 +0,0 @@
/*
* 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 <cstdlib>
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<end_bit; i+=character_length) {
result += char_to_ascii(field_.read(i, character_length));
}
return result;
}*/
bool Packet::crc_ok() const {
CRCReader field_crc{packet_};
CRC<16> acars_fcs{0x1021, 0x0000, 0x0000};
for (size_t i = 0; i < data_length(); i += 8) {
acars_fcs.process_byte(field_crc.read(i, 8));
}
return (acars_fcs.checksum() == (unsigned)field_crc.read(data_length(), fcs_length));
}
size_t Packet::data_and_fcs_length() const {
return length() - 8;
}
size_t Packet::data_length() const {
return data_and_fcs_length() - fcs_length;
}
bool Packet::length_valid() const {
const size_t extra_bits = data_and_fcs_length() & 7;
if (extra_bits != 0) {
return false;
}
return true;
}
} // namespace acars

View File

@@ -1,74 +0,0 @@
/*
* 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.
*/
#ifndef __ACARS_PACKET_H__
#define __ACARS_PACKET_H__
#include "baseband_packet.hpp"
#include "field_reader.hpp"
#include <cstdint>
#include <cstddef>
#include <string>
namespace acars {
class Packet {
public:
constexpr Packet(
const baseband::Packet& packet)
: packet_{packet},
field_{packet_} {
}
size_t length() const;
bool is_valid() const;
Timestamp received_at() const;
uint8_t block_id() const;
std::string registration_number() const;
uint32_t read(const size_t start_bit, const size_t length) const;
// std::string text(const size_t start_bit, const size_t character_count) const;
bool crc_ok() const;
private:
using Reader = FieldReader<baseband::Packet, BitRemapByteReverse>;
using CRCReader = FieldReader<baseband::Packet, BitRemapNone>;
const baseband::Packet packet_;
const Reader field_;
const size_t fcs_length = 16;
size_t data_and_fcs_length() const;
size_t data_length() const;
bool length_valid() const;
};
} /* namespace acars */
#endif /*__ACARS_PACKET_H__*/

View File

@@ -190,4 +190,21 @@ class Adler32 {
}
};
static const unsigned char parity_numbits[256] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
class ParityCheck {
public:
static bool parity_check(uint8_t ch, uint8_t pbitpos = 1) {
return ((parity_numbits[ch] & pbitpos) != 0);
}
};
#endif /*__CRC_H__*/

View File

@@ -32,7 +32,6 @@
#include "baseband_packet.hpp"
#include "acars_packet.hpp"
#include "adsb_frame.hpp"
#include "ert_packet.hpp"
#include "pocsag_packet.hpp"
@@ -379,13 +378,12 @@ class POCSAGStatsMessage : public Message {
class ACARSPacketMessage : public Message {
public:
constexpr ACARSPacketMessage(
const baseband::Packet& packet)
: Message{ID::ACARSPacket},
packet{packet} {
}
baseband::Packet packet;
constexpr ACARSPacketMessage()
: Message{ID::ACARSPacket} {}
uint8_t msg_len = 0;
char message[250] = {0}; // contains the whole packet
uint8_t crc[2] = {0};
uint8_t state = 0; // for debug
};
class ADSBFrameMessage : public Message {