add lead-in symbols

This commit is contained in:
Harald Welte 2015-04-01 19:26:34 +02:00
parent efc57bf72d
commit 0315330e35
4 changed files with 21 additions and 11 deletions

View File

@ -4,7 +4,13 @@
<key>AdsbEncoder</key>
<category>adsbtx</category>
<import>import adsbtx</import>
<make>adsbtx.AdsbEncoder()</make>
<make>adsbtx.AdsbEncoder($num_lead_in_syms)</make>
<param>
<name>Number of Lead-In Symbols</name>
<key>num_lead_in_syms</key>
<value>256</value>
<type>int</type>
</param>
<sink>
<name>pdus</name>
<type>message</type>

View File

@ -40,7 +40,7 @@ namespace gr {
public:
typedef boost::shared_ptr<AdsbEncoder> sptr;
static sptr make(void);
static sptr make(unsigned int num_lead_in_syms);
};
} // namespace adsbtx

View File

@ -50,32 +50,32 @@ namespace gr {
namespace adsbtx {
AdsbEncoder::sptr
AdsbEncoder::make()
AdsbEncoder::make(unsigned int num_lead_in_syms)
{
return gnuradio::get_initial_sptr
(new AdsbEncoder_impl());
(new AdsbEncoder_impl(num_lead_in_syms));
}
/*
* The private constructor
*/
AdsbEncoder_impl::AdsbEncoder_impl()
AdsbEncoder_impl::AdsbEncoder_impl(unsigned int num_lead_in_syms)
: block("ADS-B Payload to Symbols Encoder",
io_signature::make(0, 0, 0),
io_signature::make(0, 0, 0))
io_signature::make(0, 0, 0)),
d_num_lead_in_syms(num_lead_in_syms)
{
message_port_register_out(pmt::mp("pdus"));
message_port_register_in(pmt::mp("pdus"));
set_msg_handler(pmt::mp("pdus"), boost::bind(&AdsbEncoder_impl::handle_msg, this, _1));
#if 0
if (d_num_lead_in_syms) {
/* round up to the next byte boundary */
if (d_num_lead_in_syms % 8)
d_num_lead_in_syms += d_num_lead_in_syms % 8;
/* empty vector for lead-in */
d_lead_in_bytes = pmt::make_u8vector(d_num_lead_in_syms/8, 0);
d_lead_in_bytes = pmt::make_u8vector(d_num_lead_in_syms, 0);
}
#endif
}
@ -231,6 +231,9 @@ AdsbEncoder_impl::handle_msg(pmt::pmt_t pdu)
if (rc < 0)
return;
if (d_lead_in_bytes)
message_port_pub(pmt::mp("pdus"), pmt::cons(meta, d_lead_in_bytes));
pmt::pmt_t outpdu_bytes = make_pdu_vector(blocks::pdu::byte_t, outbuf, rc);
message_port_pub(pmt::mp("pdus"), pmt::cons(meta, outpdu_bytes));

View File

@ -32,10 +32,11 @@ namespace gr {
class AdsbEncoder_impl : public AdsbEncoder
{
private:
unsigned int d_num_lead_in_syms;
pmt::pmt_t d_lead_in_bytes;
public:
AdsbEncoder_impl(void);
AdsbEncoder_impl(unsigned int num_lead_in_syms);
~AdsbEncoder_impl(void);
// Where all the action really happens