pocsag.hh
#ifndef __SDR_POSAG_HH__
#define __SDR_POSAG_HH__
#include "node.hh"
namespace sdr {
class POCSAG: public Sink<uint8_t>
{
public:
class Message {
public:
Message();
Message(uint32_t addr, uint8_t func);
Message(const Message &other);
Message &operator=(const Message &other);
inline bool isEmpty() const { return _empty; }
inline uint32_t address() const { return _address; }
inline uint8_t function() const { return _function; }
inline uint32_t bits() const { return _bits; }
void addPayload(uint32_t word);
int estimateText() const;
int estimateNumeric() const;
std::string asText() const;
std::string asNumeric() const;
std::string asHex() const;
protected:
uint32_t _address;
uint8_t _function;
bool _empty;
uint32_t _bits;
std::vector<uint8_t> _payload;
};
protected:
typedef enum {
WAIT,
RECEIVE,
CHECK_CONTINUE
} State;
public:
POCSAG();
void config(const Config &src_cfg);
void process(const Buffer<uint8_t> &buffer, bool allow_overwrite);
virtual void handleMessages();
protected:
void _process_word(uint32_t word);
void _reset_message();
void _finish_message();
protected:
State _state;
uint64_t _bits;
uint8_t _bitcount;
uint8_t _slot;
Message _message;
std::list<Message> _queue;
};
class POCSAGDump: public POCSAG
{
public:
POCSAGDump(std::ostream &stream);
void handleMessages();
protected:
std::ostream &_stream;
};
}
#endif // __SDR_POSAG_HH__
sdr::POCSAG::_slot
uint8_t _slot
The current slot.
Definition: pocsag.hh:122
sdr::POCSAG::Message::estimateText
int estimateText() const
Retruns the "likelihood" that the message is a text message (actually a log-likelihood).
Definition: pocsag.cc:344
sdr::Config
A collection of configuration information that is send by a source to all connected sinks to properga...
Definition: node.hh:35
sdr::POCSAG::Message::asHex
std::string asHex() const
Dumps the payload.
Definition: pocsag.cc:334
sdr::POCSAG::_finish_message
void _finish_message()
Add the (non-empty) message to the queue.
Definition: pocsag.cc:136
sdr::POCSAGDump::handleMessages
void handleMessages()
Dumps the received messages.
Definition: pocsag.cc:158
sdr::POCSAG::Message::_address
uint32_t _address
The address of the message.
Definition: pocsag.hh:76
sdr::POCSAG::Message::asText
std::string asText() const
Decodes the message as a text message.
Definition: pocsag.cc:297
sdr::Sink
Typed sink.
Definition: node.hh:192
sdr
Definition: autocast.hh:8
sdr::POCSAG::Message::_empty
bool _empty
If true the message is empty.
Definition: pocsag.hh:80
sdr::POCSAG::Message::_payload
std::vector< uint8_t > _payload
The actual payload.
Definition: pocsag.hh:84
sdr::POCSAG::Message::_bits
uint32_t _bits
The number of payload bits in the message.
Definition: pocsag.hh:82
sdr::POCSAG::Message::estimateNumeric
int estimateNumeric() const
Retruns the "likelihood" that the message is a numeric message (actually a log-likelihood).
Definition: pocsag.cc:360
sdr::POCSAGDump::_stream
std::ostream & _stream
The output stream.
Definition: pocsag.hh:145
sdr::POCSAG::CHECK_CONTINUE
Wait for the sync word for continuation.
Definition: pocsag.hh:92
sdr::POCSAG::config
void config(const Config &src_cfg)
Needs to be implemented by any sub-type to check and perform the configuration of the node...
Definition: pocsag.cc:22
sdr::POCSAG::Message
A pocsag message.
Definition: pocsag.hh:37
sdr::POCSAG::Message::bits
uint32_t bits() const
Returns the number of data bits.
Definition: pocsag.hh:56
sdr::POCSAG::State
State
The possible states of the POGSAC receiver.
Definition: pocsag.hh:89
sdr::POCSAG::_bitcount
uint8_t _bitcount
The number of received bits.
Definition: pocsag.hh:120
sdr::POCSAG::_process_word
void _process_word(uint32_t word)
Process a POGSAC word.
Definition: pocsag.cc:99
sdr::POCSAG::POCSAG
POCSAG()
Constructor.
Definition: pocsag.cc:15
sdr::POCSAGDump::POCSAGDump
POCSAGDump(std::ostream &stream)
Constructor.
Definition: pocsag.cc:151
sdr::POCSAG::Message::addPayload
void addPayload(uint32_t word)
Adds some payload from the given POGSAC word.
Definition: pocsag.cc:283
sdr::POCSAG::handleMessages
virtual void handleMessages()
Can be overwritten by any other implementation to process the received messages stored in _queue...
Definition: pocsag.cc:143
sdr::POCSAG::Message::asNumeric
std::string asNumeric() const
Decodes the message as a numeric message.
Definition: pocsag.cc:317
sdr::POCSAG::Message::operator=
Message & operator=(const Message &other)
Assignment operator.
Definition: pocsag.cc:273
sdr::POCSAG::_state
State _state
The current state.
Definition: pocsag.hh:116
sdr::POCSAG::_reset_message
void _reset_message()
Clear the message.
Definition: pocsag.cc:131
sdr::POCSAG::WAIT
Wait for a sync word.
Definition: pocsag.hh:90
sdr::POCSAG::_bits
uint64_t _bits
The last received bits.
Definition: pocsag.hh:118
sdr::POCSAG::Message::_function
uint8_t _function
The function of the message.
Definition: pocsag.hh:78
sdr::POCSAG::_queue
std::list< Message > _queue
The completed messages.
Definition: pocsag.hh:126
sdr::POCSAG::Message::isEmpty
bool isEmpty() const
Retruns true if the message is empty (has no address).
Definition: pocsag.hh:50
sdr::POCSAGDump
A simple extention of the POCSAG node that prints the received messages to a std::ostream.
Definition: pocsag.hh:133
sdr::POCSAG::Message::Message
Message()
Empty constructor.
Definition: pocsag.cc:253
sdr::POCSAG::_message
Message _message
The current message.
Definition: pocsag.hh:124
sdr::POCSAG::process
void process(const Buffer< uint8_t > &buffer, bool allow_overwrite)
Needs to be implemented by any sub-type to process the received data.
Definition: pocsag.cc:41
sdr::POCSAG::Message::address
uint32_t address() const
Returns the address of the message.
Definition: pocsag.hh:52
sdr::POCSAG::RECEIVE
Receive data.
Definition: pocsag.hh:91
sdr::Buffer< uint8_t >
sdr::POCSAG
Implements a POCSAG decoder.
Definition: pocsag.hh:23