2015-07-08 15:39:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
*
|
|
|
|
* 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 __MESSAGE_H__
|
|
|
|
#define __MESSAGE_H__
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstddef>
|
2016-05-10 21:12:37 +00:00
|
|
|
#include <cstring>
|
2015-07-08 15:39:24 +00:00
|
|
|
#include <array>
|
|
|
|
#include <functional>
|
2016-04-27 19:16:37 +00:00
|
|
|
#include <algorithm>
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2015-12-08 23:15:51 +00:00
|
|
|
#include "baseband_packet.hpp"
|
2015-12-09 00:19:27 +00:00
|
|
|
#include "ert_packet.hpp"
|
2016-04-07 00:04:40 +00:00
|
|
|
#include "tpms_packet.hpp"
|
2016-01-03 20:46:21 +00:00
|
|
|
#include "dsp_fir_taps.hpp"
|
2016-01-29 23:57:20 +00:00
|
|
|
#include "dsp_iir.hpp"
|
2016-01-06 19:34:41 +00:00
|
|
|
#include "fifo.hpp"
|
2015-12-07 20:35:05 +00:00
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
#include "utility.hpp"
|
|
|
|
|
2015-11-09 19:57:25 +00:00
|
|
|
#include "ch.h"
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
class Message {
|
|
|
|
public:
|
2016-01-31 01:30:54 +00:00
|
|
|
static constexpr size_t MAX_SIZE = 512;
|
2015-08-20 20:13:12 +00:00
|
|
|
|
|
|
|
enum class ID : uint32_t {
|
2015-07-08 15:39:24 +00:00
|
|
|
/* Assign consecutive IDs. IDs are used to index array. */
|
|
|
|
RSSIStatistics = 0,
|
|
|
|
BasebandStatistics = 1,
|
|
|
|
ChannelStatistics = 2,
|
2016-01-06 19:36:57 +00:00
|
|
|
DisplayFrameSync = 3,
|
2015-07-08 15:39:24 +00:00
|
|
|
AudioStatistics = 4,
|
2015-11-10 23:19:56 +00:00
|
|
|
TPMSPacket = 6,
|
2015-08-21 01:03:49 +00:00
|
|
|
Shutdown = 8,
|
2015-11-10 22:07:07 +00:00
|
|
|
AISPacket = 7,
|
2015-12-01 19:24:48 +00:00
|
|
|
ERTPacket = 9,
|
2016-01-03 20:05:47 +00:00
|
|
|
UpdateSpectrum = 10,
|
2016-01-03 20:46:21 +00:00
|
|
|
NBFMConfigure = 11,
|
2016-01-03 21:38:55 +00:00
|
|
|
WFMConfigure = 12,
|
2016-01-03 22:31:39 +00:00
|
|
|
AMConfigure = 13,
|
2016-01-06 20:10:30 +00:00
|
|
|
ChannelSpectrumConfig = 14,
|
2016-01-10 18:42:20 +00:00
|
|
|
SpectrumStreamingConfig = 15,
|
2016-01-28 04:33:54 +00:00
|
|
|
DisplaySleep = 16,
|
2016-04-23 21:54:15 +00:00
|
|
|
CaptureConfig = 17,
|
2016-06-21 19:05:55 +00:00
|
|
|
CaptureThreadDone = 18,
|
2015-07-08 15:39:24 +00:00
|
|
|
MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr Message(
|
|
|
|
ID id
|
2015-08-20 20:13:12 +00:00
|
|
|
) : id { id }
|
2015-07-08 15:39:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const ID id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RSSIStatistics {
|
|
|
|
uint32_t accumulator { 0 };
|
|
|
|
uint32_t min { 0 };
|
|
|
|
uint32_t max { 0 };
|
|
|
|
uint32_t count { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
class RSSIStatisticsMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr RSSIStatisticsMessage(
|
2015-11-11 17:35:28 +00:00
|
|
|
const RSSIStatistics& statistics
|
|
|
|
) : Message { ID::RSSIStatistics },
|
|
|
|
statistics { statistics }
|
2015-07-08 15:39:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
RSSIStatistics statistics;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BasebandStatistics {
|
|
|
|
uint32_t idle_ticks { 0 };
|
2015-10-14 17:44:20 +00:00
|
|
|
uint32_t main_ticks { 0 };
|
|
|
|
uint32_t rssi_ticks { 0 };
|
2015-07-08 15:39:24 +00:00
|
|
|
uint32_t baseband_ticks { 0 };
|
|
|
|
bool saturation { false };
|
|
|
|
};
|
|
|
|
|
|
|
|
class BasebandStatisticsMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr BasebandStatisticsMessage(
|
2015-11-11 17:35:28 +00:00
|
|
|
const BasebandStatistics& statistics
|
|
|
|
) : Message { ID::BasebandStatistics },
|
|
|
|
statistics { statistics }
|
2015-07-08 15:39:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BasebandStatistics statistics;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ChannelStatistics {
|
|
|
|
int32_t max_db;
|
|
|
|
size_t count;
|
|
|
|
|
|
|
|
constexpr ChannelStatistics(
|
2015-11-11 17:16:20 +00:00
|
|
|
int32_t max_db = -120,
|
|
|
|
size_t count = 0
|
2015-07-08 15:39:24 +00:00
|
|
|
) : max_db { max_db },
|
|
|
|
count { count }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ChannelStatisticsMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr ChannelStatisticsMessage(
|
2015-12-10 20:25:11 +00:00
|
|
|
const ChannelStatistics& statistics
|
|
|
|
) : Message { ID::ChannelStatistics },
|
|
|
|
statistics { statistics }
|
2015-07-08 15:39:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ChannelStatistics statistics;
|
|
|
|
};
|
|
|
|
|
2016-01-06 19:36:57 +00:00
|
|
|
class DisplayFrameSyncMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr DisplayFrameSyncMessage(
|
|
|
|
) : Message { ID::DisplayFrameSync }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
struct AudioStatistics {
|
|
|
|
int32_t rms_db;
|
|
|
|
int32_t max_db;
|
|
|
|
size_t count;
|
|
|
|
|
|
|
|
constexpr AudioStatistics(
|
|
|
|
) : rms_db { -120 },
|
|
|
|
max_db { -120 },
|
|
|
|
count { 0 }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr AudioStatistics(
|
|
|
|
int32_t rms_db,
|
|
|
|
int32_t max_db,
|
|
|
|
size_t count
|
|
|
|
) : rms_db { rms_db },
|
|
|
|
max_db { max_db },
|
|
|
|
count { count }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-01-28 04:33:54 +00:00
|
|
|
class DisplaySleepMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr DisplaySleepMessage(
|
|
|
|
) : Message { ID::DisplaySleep }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
class AudioStatisticsMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr AudioStatisticsMessage(
|
2015-12-10 20:25:11 +00:00
|
|
|
const AudioStatistics& statistics
|
2015-07-08 15:39:24 +00:00
|
|
|
) : Message { ID::AudioStatistics },
|
2015-12-10 20:25:11 +00:00
|
|
|
statistics { statistics }
|
2015-07-08 15:39:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioStatistics statistics;
|
|
|
|
};
|
|
|
|
|
2016-01-10 18:42:20 +00:00
|
|
|
class SpectrumStreamingConfigMessage : public Message {
|
|
|
|
public:
|
|
|
|
enum class Mode : uint32_t {
|
|
|
|
Stopped = 0,
|
|
|
|
Running = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr SpectrumStreamingConfigMessage(
|
|
|
|
Mode mode
|
|
|
|
) : Message { ID::SpectrumStreamingConfig },
|
|
|
|
mode { mode }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Mode mode { Mode::Stopped };
|
|
|
|
};
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
struct ChannelSpectrum {
|
2015-08-20 20:13:12 +00:00
|
|
|
std::array<uint8_t, 256> db { { 0 } };
|
2016-01-10 18:42:20 +00:00
|
|
|
uint32_t sampling_rate { 0 };
|
|
|
|
uint32_t channel_filter_pass_frequency { 0 };
|
|
|
|
uint32_t channel_filter_stop_frequency { 0 };
|
2016-01-06 20:10:30 +00:00
|
|
|
};
|
|
|
|
|
2016-02-10 18:41:06 +00:00
|
|
|
using ChannelSpectrumFIFO = FIFO<ChannelSpectrum>;
|
2016-01-06 20:10:30 +00:00
|
|
|
|
|
|
|
class ChannelSpectrumConfigMessage : public Message {
|
|
|
|
public:
|
2016-02-10 18:41:06 +00:00
|
|
|
static constexpr size_t fifo_k = 2;
|
|
|
|
|
2016-01-06 20:10:30 +00:00
|
|
|
constexpr ChannelSpectrumConfigMessage(
|
|
|
|
ChannelSpectrumFIFO* fifo
|
|
|
|
) : Message { ID::ChannelSpectrumConfig },
|
|
|
|
fifo { fifo }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ChannelSpectrumFIFO* fifo { nullptr };
|
2015-07-08 15:39:24 +00:00
|
|
|
};
|
|
|
|
|
2015-11-10 22:07:07 +00:00
|
|
|
class AISPacketMessage : public Message {
|
2015-07-08 15:39:24 +00:00
|
|
|
public:
|
2015-11-11 17:16:20 +00:00
|
|
|
constexpr AISPacketMessage(
|
2015-12-10 23:13:07 +00:00
|
|
|
const baseband::Packet& packet
|
|
|
|
) : Message { ID::AISPacket },
|
|
|
|
packet { packet }
|
2015-07-08 15:39:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-08 23:15:51 +00:00
|
|
|
baseband::Packet packet;
|
2015-11-10 23:19:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TPMSPacketMessage : public Message {
|
|
|
|
public:
|
2015-11-11 17:16:20 +00:00
|
|
|
constexpr TPMSPacketMessage(
|
2016-04-07 00:04:40 +00:00
|
|
|
const tpms::SignalType signal_type,
|
2015-12-10 23:13:07 +00:00
|
|
|
const baseband::Packet& packet
|
|
|
|
) : Message { ID::TPMSPacket },
|
2016-04-07 00:04:40 +00:00
|
|
|
signal_type { signal_type },
|
2015-12-10 23:13:07 +00:00
|
|
|
packet { packet }
|
2015-11-10 23:19:56 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-04-07 00:04:40 +00:00
|
|
|
tpms::SignalType signal_type;
|
2015-12-08 23:15:51 +00:00
|
|
|
baseband::Packet packet;
|
2015-11-10 23:19:56 +00:00
|
|
|
};
|
|
|
|
|
2015-08-21 01:03:49 +00:00
|
|
|
class ShutdownMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr ShutdownMessage(
|
|
|
|
) : Message { ID::Shutdown }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-12-08 23:15:51 +00:00
|
|
|
class ERTPacketMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr ERTPacketMessage(
|
2015-12-10 23:13:07 +00:00
|
|
|
const ert::Packet::Type type,
|
|
|
|
const baseband::Packet& packet
|
|
|
|
) : Message { ID::ERTPacket },
|
|
|
|
type { type },
|
|
|
|
packet { packet }
|
2015-12-08 23:15:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-10 23:13:07 +00:00
|
|
|
ert::Packet::Type type;
|
2015-12-01 19:24:48 +00:00
|
|
|
|
2015-12-08 23:15:51 +00:00
|
|
|
baseband::Packet packet;
|
2015-12-01 19:24:48 +00:00
|
|
|
};
|
|
|
|
|
2016-01-03 20:05:47 +00:00
|
|
|
class UpdateSpectrumMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr UpdateSpectrumMessage(
|
|
|
|
) : Message { ID::UpdateSpectrum }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-01-03 20:46:21 +00:00
|
|
|
class NBFMConfigureMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr NBFMConfigureMessage(
|
2016-01-04 00:21:17 +00:00
|
|
|
const fir_taps_real<24> decim_0_filter,
|
|
|
|
const fir_taps_real<32> decim_1_filter,
|
|
|
|
const fir_taps_real<32> channel_filter,
|
2016-01-30 03:23:30 +00:00
|
|
|
const size_t channel_decimation,
|
2016-01-29 23:57:20 +00:00
|
|
|
const size_t deviation,
|
|
|
|
const iir_biquad_config_t audio_hpf_config,
|
|
|
|
const iir_biquad_config_t audio_deemph_config
|
2016-01-03 20:46:21 +00:00
|
|
|
) : Message { ID::NBFMConfigure },
|
2016-01-04 00:28:09 +00:00
|
|
|
decim_0_filter(decim_0_filter),
|
|
|
|
decim_1_filter(decim_1_filter),
|
|
|
|
channel_filter(channel_filter),
|
2016-01-30 03:23:30 +00:00
|
|
|
channel_decimation { channel_decimation },
|
2016-01-29 23:57:20 +00:00
|
|
|
deviation { deviation },
|
2016-02-04 01:59:46 +00:00
|
|
|
audio_hpf_config(audio_hpf_config),
|
|
|
|
audio_deemph_config(audio_deemph_config)
|
2016-01-03 20:46:21 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const fir_taps_real<24> decim_0_filter;
|
|
|
|
const fir_taps_real<32> decim_1_filter;
|
|
|
|
const fir_taps_real<32> channel_filter;
|
2016-01-30 03:23:30 +00:00
|
|
|
const size_t channel_decimation;
|
2016-01-03 20:46:21 +00:00
|
|
|
const size_t deviation;
|
2016-01-29 23:57:20 +00:00
|
|
|
const iir_biquad_config_t audio_hpf_config;
|
|
|
|
const iir_biquad_config_t audio_deemph_config;
|
2016-01-03 20:46:21 +00:00
|
|
|
};
|
|
|
|
|
2016-01-03 21:38:55 +00:00
|
|
|
class WFMConfigureMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr WFMConfigureMessage(
|
2016-01-04 00:21:17 +00:00
|
|
|
const fir_taps_real<24> decim_0_filter,
|
|
|
|
const fir_taps_real<16> decim_1_filter,
|
|
|
|
const fir_taps_real<64> audio_filter,
|
2016-01-29 23:57:20 +00:00
|
|
|
const size_t deviation,
|
|
|
|
const iir_biquad_config_t audio_hpf_config,
|
|
|
|
const iir_biquad_config_t audio_deemph_config
|
2016-01-03 21:38:55 +00:00
|
|
|
) : Message { ID::WFMConfigure },
|
2016-01-04 00:28:09 +00:00
|
|
|
decim_0_filter(decim_0_filter),
|
|
|
|
decim_1_filter(decim_1_filter),
|
|
|
|
audio_filter(audio_filter),
|
2016-01-29 23:57:20 +00:00
|
|
|
deviation { deviation },
|
2016-02-04 01:59:46 +00:00
|
|
|
audio_hpf_config(audio_hpf_config),
|
|
|
|
audio_deemph_config(audio_deemph_config)
|
2016-01-03 21:38:55 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const fir_taps_real<24> decim_0_filter;
|
|
|
|
const fir_taps_real<16> decim_1_filter;
|
|
|
|
const fir_taps_real<64> audio_filter;
|
|
|
|
const size_t deviation;
|
2016-01-29 23:57:20 +00:00
|
|
|
const iir_biquad_config_t audio_hpf_config;
|
|
|
|
const iir_biquad_config_t audio_deemph_config;
|
2016-01-03 21:38:55 +00:00
|
|
|
};
|
|
|
|
|
2016-01-03 22:31:39 +00:00
|
|
|
class AMConfigureMessage : public Message {
|
|
|
|
public:
|
2016-01-31 02:02:28 +00:00
|
|
|
enum class Modulation : int32_t {
|
2016-01-31 02:17:29 +00:00
|
|
|
DSB = 0,
|
2016-01-31 02:02:28 +00:00
|
|
|
SSB = 1,
|
|
|
|
};
|
|
|
|
|
2016-01-03 22:31:39 +00:00
|
|
|
constexpr AMConfigureMessage(
|
2016-01-04 00:21:17 +00:00
|
|
|
const fir_taps_real<24> decim_0_filter,
|
|
|
|
const fir_taps_real<32> decim_1_filter,
|
2016-01-31 01:28:11 +00:00
|
|
|
const fir_taps_real<32> decim_2_filter,
|
2016-01-31 01:30:54 +00:00
|
|
|
const fir_taps_complex<64> channel_filter,
|
2016-01-31 02:02:28 +00:00
|
|
|
const Modulation modulation,
|
2016-01-29 23:57:20 +00:00
|
|
|
const iir_biquad_config_t audio_hpf_config
|
2016-01-03 22:31:39 +00:00
|
|
|
) : Message { ID::AMConfigure },
|
2016-01-04 00:28:09 +00:00
|
|
|
decim_0_filter(decim_0_filter),
|
|
|
|
decim_1_filter(decim_1_filter),
|
2016-01-31 01:28:11 +00:00
|
|
|
decim_2_filter(decim_2_filter),
|
2016-01-29 23:57:20 +00:00
|
|
|
channel_filter(channel_filter),
|
2016-01-31 02:02:28 +00:00
|
|
|
modulation { modulation },
|
2016-02-04 01:59:46 +00:00
|
|
|
audio_hpf_config(audio_hpf_config)
|
2016-01-03 22:31:39 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const fir_taps_real<24> decim_0_filter;
|
|
|
|
const fir_taps_real<32> decim_1_filter;
|
2016-01-31 01:28:11 +00:00
|
|
|
const fir_taps_real<32> decim_2_filter;
|
2016-01-31 01:30:54 +00:00
|
|
|
const fir_taps_complex<64> channel_filter;
|
2016-01-31 02:02:28 +00:00
|
|
|
const Modulation modulation;
|
2016-01-29 23:57:20 +00:00
|
|
|
const iir_biquad_config_t audio_hpf_config;
|
2016-01-03 22:31:39 +00:00
|
|
|
};
|
|
|
|
|
2016-05-10 21:12:37 +00:00
|
|
|
// TODO: Put this somewhere else, or at least the implementation part.
|
|
|
|
class StreamBuffer {
|
|
|
|
uint8_t* data_;
|
|
|
|
size_t used_;
|
|
|
|
size_t capacity_;
|
|
|
|
|
|
|
|
public:
|
|
|
|
constexpr StreamBuffer(
|
|
|
|
void* const data = nullptr,
|
|
|
|
const size_t capacity = 0
|
|
|
|
) : data_ { static_cast<uint8_t*>(data) },
|
|
|
|
used_ { 0 },
|
|
|
|
capacity_ { capacity }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t write(const void* p, const size_t count) {
|
|
|
|
const auto copy_size = std::min(capacity_ - used_, count);
|
|
|
|
memcpy(&data_[used_], p, copy_size);
|
|
|
|
used_ += copy_size;
|
|
|
|
return copy_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_full() const {
|
|
|
|
return used_ >= capacity_;
|
|
|
|
}
|
|
|
|
|
|
|
|
const void* data() const {
|
|
|
|
return data_;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t size() const {
|
|
|
|
return used_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void empty() {
|
|
|
|
used_ = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-04-23 21:54:15 +00:00
|
|
|
struct CaptureConfig {
|
2016-05-10 21:12:37 +00:00
|
|
|
const size_t write_size;
|
|
|
|
const size_t buffer_count;
|
2016-04-27 17:40:50 +00:00
|
|
|
uint64_t baseband_bytes_received;
|
|
|
|
uint64_t baseband_bytes_dropped;
|
2016-05-10 21:12:37 +00:00
|
|
|
FIFO<StreamBuffer*>* fifo_buffers_empty;
|
|
|
|
FIFO<StreamBuffer*>* fifo_buffers_full;
|
2016-04-27 05:26:30 +00:00
|
|
|
|
|
|
|
constexpr CaptureConfig(
|
2016-05-10 21:12:37 +00:00
|
|
|
const size_t write_size,
|
|
|
|
const size_t buffer_count
|
|
|
|
) : write_size { write_size },
|
|
|
|
buffer_count { buffer_count },
|
2016-04-27 17:40:50 +00:00
|
|
|
baseband_bytes_received { 0 },
|
|
|
|
baseband_bytes_dropped { 0 },
|
2016-05-10 21:12:37 +00:00
|
|
|
fifo_buffers_empty { nullptr },
|
|
|
|
fifo_buffers_full { nullptr }
|
2016-04-27 05:26:30 +00:00
|
|
|
{
|
|
|
|
}
|
2016-04-27 19:04:02 +00:00
|
|
|
|
|
|
|
size_t dropped_percent() const {
|
2016-04-27 19:16:37 +00:00
|
|
|
if( baseband_bytes_dropped == 0 ) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
const size_t percent = baseband_bytes_dropped * 100U / baseband_bytes_received;
|
|
|
|
return std::max(1U, percent);
|
|
|
|
}
|
2016-04-27 19:04:02 +00:00
|
|
|
}
|
2016-04-23 21:54:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CaptureConfigMessage : public Message {
|
|
|
|
public:
|
|
|
|
constexpr CaptureConfigMessage(
|
|
|
|
CaptureConfig* const config
|
|
|
|
) : Message { ID::CaptureConfig },
|
|
|
|
config { config }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CaptureConfig* const config;
|
|
|
|
};
|
|
|
|
|
2016-06-21 19:05:55 +00:00
|
|
|
class CaptureThreadDoneMessage : public Message {
|
2016-06-21 18:04:10 +00:00
|
|
|
public:
|
2016-06-21 19:05:55 +00:00
|
|
|
constexpr CaptureThreadDoneMessage(
|
2016-06-21 18:53:07 +00:00
|
|
|
uint32_t error = 0
|
2016-06-21 19:05:55 +00:00
|
|
|
) : Message { ID::CaptureThreadDone },
|
2016-06-21 18:04:10 +00:00
|
|
|
error { error }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t error;
|
|
|
|
};
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
#endif/*__MESSAGE_H__*/
|