POCSAG Processor Rewrite (#1437)

* WIP Refactoring
* WordExtractor building
* Fix buffer sizes and squelch execute
* Move impls to cpp file
* Baud indicator
* WIP new bit extractor
* New approach for bit extraction.
* Code fit and finish
* Fix case on button
* Cleanup
* Adjust rate miss threshold
* Fix count bits error calculation.
This commit is contained in:
Kyle Reed
2023-09-08 10:41:09 -07:00
committed by GitHub
parent 9525738118
commit 31e8019642
13 changed files with 648 additions and 534 deletions

View File

@@ -346,16 +346,19 @@ class POCSAGStatsMessage : public Message {
constexpr POCSAGStatsMessage(
uint32_t current_bits,
uint8_t current_frames,
bool has_sync)
bool has_sync,
uint16_t baud_rate)
: Message{ID::POCSAGStats},
current_bits{current_bits},
current_frames{current_frames},
has_sync{has_sync} {
has_sync{has_sync},
baud_rate{baud_rate} {
}
uint32_t current_bits = 0;
uint8_t current_frames = 0;
bool has_sync = false;
uint16_t baud_rate = 0;
};
class ACARSPacketMessage : public Message {

View File

@@ -412,7 +412,7 @@ bool pocsag_decode_batch(const POCSAGPacket& batch, POCSAGState& state) {
state.ascii_idx -= 7;
char ascii_char = (state.ascii_data >> state.ascii_idx) & 0x7F;
// Bottom's up (reverse the bits).
// Reverse the bits. (TODO: __RBIT?)
ascii_char = (ascii_char & 0xF0) >> 4 | (ascii_char & 0x0F) << 4; // 01234567 -> 45670123
ascii_char = (ascii_char & 0xCC) >> 2 | (ascii_char & 0x33) << 2; // 45670123 -> 67452301
ascii_char = (ascii_char & 0xAA) >> 2 | (ascii_char & 0x55); // 67452301 -> 76543210

View File

@@ -45,6 +45,10 @@ enum PacketFlag : uint32_t {
TOO_LONG
};
/* Number of codewords in a batch. */
constexpr uint8_t batch_size = 16;
using batch_t = std::array<uint32_t, batch_size>;
class POCSAGPacket {
public:
void set_timestamp(const Timestamp& value) {
@@ -55,16 +59,20 @@ class POCSAGPacket {
return timestamp_;
}
void set(const size_t index, const uint32_t data) {
if (index < 16)
void set(size_t index, uint32_t data) {
if (index < batch_size)
codewords[index] = data;
}
uint32_t operator[](const size_t index) const {
return (index < 16) ? codewords[index] : 0;
void set(const batch_t& batch) {
codewords = batch;
}
void set_bitrate(const uint16_t bitrate) {
uint32_t operator[](size_t index) const {
return (index < batch_size) ? codewords[index] : 0;
}
void set_bitrate(uint16_t bitrate) {
bitrate_ = bitrate;
}
@@ -72,7 +80,7 @@ class POCSAGPacket {
return bitrate_;
}
void set_flag(const PacketFlag flag) {
void set_flag(PacketFlag flag) {
flag_ = flag;
}
@@ -89,7 +97,7 @@ class POCSAGPacket {
private:
uint16_t bitrate_{0};
PacketFlag flag_{NORMAL};
std::array<uint32_t, 16> codewords{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
batch_t codewords{};
Timestamp timestamp_{};
};