mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-25 20:07:38 +00:00
Started work on ACARS RX
Added ACARS frequencies file Moved non-implemented apps menu items down
This commit is contained in:
107
firmware/common/acars_packet.cpp
Normal file
107
firmware/common/acars_packet.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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 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() == 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 ais */
|
75
firmware/common/acars_packet.hpp
Normal file
75
firmware/common/acars_packet.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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__*/
|
@@ -30,13 +30,14 @@
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
|
||||
#include "pocsag_packet.hpp"
|
||||
#include "baseband_packet.hpp"
|
||||
|
||||
#include "acars_packet.hpp"
|
||||
#include "adsb_frame.hpp"
|
||||
#include "ert_packet.hpp"
|
||||
#include "tpms_packet.hpp"
|
||||
#include "pocsag_packet.hpp"
|
||||
#include "sonde_packet.hpp"
|
||||
#include "adsb_frame.hpp"
|
||||
#include "tpms_packet.hpp"
|
||||
#include "jammer.hpp"
|
||||
#include "dsp_fir_taps.hpp"
|
||||
#include "dsp_iir.hpp"
|
||||
@@ -57,9 +58,10 @@ public:
|
||||
ChannelStatistics = 2,
|
||||
DisplayFrameSync = 3,
|
||||
AudioStatistics = 4,
|
||||
Shutdown = 5,
|
||||
TPMSPacket = 6,
|
||||
Shutdown = 8,
|
||||
AISPacket = 7,
|
||||
ACARSPacket = 7,
|
||||
AISPacket = 8,
|
||||
ERTPacket = 9,
|
||||
SondePacket = 10,
|
||||
UpdateSpectrum = 11,
|
||||
@@ -357,6 +359,18 @@ public:
|
||||
pocsag::POCSAGPacket packet;
|
||||
};
|
||||
|
||||
class ACARSPacketMessage : public Message {
|
||||
public:
|
||||
constexpr ACARSPacketMessage(
|
||||
const baseband::Packet& packet
|
||||
) : Message { ID::ACARSPacket },
|
||||
packet { packet }
|
||||
{
|
||||
}
|
||||
|
||||
baseband::Packet packet;
|
||||
};
|
||||
|
||||
class ADSBFrameMessage : public Message {
|
||||
public:
|
||||
constexpr ADSBFrameMessage(
|
||||
|
@@ -63,6 +63,7 @@ private:
|
||||
char c[4];
|
||||
};
|
||||
|
||||
constexpr image_tag_t image_tag_acars { 'P', 'A', 'C', 'A' };
|
||||
constexpr image_tag_t image_tag_adsb_rx { 'P', 'A', 'D', 'R' };
|
||||
constexpr image_tag_t image_tag_afsk_rx { 'P', 'A', 'F', 'R' };
|
||||
constexpr image_tag_t image_tag_ais { 'P', 'A', 'I', 'S' };
|
||||
|
Reference in New Issue
Block a user