Bitrate and flags for POCSAG packets, trim bugfix

This commit is contained in:
furrtek
2016-08-25 16:20:19 +02:00
parent 04cdafe387
commit 5de6349199
6 changed files with 121 additions and 76 deletions

View File

@@ -49,8 +49,9 @@ void POCSAGProcessor::execute(const buffer_c8_t& buffer) {
for (c = 0; c < 32; c++) {
// Bit = sign
const int32_t sample_int = audio.p[c] * 32768.0f;
const int32_t audio_sample = __SSAT(sample_int, 16);
const int32_t audio_sample = audio.p[c] * 32768.0f; // sample_int
//const int32_t audio_sample = __SSAT(sample_int, 16);
dcd_shreg <<= 1;
dcd_shreg |= (audio_sample < 0);
@@ -87,12 +88,13 @@ void POCSAGProcessor::execute(const buffer_c8_t& buffer) {
if (rx_data == POCSAG_SYNC) {
packet.clear();
rx_state = SYNC;
frame_counter = 0;
rx_bit = 0;
msg_timeout = 0;
last_rx_data = rx_data;
rx_state = SYNC;
} else if (rx_data == POCSAG_IDLE) {
rx_state = WAITING;
//rx_state = WAITING;
}
} else {
@@ -111,26 +113,38 @@ void POCSAGProcessor::execute(const buffer_c8_t& buffer) {
packet.set(frame_counter, rx_data);
if (rx_data == POCSAG_IDLE) {
//rx_state = WAITING; // DEBUG
if ((rx_data == POCSAG_IDLE) && (!(last_rx_data & 0x80000000))) {
// SYNC then IDLE always means end of message ?
packet.set_bitrate(pocsag::BitRate::FSK1200);
packet.set_flag(pocsag::PacketFlag::NORMAL);
packet.set_timestamp(Timestamp::now());
const POCSAGPacketMessage message(packet);
shared_memory.application_queue.push(message);
rx_state = WAITING;
} else {
if (frame_counter < 15) {
frame_counter++;
} else {
// DEBUG
// More than 17-1 codewords
packet.set_bitrate(pocsag::BitRate::FSK1200);
packet.set_flag(pocsag::PacketFlag::TOO_LONG);
packet.set_timestamp(Timestamp::now());
const POCSAGPacketMessage message(packet);
shared_memory.application_queue.push(message);
rx_state = WAITING;
}
}
last_rx_data = rx_data;
}
} else {
// DEBUG
packet.set_timestamp(Timestamp::now());
const POCSAGPacketMessage message(packet);
shared_memory.application_queue.push(message);
rx_state = WAITING; // Abort
// Timed out (no end of message received)
packet.set_bitrate(pocsag::BitRate::FSK1200);
packet.set_flag(pocsag::PacketFlag::TIMED_OUT);
packet.set_timestamp(Timestamp::now());
const POCSAGPacketMessage message(packet);
shared_memory.application_queue.push(message);
rx_state = WAITING;
}
break;

View File

@@ -27,7 +27,6 @@
#include "baseband_thread.hpp"
#include "rssi_thread.hpp"
#include "dsp_iir.hpp"
#include "dsp_decimate.hpp"
#include "dsp_demodulate.hpp"
@@ -49,11 +48,11 @@ private:
WAITING = 0,
PREAMBLE = 32,
SYNC = 64,
LOSING_SYNC = 65,
LOST_SYNC = 66,
ADDRESS = 67,
MESSAGE = 68,
END_OF_MESSAGE = 69
//LOSING_SYNC = 65,
//LOST_SYNC = 66,
//ADDRESS = 67,
//MESSAGE = 68,
//END_OF_MESSAGE = 69
};
static constexpr size_t baseband_fs = 1536000;
@@ -83,6 +82,7 @@ private:
uint32_t dcd_shreg;
uint32_t sphase;
uint32_t rx_data;
uint32_t last_rx_data;
uint32_t rx_bit;
bool configured = false;
rx_states rx_state;