Radiosonde RX now understands Meteomodem's M10 correctly

Updated binary
This commit is contained in:
furrtek 2017-10-27 18:54:50 +02:00
parent 6e7b2c751f
commit d47f292d3a
11 changed files with 157 additions and 47 deletions

View File

@ -136,7 +136,7 @@ public:
float lat, float lat,
float lon, float lon,
float angle, float angle,
const std::function<void(void)> on_close const std::function<void(void)> on_close = nullptr
); );
GeoMapView(NavigationView& nav, GeoMapView(NavigationView& nav,
int32_t altitude, int32_t altitude,

View File

@ -297,7 +297,7 @@ ReceiversMenuView::ReceiversMenuView(NavigationView& nav) {
{ "POCSAG", ui::Color::green(), &bitmap_icon_pocsag, [&nav](){ nav.push<POCSAGAppView>(); } }, { "POCSAG", ui::Color::green(), &bitmap_icon_pocsag, [&nav](){ nav.push<POCSAGAppView>(); } },
{ "SIGFOX", ui::Color::grey(), &bitmap_icon_fox, [&nav](){ nav.push<NotImplementedView>(); } }, // SIGFRXView { "SIGFOX", ui::Color::grey(), &bitmap_icon_fox, [&nav](){ nav.push<NotImplementedView>(); } }, // SIGFRXView
{ "LoRa", ui::Color::grey(), nullptr, [&nav](){ nav.push<NotImplementedView>(); } }, { "LoRa", ui::Color::grey(), nullptr, [&nav](){ nav.push<NotImplementedView>(); } },
{ "Radiosondes", ui::Color::red(), &bitmap_icon_sonde, [&nav](){ nav.push<SondeView>(); } }, { "Radiosondes", ui::Color::yellow(),&bitmap_icon_sonde, [&nav](){ nav.push<SondeView>(); } },
{ "SSTV", ui::Color::grey(), &bitmap_icon_sstv, [&nav](){ nav.push<NotImplementedView>(); } }, { "SSTV", ui::Color::grey(), &bitmap_icon_sstv, [&nav](){ nav.push<NotImplementedView>(); } },
{ "TPMS: Cars", ui::Color::green(), &bitmap_icon_tpms, [&nav](){ nav.push<TPMSAppView>(); } }, { "TPMS: Cars", ui::Color::green(), &bitmap_icon_tpms, [&nav](){ nav.push<TPMSAppView>(); } },
}); });

View File

