add packet_pad, string_to_blob, pdu_to_blob and periodic_msg_source
This commit is contained in:
@@ -20,6 +20,10 @@
|
|||||||
install(FILES
|
install(FILES
|
||||||
ccs_burst_tagger.xml
|
ccs_burst_tagger.xml
|
||||||
ccs_packet_dropper.xml
|
ccs_packet_dropper.xml
|
||||||
|
ccs_packet_pad.xml
|
||||||
|
ccs_pdu_to_blob.xml
|
||||||
|
ccs_periodic_msg_source.xml
|
||||||
|
ccs_string_to_blob.xml
|
||||||
ccs_wireshark_connector.xml
|
ccs_wireshark_connector.xml
|
||||||
DESTINATION share/gnuradio/grc/blocks
|
DESTINATION share/gnuradio/grc/blocks
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<block>
|
||||||
|
<name>Packet Pad</name>
|
||||||
|
<key>ccs_packet_pad</key>
|
||||||
|
<category>CCS</category>
|
||||||
|
<import>import ccs</import>
|
||||||
|
<make>ccs.packet_pad($debug, $pad_front, $pad_tail)</make>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Debug</name>
|
||||||
|
<key>debug</key>
|
||||||
|
<value>False</value>
|
||||||
|
<type>bool</type>
|
||||||
|
|
||||||
|
<option>
|
||||||
|
<name>Enable</name>
|
||||||
|
<key>True</key>
|
||||||
|
</option>
|
||||||
|
<option>
|
||||||
|
<name>Disable</name>
|
||||||
|
<key>False</key>
|
||||||
|
</option>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Pad Front</name>
|
||||||
|
<key>pad_front</key>
|
||||||
|
<value>0</value>
|
||||||
|
<type>int</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Pad Tail</name>
|
||||||
|
<key>pad_tail</key>
|
||||||
|
<value>0</value>
|
||||||
|
<type>int</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<sink>
|
||||||
|
<name>in</name>
|
||||||
|
<type>complex</type>
|
||||||
|
<nports>1</nports>
|
||||||
|
</sink>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
<name>out</name>
|
||||||
|
<type>complex</type>
|
||||||
|
<nports>1</nports>
|
||||||
|
</source>
|
||||||
|
|
||||||
|
</block>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<block>
|
||||||
|
<name>PDU to Blob</name>
|
||||||
|
<key>ccs_pdu_to_blob</key>
|
||||||
|
<category>CCS</category>
|
||||||
|
<import>import ccs</import>
|
||||||
|
<make>ccs.pdu_to_blob()</make>
|
||||||
|
|
||||||
|
<sink>
|
||||||
|
<name>in</name>
|
||||||
|
<type>message</type>
|
||||||
|
</sink>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
<name>out</name>
|
||||||
|
<type>message</type>
|
||||||
|
</source>
|
||||||
|
</block>
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<block>
|
||||||
|
<name>Periodic Message Source</name>
|
||||||
|
<key>ccs_periodic_msg_source</key>
|
||||||
|
<category>CCS</category>
|
||||||
|
<import>import ccs</import>
|
||||||
|
<make>ccs..periodic_msg_source($msg, $interval, $num, $debug)</make>
|
||||||
|
<param>
|
||||||
|
<name>Message PMT</name>
|
||||||
|
<key>msg</key>
|
||||||
|
<value>pmt.pmt_intern("Hello World!")</value>
|
||||||
|
<type>raw</type>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Period (ms)</name>
|
||||||
|
<key>interval</key>
|
||||||
|
<value>1000</value>
|
||||||
|
<type>real</type>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Debug</name>
|
||||||
|
<key>debug</key>
|
||||||
|
<value>False</value>
|
||||||
|
<type>bool</type>
|
||||||
|
<option>
|
||||||
|
<name>Enable</name>
|
||||||
|
<key>True</key>
|
||||||
|
</option>
|
||||||
|
<option>
|
||||||
|
<name>Disable</name>
|
||||||
|
<key>False</key>
|
||||||
|
</option>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Num Messages</name>
|
||||||
|
<key>num</key>
|
||||||
|
<value>-1</value>
|
||||||
|
<type>int</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
<name>out</name>
|
||||||
|
<type>message</type>
|
||||||
|
<optional>1</optional>
|
||||||
|
</source>
|
||||||
|
</block>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<block>
|
||||||
|
<name>String to Blob</name>
|
||||||
|
<key>ccs_string_to_blob</key>
|
||||||
|
<category>CCS</category>
|
||||||
|
<import>import cccs</import>
|
||||||
|
<make>ccs.string_to_blob()</make>
|
||||||
|
|
||||||
|
<sink>
|
||||||
|
<name>in</name>
|
||||||
|
<type>message</type>
|
||||||
|
</sink>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
<name>out</name>
|
||||||
|
<type>message</type>
|
||||||
|
</source>
|
||||||
|
</block>
|
||||||
@@ -24,6 +24,10 @@ install(FILES
|
|||||||
api.h
|
api.h
|
||||||
burst_tagger.h
|
burst_tagger.h
|
||||||
packet_dropper.h
|
packet_dropper.h
|
||||||
|
packet_pad.h
|
||||||
|
pdu_to_blob.h
|
||||||
|
periodic_msg_source.h
|
||||||
|
string_to_blob.h
|
||||||
wireshark_connector.h
|
wireshark_connector.h
|
||||||
DESTINATION include/ccs
|
DESTINATION include/ccs
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDED_CCS_PACKET_PAD_H
|
||||||
|
#define INCLUDED_CCS_PACKET_PAD_H
|
||||||
|
|
||||||
|
#include <ccs/api.h>
|
||||||
|
#include <gnuradio/block.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace ccs {
|
||||||
|
|
||||||
|
class CCS_API packet_pad : virtual public gr::block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<packet_pad> sptr;
|
||||||
|
static sptr make(bool debug = false, int pad_front = 0, int pad_tail = 0);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ccs
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_CCS_PACKET_PAD_H */
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDED_CCS_PDU_TO_BLOB_H
|
||||||
|
#define INCLUDED_CCS_PDU_TO_BLOB_H
|
||||||
|
|
||||||
|
#include <ccs/api.h>
|
||||||
|
#include <gnuradio/block.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace ccs {
|
||||||
|
|
||||||
|
class CCS_API pdu_to_blob : virtual public gr::block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<pdu_to_blob> sptr;
|
||||||
|
static sptr make();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ccs
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_CCS_PDU_TO_BLOB_H */
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDED_CCS_PERIODIC_MSG_SOURCE_H
|
||||||
|
#define INCLUDED_CCS_PERIODIC_MSG_SOURCE_H
|
||||||
|
|
||||||
|
#include <ccs/api.h>
|
||||||
|
#include <gnuradio/block.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace ccs {
|
||||||
|
|
||||||
|
class CCS_API periodic_msg_source : virtual public gr::block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<periodic_msg_source> sptr;
|
||||||
|
static sptr make(pmt::pmt_t msg, float interval, int num_msg = -1, bool debug = false);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ccs
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_CCS_PERIODIC_MSG_SOURCE */
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef INCLUDED_CCS_STRING_TO_BLOB_H
|
||||||
|
#define INCLUDED_CCS_STRING_TO_BLOB_H
|
||||||
|
|
||||||
|
#include <ccs/api.h>
|
||||||
|
#include <gnuradio/block.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace ccs {
|
||||||
|
|
||||||
|
class CCS_API string_to_blob : virtual public gr::block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<string_to_blob> sptr;
|
||||||
|
static sptr make();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ccs
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_CCS_STRING_TO_BLOB_H */
|
||||||
@@ -28,6 +28,10 @@ link_directories(${Boost_LIBRARY_DIRS})
|
|||||||
list(APPEND ccs_sources
|
list(APPEND ccs_sources
|
||||||
burst_tagger_impl.cc
|
burst_tagger_impl.cc
|
||||||
packet_dropper_impl.cc
|
packet_dropper_impl.cc
|
||||||
|
packet_pad_impl.cc
|
||||||
|
pdu_to_blob_impl.cc
|
||||||
|
periodic_msg_source_impl.cc
|
||||||
|
string_to_blob_impl.cc
|
||||||
wireshark_connector_impl.cc
|
wireshark_connector_impl.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,237 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <ccs/packet_pad.h>
|
||||||
|
#include <gnuradio/io_signature.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace gr::ccs;
|
||||||
|
|
||||||
|
|
||||||
|
class packet_pad_impl : public packet_pad {
|
||||||
|
|
||||||
|
static const int SYMBOL_LENGTH = 80;
|
||||||
|
|
||||||
|
#define dout d_debug && std::cout
|
||||||
|
|
||||||
|
public:
|
||||||
|
packet_pad_impl(bool debug, int pad_front, int pad_tail) : block("packet_pad",
|
||||||
|
gr::io_signature::make(1, 1, sizeof(gr_complex)),
|
||||||
|
gr::io_signature::make(1, 1, sizeof(gr_complex))),
|
||||||
|
d_debug(debug), d_pad_front(pad_front),
|
||||||
|
d_pad_tail(pad_tail), d_front_left(0),
|
||||||
|
d_tail_left(0), d_frame_left(0), d_state(IDLE) {
|
||||||
|
|
||||||
|
assert(pad_front >= 0);
|
||||||
|
assert(pad_tail >= 0);
|
||||||
|
|
||||||
|
set_relative_rate(1);
|
||||||
|
set_output_multiple(SYMBOL_LENGTH);
|
||||||
|
set_tag_propagation_policy(block::TPP_DONT);
|
||||||
|
}
|
||||||
|
|
||||||
|
~packet_pad_impl(){
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert_sob(uint64_t item) {
|
||||||
|
return;
|
||||||
|
dout << "OFDM PAD: insert sob at: " << item << std::endl;
|
||||||
|
|
||||||
|
const pmt::pmt_t sob_key = pmt::string_to_symbol("tx_sob");
|
||||||
|
const pmt::pmt_t value = pmt::PMT_T;
|
||||||
|
const pmt::pmt_t srcid = pmt::string_to_symbol(this->name());
|
||||||
|
add_item_tag(0, item, sob_key, value, srcid);
|
||||||
|
add_item_tag(0, item, pmt::string_to_symbol("rel_tx_time"), pmt::from_double(0.05), srcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert_eob(uint64_t item) {
|
||||||
|
dout << "OFDM PAD: insert eob at: " << item << std::endl;
|
||||||
|
|
||||||
|
const pmt::pmt_t eob_key = pmt::string_to_symbol("tx_eob");
|
||||||
|
const pmt::pmt_t value = pmt::PMT_T;
|
||||||
|
const pmt::pmt_t srcid = pmt::string_to_symbol(this->name());
|
||||||
|
add_item_tag(0, item, eob_key, value, srcid);
|
||||||
|
}
|
||||||
|
|
||||||
|
int general_work (int noutput_items, gr_vector_int& ninput_items,
|
||||||
|
gr_vector_const_void_star& input_items,
|
||||||
|
gr_vector_void_star& output_items) {
|
||||||
|
|
||||||
|
int ninput = ninput_items[0] / SYMBOL_LENGTH; // available input symbols
|
||||||
|
//assert(ninput_items[0] % SYMBOL_LENGTH == 0);
|
||||||
|
int noutput = noutput_items / SYMBOL_LENGTH; // available output symbols
|
||||||
|
|
||||||
|
|
||||||
|
// these 4 values are updated in each iteration
|
||||||
|
const gr_complex *in = (const gr_complex*)input_items[0];
|
||||||
|
gr_complex *out = (gr_complex*)output_items[0];
|
||||||
|
|
||||||
|
int written = 0; // written symbols
|
||||||
|
int consumed = 0; // read symbols
|
||||||
|
|
||||||
|
// tag handling
|
||||||
|
const uint64_t nread = this->nitems_read(0);
|
||||||
|
std::vector<gr::tag_t> tags;
|
||||||
|
|
||||||
|
dout << "OFDM PAD: input size: " << ninput_items[0] << " output size: "
|
||||||
|
<< noutput_items << std::endl;
|
||||||
|
|
||||||
|
while(written < noutput) {
|
||||||
|
|
||||||
|
// debug
|
||||||
|
dout << "OFDM PAD: iteration - consumed: " << consumed <<
|
||||||
|
" written: " << written << std::endl;
|
||||||
|
|
||||||
|
switch(d_state) {
|
||||||
|
|
||||||
|
case IDLE:
|
||||||
|
|
||||||
|
//assert(consumed < ninput);
|
||||||
|
if(consumed >= ninput) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
get_tags_in_range(tags, 0, nread + consumed * SYMBOL_LENGTH,
|
||||||
|
nread + (consumed + 1) * SYMBOL_LENGTH - 1,
|
||||||
|
pmt::string_to_symbol("ofdm_start"));
|
||||||
|
|
||||||
|
assert(tags.size() == 1);
|
||||||
|
|
||||||
|
d_front_left = d_pad_front;
|
||||||
|
d_frame_left = pmt::to_uint64(tags[0].value);
|
||||||
|
d_tail_left = d_pad_tail;
|
||||||
|
|
||||||
|
insert_sob(this->nitems_written(0) + written * SYMBOL_LENGTH);
|
||||||
|
d_state = FRONT;
|
||||||
|
|
||||||
|
dout << "OFDM PAD: new frame - length: " << d_frame_left << std::endl;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FRONT:
|
||||||
|
|
||||||
|
if(!((ninput >= d_frame_left) || (ninput == 102))) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!d_front_left) {
|
||||||
|
d_state = FRAME;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
dout << "OFDM PAD: pad front" << std::endl;
|
||||||
|
|
||||||
|
memset(out, 0, SYMBOL_LENGTH * sizeof(gr_complex));
|
||||||
|
|
||||||
|
d_front_left--;
|
||||||
|
out += SYMBOL_LENGTH;
|
||||||
|
written++;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FRAME:
|
||||||
|
|
||||||
|
//assert((consumed + 1) * SYMBOL_LENGTH <= ninput_items[0]);
|
||||||
|
if(consumed >= ninput) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
dout << "OFDM PAD: copy frame" << std::endl;
|
||||||
|
|
||||||
|
memcpy(out, in, SYMBOL_LENGTH * sizeof(gr_complex));
|
||||||
|
|
||||||
|
d_frame_left--;
|
||||||
|
consumed++;
|
||||||
|
written++;
|
||||||
|
in += SYMBOL_LENGTH;
|
||||||
|
out += SYMBOL_LENGTH;
|
||||||
|
|
||||||
|
if(!d_frame_left) {
|
||||||
|
d_state = TAIL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TAIL:
|
||||||
|
|
||||||
|
if(!d_tail_left) {
|
||||||
|
d_state = IDLE;
|
||||||
|
insert_eob(this->nitems_written(0) + written * SYMBOL_LENGTH - 1);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
dout << "OFDM PAD: pad tail" << std::endl;
|
||||||
|
|
||||||
|
memset(out, 0, SYMBOL_LENGTH * sizeof(gr_complex));
|
||||||
|
|
||||||
|
d_tail_left--;
|
||||||
|
written++;
|
||||||
|
out += SYMBOL_LENGTH;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
|
dout << "OFDM PAD: consumed: " << consumed << " produced: " << written << std::endl;
|
||||||
|
consume(0, consumed * SYMBOL_LENGTH);
|
||||||
|
return written * SYMBOL_LENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
forecast (int noutput_items, gr_vector_int &ninput_items_required)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(d_frame_left) {
|
||||||
|
ninput_items_required[0] = noutput_items;
|
||||||
|
|
||||||
|
} else if(d_state == TAIL) {
|
||||||
|
ninput_items_required[0] = 0;
|
||||||
|
} else {
|
||||||
|
ninput_items_required[0] = 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
dout << "PAD forecast noutput_items: " << noutput_items << " required: " << ninput_items_required[0] << std::endl;
|
||||||
|
dout << "PAD state " << d_state << std::endl;
|
||||||
|
dout << "d_frame_left " << d_frame_left << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool d_debug;
|
||||||
|
|
||||||
|
int d_pad_front;
|
||||||
|
int d_pad_tail;
|
||||||
|
|
||||||
|
int d_front_left;
|
||||||
|
int d_tail_left;
|
||||||
|
int d_frame_left;
|
||||||
|
|
||||||
|
enum {IDLE, FRONT, FRAME, TAIL} d_state;
|
||||||
|
};
|
||||||
|
|
||||||
|
packet_pad::sptr
|
||||||
|
packet_pad::make(bool debug, int pad_front, int pad_tail) {
|
||||||
|
return gnuradio::get_initial_sptr(new packet_pad_impl(debug, pad_front, pad_tail));
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <ccs/pdu_to_blob.h>
|
||||||
|
|
||||||
|
#include <gnuradio/io_signature.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using namespace gr::ccs;
|
||||||
|
|
||||||
|
class pdu_to_blob_impl : public pdu_to_blob {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
pdu_to_blob_impl() :
|
||||||
|
block("pdu_to_blob",
|
||||||
|
gr::io_signature::make(0, 0, 0),
|
||||||
|
gr::io_signature::make(0, 0, 0)) {
|
||||||
|
|
||||||
|
message_port_register_out(pmt::mp("out"));
|
||||||
|
|
||||||
|
message_port_register_in(pmt::mp("in"));
|
||||||
|
set_msg_handler(pmt::mp("in"), boost::bind(&pdu_to_blob_impl::make_blob, this, _1));
|
||||||
|
}
|
||||||
|
|
||||||
|
~pdu_to_blob_impl() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void make_blob(pmt::pmt_t msg) {
|
||||||
|
|
||||||
|
assert(pmt::is_pair(msg));
|
||||||
|
|
||||||
|
pmt::pmt_t vec = pmt::cdr(msg);
|
||||||
|
assert(pmt::is_u8vector(vec));
|
||||||
|
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
const void *data = pmt::uniform_vector_elements(vec, len);
|
||||||
|
assert(len < 4000);
|
||||||
|
|
||||||
|
std::memcpy(buf, data, len);
|
||||||
|
|
||||||
|
pmt::pmt_t blob = pmt::make_blob(buf, len);
|
||||||
|
|
||||||
|
message_port_pub(pmt::mp("out"), blob);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
char buf[4000];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
pdu_to_blob::sptr
|
||||||
|
pdu_to_blob::make() {
|
||||||
|
return gnuradio::get_initial_sptr(new pdu_to_blob_impl());
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <ccs/periodic_msg_source.h>
|
||||||
|
|
||||||
|
#include <gnuradio/io_signature.h>
|
||||||
|
#include <gnuradio/block_detail.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
using namespace gr::ccs;
|
||||||
|
|
||||||
|
class periodic_msg_source_impl : public periodic_msg_source {
|
||||||
|
|
||||||
|
#define dout d_debug && std::cout
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
periodic_msg_source_impl(pmt::pmt_t msg, float interval, int num_msg, bool debug) :
|
||||||
|
block("periodic_msg_source",
|
||||||
|
gr::io_signature::make(0, 0, 0),
|
||||||
|
gr::io_signature::make(0, 0, 0)),
|
||||||
|
d_msg(msg),
|
||||||
|
d_num_msg(num_msg),
|
||||||
|
d_interval(interval),
|
||||||
|
d_debug(debug),
|
||||||
|
d_finished(false) {
|
||||||
|
|
||||||
|
message_port_register_out(pmt::mp("out"));
|
||||||
|
d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&periodic_msg_source_impl::run, this, this)));
|
||||||
|
}
|
||||||
|
|
||||||
|
~periodic_msg_source_impl() {
|
||||||
|
d_finished = true;
|
||||||
|
d_thread->interrupt();
|
||||||
|
d_thread->join();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void run(periodic_msg_source_impl *instance) {
|
||||||
|
while(!d_finished) {
|
||||||
|
|
||||||
|
dout << "number of messages left: " << d_num_msg << std::endl;
|
||||||
|
|
||||||
|
if(!d_num_msg || d_finished) {
|
||||||
|
d_finished = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
message_port_pub( pmt::mp("out"), d_msg );
|
||||||
|
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(d_interval));
|
||||||
|
|
||||||
|
if(d_num_msg > 0) {
|
||||||
|
d_num_msg--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dout << "stopping msg source" << std::endl;
|
||||||
|
message_port_pub(pmt::mp("out"), pmt::PMT_EOF);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int d_num_msg;
|
||||||
|
bool d_debug;
|
||||||
|
bool d_finished;
|
||||||
|
float d_interval;
|
||||||
|
pmt::pmt_t d_msg;
|
||||||
|
boost::shared_ptr<boost::thread> d_thread;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
periodic_msg_source::sptr
|
||||||
|
periodic_msg_source::make(pmt::pmt_t msg, float interval, int num_msg, bool debug) {
|
||||||
|
return gnuradio::get_initial_sptr(new periodic_msg_source_impl(msg, interval, num_msg, debug));
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Bastian Bloessl <bloessl@ccs-labs.org>
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#include <ccs/string_to_blob.h>
|
||||||
|
|
||||||
|
#include <gnuradio/io_signature.h>
|
||||||
|
#include <gnuradio/block_detail.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
using namespace gr::ccs;
|
||||||
|
|
||||||
|
class string_to_blob_impl : public string_to_blob {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
string_to_blob_impl() :
|
||||||
|
block("string_to_blob",
|
||||||
|
gr::io_signature::make(0, 0, 0),
|
||||||
|
gr::io_signature::make(0, 0, 0)) {
|
||||||
|
|
||||||
|
message_port_register_out(pmt::mp("out"));
|
||||||
|
|
||||||
|
message_port_register_in(pmt::mp("in"));
|
||||||
|
set_msg_handler(pmt::mp("in"), boost::bind(&string_to_blob_impl::make_blob, this, _1));
|
||||||
|
}
|
||||||
|
|
||||||
|
~string_to_blob_impl() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void make_blob(pmt::pmt_t msg) {
|
||||||
|
|
||||||
|
if(pmt::is_eof_object(msg)) {
|
||||||
|
message_port_pub(pmt::mp("out"), pmt::PMT_EOF);
|
||||||
|
detail().get()->set_done(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(pmt::is_symbol(msg));
|
||||||
|
|
||||||
|
int len = pmt::symbol_to_string(msg).length();
|
||||||
|
const char *data = pmt::symbol_to_string(msg).data();
|
||||||
|
|
||||||
|
pmt::pmt_t blob = pmt::make_blob(data, len);
|
||||||
|
|
||||||
|
message_port_pub(pmt::mp("out"), blob);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
string_to_blob::sptr
|
||||||
|
string_to_blob::make() {
|
||||||
|
return gnuradio::get_initial_sptr(new string_to_blob_impl());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -8,14 +8,26 @@
|
|||||||
%{
|
%{
|
||||||
#include "ccs/burst_tagger.h"
|
#include "ccs/burst_tagger.h"
|
||||||
#include "ccs/packet_dropper.h"
|
#include "ccs/packet_dropper.h"
|
||||||
|
#include "ccs/packet_pad.h"
|
||||||
|
#include "ccs/pdu_to_blob.h"
|
||||||
|
#include "ccs/periodic_msg_source.h"
|
||||||
|
#include "ccs/string_to_blob.h"
|
||||||
#include "ccs/wireshark_connector.h"
|
#include "ccs/wireshark_connector.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
%include "ccs/burst_tagger.h"
|
%include "ccs/burst_tagger.h"
|
||||||
%include "ccs/packet_dropper.h"
|
%include "ccs/packet_dropper.h"
|
||||||
|
%include "ccs/packet_pad.h"
|
||||||
|
%include "ccs/pdu_to_blob.h"
|
||||||
|
%include "ccs/periodic_msg_source.h"
|
||||||
|
%include "ccs/string_to_blob.h"
|
||||||
%include "ccs/wireshark_connector.h"
|
%include "ccs/wireshark_connector.h"
|
||||||
|
|
||||||
GR_SWIG_BLOCK_MAGIC2(ccs, burst_tagger);
|
GR_SWIG_BLOCK_MAGIC2(ccs, burst_tagger);
|
||||||
GR_SWIG_BLOCK_MAGIC2(ccs, packet_dropper);
|
GR_SWIG_BLOCK_MAGIC2(ccs, packet_dropper);
|
||||||
GR_SWIG_BLOCK_MAGIC2(ccs, wireshark_connector);
|
GR_SWIG_BLOCK_MAGIC2(ccs, wireshark_connector);
|
||||||
|
GR_SWIG_BLOCK_MAGIC2(ccs, packet_pad);
|
||||||
|
GR_SWIG_BLOCK_MAGIC2(ccs, pdu_to_blob);
|
||||||
|
GR_SWIG_BLOCK_MAGIC2(ccs, periodic_msg_source);
|
||||||
|
GR_SWIG_BLOCK_MAGIC2(ccs, string_to_blob);
|
||||||
|
|||||||
Reference in New Issue
Block a user