mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-25 19:47:36 +00:00
Started working on radiosonde RX
Removed some warnings Better handling of absent map file in GeoMap ?
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "ert_packet.hpp"
|
||||
#include "tpms_packet.hpp"
|
||||
#include "pocsag_packet.hpp"
|
||||
#include "sonde_packet.hpp"
|
||||
#include "adsb_frame.hpp"
|
||||
#include "jammer.hpp"
|
||||
#include "dsp_fir_taps.hpp"
|
||||
@@ -60,18 +61,19 @@ public:
|
||||
Shutdown = 8,
|
||||
AISPacket = 7,
|
||||
ERTPacket = 9,
|
||||
UpdateSpectrum = 10,
|
||||
NBFMConfigure = 11,
|
||||
WFMConfigure = 12,
|
||||
AMConfigure = 13,
|
||||
ChannelSpectrumConfig = 14,
|
||||
SpectrumStreamingConfig = 15,
|
||||
DisplaySleep = 16,
|
||||
CaptureConfig = 17,
|
||||
CaptureThreadDone = 18,
|
||||
ReplayConfig = 19,
|
||||
ReplayThreadDone = 20,
|
||||
AFSKRxConfigure = 21,
|
||||
SondePacket = 10,
|
||||
UpdateSpectrum = 11,
|
||||
NBFMConfigure = 12,
|
||||
WFMConfigure = 13,
|
||||
AMConfigure = 14,
|
||||
ChannelSpectrumConfig = 15,
|
||||
SpectrumStreamingConfig = 16,
|
||||
DisplaySleep = 17,
|
||||
CaptureConfig = 18,
|
||||
CaptureThreadDone = 19,
|
||||
ReplayConfig = 20,
|
||||
ReplayThreadDone = 21,
|
||||
AFSKRxConfigure = 22,
|
||||
|
||||
TXProgress = 30,
|
||||
Retune = 31,
|
||||
@@ -372,6 +374,22 @@ public:
|
||||
baseband::Packet packet;
|
||||
};
|
||||
|
||||
class SondePacketMessage : public Message {
|
||||
public:
|
||||
constexpr SondePacketMessage(
|
||||
const sonde::Packet::Type type,
|
||||
const baseband::Packet& packet
|
||||
) : Message { ID::SondePacket },
|
||||
type { type },
|
||||
packet { packet }
|
||||
{
|
||||
}
|
||||
|
||||
sonde::Packet::Type type;
|
||||
|
||||
baseband::Packet packet;
|
||||
};
|
||||
|
||||
class UpdateSpectrumMessage : public Message {
|
||||
public:
|
||||
constexpr UpdateSpectrumMessage(
|
||||
|
97
firmware/common/sonde_packet.cpp
Normal file
97
firmware/common/sonde_packet.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 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 "sonde_packet.hpp"
|
||||
|
||||
//#include "crc.hpp"
|
||||
|
||||
namespace sonde {
|
||||
|
||||
size_t Packet::length() const {
|
||||
return decoder_.symbols_count();
|
||||
}
|
||||
|
||||
bool Packet::is_valid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
Timestamp Packet::received_at() const {
|
||||
return packet_.timestamp();
|
||||
}
|
||||
|
||||
Packet::Type Packet::type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
SN Packet::serial_number() const {
|
||||
if (type() == Type::M10) {
|
||||
// See https://github.com/rs1729/RS/blob/master/m10/m10x.c line 606
|
||||
return (reader_.read(2 * 8, 8) << 20) |
|
||||
(reader_.read(0, 4) << 16) |
|
||||
(reader_.read(4 * 8, 3) << 13) |
|
||||
(reader_.read(4 * 8 + 3, 5) << 8) |
|
||||
reader_.read(3 * 8, 8);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
FormattedSymbols Packet::symbols_formatted() const {
|
||||
return format_symbols(decoder_);
|
||||
}
|
||||
|
||||
bool Packet::crc_ok() const {
|
||||
switch(type()) {
|
||||
case Type::M10: return crc_ok_M10();
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Packet::crc_ok_M10() const {
|
||||
uint16_t cs { 0 };
|
||||
uint32_t c0, c1, t, t6, t7, s,b ;
|
||||
|
||||
for (size_t i = 0; i < packet_.size(); i++) {
|
||||
b = packet_[i];
|
||||
c1 = cs & 0xFF;
|
||||
|
||||
// B
|
||||
b = (b >> 1) | ((b & 1) << 7);
|
||||
b ^= (b >> 2) & 0xFF;
|
||||
|
||||
// A1
|
||||
t6 = (cs & 1) ^ ((cs >> 2) & 1) ^ ((cs >> 4) & 1);
|
||||
t7 = ((cs >> 1) & 1) ^ ((cs >> 3) & 1) ^ ((cs >> 5) & 1);
|
||||
t = (cs & 0x3F) | (t6 << 6) | (t7 << 7);
|
||||
|
||||
// A2
|
||||
s = (cs >> 7) & 0xFF;
|
||||
s ^= (s >> 2) & 0xFF;
|
||||
|
||||
c0 = b ^ t ^ s;
|
||||
|
||||
cs = ((c1<<8) | c0) & 0xFFFF;
|
||||
}
|
||||
|
||||
return ((cs & 0xFFFF) == ((packet_[0x63] << 8) | (packet_[0x63 + 1])));
|
||||
}
|
||||
|
||||
} /* namespace sonde */
|
80
firmware/common/sonde_packet.hpp
Normal file
80
firmware/common/sonde_packet.hpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
* Copyright (C) 2017 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 __SONDE_PACKET_H__
|
||||
#define __SONDE_PACKET_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
#include "field_reader.hpp"
|
||||
#include "baseband_packet.hpp"
|
||||
#include "manchester.hpp"
|
||||
|
||||
namespace sonde {
|
||||
|
||||
using SN = uint64_t;
|
||||
|
||||
class Packet {
|
||||
public:
|
||||
enum class Type : uint32_t {
|
||||
Unknown = 0,
|
||||
M10 = 1,
|
||||
};
|
||||
|
||||
Packet(
|
||||
const Type type,
|
||||
const baseband::Packet& packet
|
||||
) : packet_ { packet },
|
||||
decoder_ { packet_ },
|
||||
reader_ { decoder_ },
|
||||
type_ { type }
|
||||
{
|
||||
}
|
||||
|
||||
size_t length() const;
|
||||
|
||||
bool is_valid() const;
|
||||
|
||||
Timestamp received_at() const;
|
||||
|
||||
Type type() const;
|
||||
SN serial_number() const;
|
||||
|
||||
FormattedSymbols symbols_formatted() const;
|
||||
|
||||
bool crc_ok() const;
|
||||
|
||||
private:
|
||||
using Reader = FieldReader<ManchesterDecoder, BitRemapNone>;
|
||||
|
||||
const baseband::Packet packet_;
|
||||
const ManchesterDecoder decoder_;
|
||||
const Reader reader_;
|
||||
const Type type_;
|
||||
|
||||
bool crc_ok_M10() const;
|
||||
};
|
||||
|
||||
} /* namespace sonde */
|
||||
|
||||
#endif/*__SONDE_PACKET_H__*/
|
@@ -70,23 +70,24 @@ constexpr image_tag_t image_tag_am_audio { 'P', 'A', 'M', 'A' };
|
||||
constexpr image_tag_t image_tag_capture { 'P', 'C', 'A', 'P' };
|
||||
constexpr image_tag_t image_tag_ert { 'P', 'E', 'R', 'T' };
|
||||
constexpr image_tag_t image_tag_nfm_audio { 'P', 'N', 'F', 'M' };
|
||||
constexpr image_tag_t image_tag_tpms { 'P', 'T', 'P', 'M' };
|
||||
constexpr image_tag_t image_tag_pocsag { 'P', 'P', 'O', 'C' };
|
||||
constexpr image_tag_t image_tag_sonde { 'P', 'S', 'O', 'N' };
|
||||
constexpr image_tag_t image_tag_tpms { 'P', 'T', 'P', 'M' };
|
||||
constexpr image_tag_t image_tag_wfm_audio { 'P', 'W', 'F', 'M' };
|
||||
constexpr image_tag_t image_tag_wideband_spectrum { 'P', 'S', 'P', 'E' };
|
||||
|
||||
constexpr image_tag_t image_tag_jammer { 'P', 'J', 'A', 'M' };
|
||||
constexpr image_tag_t image_tag_audio_tx { 'P', 'A', 'T', 'X' };
|
||||
constexpr image_tag_t image_tag_afsk { 'P', 'A', 'F', 'T' };
|
||||
constexpr image_tag_t image_tag_tones { 'P', 'T', 'O', 'N' };
|
||||
constexpr image_tag_t image_tag_rds { 'P', 'R', 'D', 'S' };
|
||||
constexpr image_tag_t image_tag_ook { 'P', 'O', 'O', 'K' };
|
||||
constexpr image_tag_t image_tag_adsb_tx { 'P', 'A', 'D', 'T' };
|
||||
constexpr image_tag_t image_tag_replay { 'P', 'R', 'E', 'P' };
|
||||
constexpr image_tag_t image_tag_afsk { 'P', 'A', 'F', 'T' };
|
||||
constexpr image_tag_t image_tag_audio_tx { 'P', 'A', 'T', 'X' };
|
||||
constexpr image_tag_t image_tag_fsktx { 'P', 'F', 'S', 'K' };
|
||||
constexpr image_tag_t image_tag_jammer { 'P', 'J', 'A', 'M' };
|
||||
constexpr image_tag_t image_tag_mic_tx { 'P', 'M', 'T', 'X' };
|
||||
constexpr image_tag_t image_tag_sstv_tx { 'P', 'S', 'T', 'X' };
|
||||
constexpr image_tag_t image_tag_ook { 'P', 'O', 'O', 'K' };
|
||||
constexpr image_tag_t image_tag_rds { 'P', 'R', 'D', 'S' };
|
||||
constexpr image_tag_t image_tag_replay { 'P', 'R', 'E', 'P' };
|
||||
constexpr image_tag_t image_tag_siggen { 'P', 'S', 'I', 'G' };
|
||||
constexpr image_tag_t image_tag_sstv_tx { 'P', 'S', 'T', 'X' };
|
||||
constexpr image_tag_t image_tag_tones { 'P', 'T', 'O', 'N' };
|
||||
|
||||
constexpr image_tag_t image_tag_noop { 'P', 'N', 'O', 'P' };
|
||||
|
||||
|
Reference in New Issue
Block a user