@ -42,16 +42,22 @@ SondeView::SondeView(NavigationView& nav) {
baseband::run_image(portapack::spi_flash::image_tag_sonde); baseband::run_image(portapack::spi_flash::image_tag_sonde);
add_children({ add_children({
&field_frequency, &labels,
&text_debug,
&field_rf_amp, &field_rf_amp,
&field_lna, &field_lna,
&field_vga, &field_vga,
&rssi &rssi,
&field_frequency,
&text_debug_a,
&text_debug_b,
&text_signature,
&text_sats,
&geopos,
&button_see_map
}); });
field_frequency.set_value(receiver_model.tuning_frequency()); field_frequency.set_value(target_frequency_);
field_frequency.set_step(receiver_model.frequency_step()); field_frequency.set_step(10000);
field_frequency.on_change = [this](rf::Frequency f) { field_frequency.on_change = [this](rf::Frequency f) {
set_target_frequency(f); set_target_frequency(f);
field_frequency.set_value(f); field_frequency.set_value(f);
@ -65,8 +71,10 @@ SondeView::SondeView(NavigationView& nav) {
}; };
}; };
geopos.set_read_only(true);
radio::enable({ radio::enable({
receiver_model.tuning_frequency(), tuning_frequency(),
sampling_rate, sampling_rate,
baseband_bandwidth, baseband_bandwidth,
rf::Direction::Receive, rf::Direction::Receive,
@ -75,7 +83,14 @@ SondeView::SondeView(NavigationView& nav) {
static_cast<int8_t>(receiver_model.vga()), static_cast<int8_t>(receiver_model.vga()),
}); });
set_target_frequency(402000000); button_see_map.on_select = [this, &nav](Button&) {
nav.push<GeoMapView>(
"",
altitude,
latitude,
longitude,
0);
};
/*logger = std::make_unique<SondeLogger>(); /*logger = std::make_unique<SondeLogger>();
if( logger ) { if( logger ) {
@ -92,14 +107,23 @@ void SondeView::focus() {
field_vga.focus(); field_vga.focus();
} }
void SondeView::on_packet(const baseband::Packet& packet) { void SondeView::on_packet(const sonde::Packet& packet) {
std::string bin_string; const auto hex_formatted = packet.symbols_formatted();
for (size_t i = 0; i < 30; i++) { text_debug_a.set(hex_formatted.data.substr(0, 30));
bin_string += to_string_dec_uint(packet[i]); text_debug_b.set(hex_formatted.errors.substr(0, 30));
}
text_debug.set(bin_string); text_signature.set(packet.signature());
text_sats.set(to_string_dec_uint(packet.visible_sats()));
altitude = packet.GPS_altitude();
latitude = packet.GPS_latitude();
longitude = packet.GPS_longitude();
geopos.set_altitude(altitude);
geopos.set_lat(latitude);
geopos.set_lon(longitude);
/*if( logger ) { /*if( logger ) {
logger->on_packet(packet); logger->on_packet(packet);

View File

@ -27,6 +27,7 @@
#include "ui_receiver.hpp" #include "ui_receiver.hpp"
#include "ui_rssi.hpp" #include "ui_rssi.hpp"
#include "ui_channel.hpp" #include "ui_channel.hpp"
#include "ui_geomap.hpp"
#include "event_m0.hpp" #include "event_m0.hpp"
@ -67,7 +68,16 @@ public:
private: private:
//std::unique_ptr<SondeLogger> logger { }; //std::unique_ptr<SondeLogger> logger { };
uint32_t target_frequency_ { }; uint32_t target_frequency_ { 402000000 };
int32_t altitude { 0 };
float latitude { 0 };
float longitude { 0 };
Labels labels {
{ { 3 * 8, 5 * 16 }, "Signature:", Color::light_grey() },
{ { 0 * 8, 6 * 16 }, "Visible sats:", Color::light_grey() },
//{ { 4 * 8, 7 * 16 }, "Altitude:", Color::light_grey() },
};
FrequencyField field_frequency { FrequencyField field_frequency {
{ 0 * 8, 0 * 8 }, { 0 * 8, 0 * 8 },
@ -88,23 +98,44 @@ private:
{ 21 * 8, 0, 6 * 8, 4 }, { 21 * 8, 0, 6 * 8, 4 },
}; };
Text text_debug { Text text_debug_a {
{ 0, 32, 240, 16 }, { 0, 2 * 16, 240, 16 },
"Waiting for frame..." "Waiting for frame..."
}; };
Text text_debug_b {
{ 0, 3 * 16, 240, 16 },
"Waiting for frame..."
};
Text text_signature {
{ 13 * 8, 5 * 16, 240, 16 },
"..."
};
Text text_sats {
{ 13 * 8, 6 * 16, 240, 16 },
"..."
};
GeoPos geopos {
{ 0, 8 * 16 }
};
Button button_see_map {
{ 8 * 8, 12 * 16, 14 * 8, 3 * 16 },
"See on map"
};
MessageHandlerRegistration message_handler_packet { MessageHandlerRegistration message_handler_packet {
Message::ID::SondePacket, Message::ID::SondePacket,
[this](Message* const p) { [this](Message* const p) {
const auto message = static_cast<const SondePacketMessage*>(p); const auto message = static_cast<const SondePacketMessage*>(p);
//const sonde::Packet packet { message->type, message->packet }; const sonde::Packet packet { message->packet, message->type };
//this->on_packet(packet); this->on_packet(packet);
this->on_packet(message->packet);
} }
}; };
//void on_packet(const sonde::Packet& packet); //void on_packet(const sonde::Packet& packet);
void on_packet(const baseband::Packet& packet); void on_packet(const sonde::Packet& packet);
void set_target_frequency(const uint32_t new_value); void set_target_frequency(const uint32_t new_value);
uint32_t tuning_frequency() const; uint32_t tuning_frequency() const;
}; };

View File

@ -23,7 +23,6 @@
#include "proc_sonde.hpp" #include "proc_sonde.hpp"
#include "dsp_fir_taps.hpp" #include "dsp_fir_taps.hpp"
//#include "portapack_shared_memory.hpp"
#include "event_m4.hpp" #include "event_m4.hpp"

View File

@ -28,7 +28,7 @@
* Since the applied shift in ui_sonde.cpp is -fs/4 = -2457600/4 = -614400Hz to avoid the DC spike, the FSK signal ends up being * Since the applied shift in ui_sonde.cpp is -fs/4 = -2457600/4 = -614400Hz to avoid the DC spike, the FSK signal ends up being
* shifted by 614400 / 8 / 8 = 9600Hz. So decim_1_out should look like this: * shifted by 614400 / 8 / 8 = 9600Hz. So decim_1_out should look like this:
* *
* _______________|__/'\__________ * _______________|______/'\______
* -C A B C * -C A B C
* *
* A is the DC spike at 0Hz * A is the DC spike at 0Hz
@ -40,7 +40,7 @@
* ______________/'\______________ * ______________/'\______________
* -C D C * -C D C
* *
* A should have been filtered off ? * Anything unwanted (like A) should have been filtered off
* D is B around 0Hz now * D is B around 0Hz now
* *
* Then the clock_recovery function should be happy :) * Then the clock_recovery function should be happy :)
@ -113,18 +113,17 @@ private:
dsp::decimate::FIRC16xR16x32Decim8 decim_1 { }; dsp::decimate::FIRC16xR16x32Decim8 decim_1 { };
dsp::matched_filter::MatchedFilter mf { baseband::ais::square_taps_38k4_1t_p, 2 }; dsp::matched_filter::MatchedFilter mf { baseband::ais::square_taps_38k4_1t_p, 2 };
// AIS: 19200, 9600
clock_recovery::ClockRecovery<clock_recovery::FixedErrorFilter> clock_recovery_fsk_4800 { clock_recovery::ClockRecovery<clock_recovery::FixedErrorFilter> clock_recovery_fsk_4800 {
19200, 4800, { 0.0555f }, 19200, 9600, { 0.0555f },
[this](const float raw_symbol) { [this](const float raw_symbol) {
const uint_fast8_t sliced_symbol = (raw_symbol >= 0.0f) ? 1 : 0; const uint_fast8_t sliced_symbol = (raw_symbol >= 0.0f) ? 1 : 0;
this->packet_builder_fsk_4800_M10.execute(sliced_symbol); this->packet_builder_fsk_4800_M10.execute(sliced_symbol);
} }
}; };
PacketBuilder<BitPattern, NeverMatch, FixedLength> packet_builder_fsk_4800_M10 { PacketBuilder<BitPattern, NeverMatch, FixedLength> packet_builder_fsk_4800_M10 {
{ 0b11001100110011001010011001001100, 32, 1 }, { 0b00110011001100110101100110110011, 32, 1 },
{ }, { },
{ 50 }, // { 102 * 8 }, { 102 * 8 },
[this](const baseband::Packet& packet) { [this](const baseband::Packet& packet) {
const SondePacketMessage message { sonde::Packet::Type::M10, packet }; const SondePacketMessage message { sonde::Packet::Type::M10, packet };
shared_memory.application_queue.push(message); shared_memory.application_queue.push(message);

View File

@ -23,6 +23,10 @@
#include "string_format.hpp" #include "string_format.hpp"
size_t ManchesterBase::symbols_count() const {
return packet.size() / 2;
}
DecodedSymbol ManchesterDecoder::operator[](const size_t index) const { DecodedSymbol ManchesterDecoder::operator[](const size_t index) const {
const size_t encoded_index = index * 2; const size_t encoded_index = index * 2;
if( (encoded_index + 1) < packet.size() ) { if( (encoded_index + 1) < packet.size() ) {
@ -34,12 +38,19 @@ DecodedSymbol ManchesterDecoder::operator[](const size_t index) const {
} }
} }
size_t ManchesterDecoder::symbols_count() const { DecodedSymbol BiphaseMDecoder::operator[](const size_t index) const {
return packet.size() / 2; const size_t encoded_index = index * 2;
if( (encoded_index + 1) < packet.size() ) {
const auto value = packet[encoded_index + 0] != packet[encoded_index + 1];
const uint_fast8_t error = encoded_index ? (packet[encoded_index - 1] == packet[encoded_index + 0]) : 0;
return { value, error };
} else {
return { 0, 1 };
}
} }
FormattedSymbols format_symbols( FormattedSymbols format_symbols(
const ManchesterDecoder& decoder const ManchesterBase& decoder
) { ) {
const size_t payload_length_decoded = decoder.symbols_count(); const size_t payload_length_decoded = decoder.symbols_count();
const size_t payload_length_hex_characters = (payload_length_decoded + 3) / 4; const size_t payload_length_hex_characters = (payload_length_decoded + 3) / 4;

View File

@ -34,9 +34,9 @@ struct DecodedSymbol {
uint_fast8_t error; uint_fast8_t error;
}; };
class ManchesterDecoder { class ManchesterBase {
public: public:
constexpr ManchesterDecoder( constexpr ManchesterBase(
const baseband::Packet& packet, const baseband::Packet& packet,
const size_t sense = 0 const size_t sense = 0
) : packet { packet }, ) : packet { packet },
@ -44,15 +44,29 @@ public:
{ {
} }
DecodedSymbol operator[](const size_t index) const; virtual DecodedSymbol operator[](const size_t index) const = 0;
size_t symbols_count() const; virtual size_t symbols_count() const;
private: virtual ~ManchesterBase() { };
protected:
const baseband::Packet& packet; const baseband::Packet& packet;
const size_t sense; const size_t sense;
}; };
class ManchesterDecoder : public ManchesterBase {
public:
using ManchesterBase::ManchesterBase;
DecodedSymbol operator[](const size_t index) const;
};
class BiphaseMDecoder : public ManchesterBase {
public:
using ManchesterBase::ManchesterBase;
DecodedSymbol operator[](const size_t index) const;
};
template<typename T> template<typename T>
T operator|(const T& l, const DecodedSymbol& r) { T operator|(const T& l, const DecodedSymbol& r) {
return l | r.value; return l | r.value;
@ -64,7 +78,7 @@ struct FormattedSymbols {
}; };
FormattedSymbols format_symbols( FormattedSymbols format_symbols(
const ManchesterDecoder& decoder const ManchesterBase& decoder
); );
void manchester_encode(uint8_t * dest, uint8_t * src, const size_t length, const size_t sense = 0); void manchester_encode(uint8_t * dest, uint8_t * src, const size_t length, const size_t sense = 0);

View File

@ -42,6 +42,33 @@ Packet::Type Packet::type() const {
return type_; return type_;
} }
uint32_t Packet::visible_sats() const {
return reader_.read(30 * 8, 8);
}
uint32_t Packet::GPS_altitude() const {
return reader_.read(22 * 8, 32) / 1000;
}
float Packet::GPS_latitude() const {
return reader_.read(14 * 8, 32) / ((1ULL << 32) / 360.0);
}
float Packet::GPS_longitude() const {
return reader_.read(18 * 8, 32) / ((1ULL << 32) / 360.0);
}
std::string Packet::signature() const {
const auto header = reader_.read(0, 24);
if (header == 0x649F20)
return "M10";
else if (header == 0x648F20)
return "M2K2";
else
return symbols_formatted().data.substr(0, 6);
}
SN Packet::serial_number() const { SN Packet::serial_number() const {
if (type() == Type::M10) { if (type() == Type::M10) {
// See https://github.com/rs1729/RS/blob/master/m10/m10x.c line 606 // See https://github.com/rs1729/RS/blob/master/m10/m10x.c line 606

View File

@ -42,8 +42,8 @@ public:
}; };
Packet( Packet(
const Type type, const baseband::Packet& packet,
const baseband::Packet& packet const Type type
) : packet_ { packet }, ) : packet_ { packet },
decoder_ { packet_ }, decoder_ { packet_ },
reader_ { decoder_ }, reader_ { decoder_ },
@ -59,16 +59,21 @@ public:
Type type() const; Type type() const;
SN serial_number() const; SN serial_number() const;
uint32_t visible_sats() const;
uint32_t GPS_altitude() const;
float GPS_latitude() const;
float GPS_longitude() const;
std::string signature() const;
FormattedSymbols symbols_formatted() const; FormattedSymbols symbols_formatted() const;
bool crc_ok() const; bool crc_ok() const;
private: private:
using Reader = FieldReader<ManchesterDecoder, BitRemapNone>; using Reader = FieldReader<BiphaseMDecoder, BitRemapNone>;
const baseband::Packet packet_; const baseband::Packet packet_;
const ManchesterDecoder decoder_; const BiphaseMDecoder decoder_;
const Reader reader_; const Reader reader_;
const Type type_; const Type type_;

Binary file not shown.