some clean up

This commit is contained in:
Bastian Bloessl
2016-04-23 11:07:52 +02:00
parent d182ea5a96
commit 842db2eeea
8 changed files with 45 additions and 53 deletions
+3 -10
View File
@@ -17,13 +17,6 @@
# the Free Software Foundation, Inc., 51 Franklin Street, # the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
install(FILES file(GLOB xml_files "*.xml")
foo_burst_tagger.xml
foo_packet_dropper.xml install(FILES ${xml_files} DESTINATION share/gnuradio/grc/blocks )
foo_packet_pad.xml
foo_packet_pad2.xml
foo_periodic_msg_source.xml
foo_rtt_measure.xml
foo_wireshark_connector.xml
foo_random_periodic_msg_source.xml DESTINATION share/gnuradio/grc/blocks
)
+2 -2
View File
@@ -52,8 +52,8 @@
<key>num</key> <key>num</key>
<value>1</value> <value>1</value>
<type>int</type> <type>int</type>
</param> </param>
<param> <param>
<name>Random Seed</name> <name>Random Seed</name>
<key>seed</key> <key>seed</key>
<value>1</value> <value>1</value>
+3 -2
View File
@@ -27,7 +27,8 @@ install(FILES
packet_pad.h packet_pad.h
packet_pad2.h packet_pad2.h
periodic_msg_source.h periodic_msg_source.h
wireshark_connector.h random_periodic_msg_source.h
rtt_measure.h rtt_measure.h
random_periodic_msg_source.h DESTINATION include/foo wireshark_connector.h
DESTINATION include/foo
) )
+3 -3
View File
@@ -34,12 +34,12 @@ link_directories(
list(APPEND foo_sources list(APPEND foo_sources
burst_tagger_impl.cc burst_tagger_impl.cc
packet_dropper_impl.cc packet_dropper_impl.cc
packet_pad_impl.cc
packet_pad2.cc packet_pad2.cc
packet_pad_impl.cc
periodic_msg_source_impl.cc periodic_msg_source_impl.cc
wireshark_connector_impl.cc
rtt_measure_impl.cc
random_periodic_msg_source_impl.cc random_periodic_msg_source_impl.cc
rtt_measure_impl.cc
wireshark_connector_impl.cc
) )
set(PACKAGE_FIND_VERSION_MAJOR 0) set(PACKAGE_FIND_VERSION_MAJOR 0)
+2 -3
View File
@@ -80,11 +80,11 @@ periodic_msg_source_impl::run(periodic_msg_source_impl *instance) {
if(d_nmsg_left > 0) { if(d_nmsg_left > 0) {
d_nmsg_left--; d_nmsg_left--;
} }
delay = d_interval; delay = d_interval;
} }
boost::this_thread::sleep(boost::posix_time::milliseconds(delay)); boost::this_thread::sleep(boost::posix_time::milliseconds(delay));
} }
} catch(boost::thread_interrupted) { } catch(boost::thread_interrupted) {
gr::thread::scoped_lock(d_mutex); gr::thread::scoped_lock(d_mutex);
@@ -151,4 +151,3 @@ periodic_msg_source::sptr
periodic_msg_source::make(pmt::pmt_t msg, float interval, int num_msg, bool quit, bool debug) { periodic_msg_source::make(pmt::pmt_t msg, float interval, int num_msg, bool quit, bool debug) {
return gnuradio::get_initial_sptr(new periodic_msg_source_impl(msg, interval, num_msg, quit, debug)); return gnuradio::get_initial_sptr(new periodic_msg_source_impl(msg, interval, num_msg, quit, debug));
} }
+20 -21
View File
@@ -38,10 +38,10 @@ random_periodic_msg_source_impl::random_periodic_msg_source_impl(int msg_len,
d_debug(debug), d_debug(debug),
d_finished(false), d_finished(false),
d_quit(quit), d_quit(quit),
d_seed(static_cast<unsigned int>(seed)), d_seed(static_cast<unsigned int>(seed)),
d_brange(0,255), d_brange(0,255),
d_rng(seed), d_rng(seed),
d_randbytes(d_rng,d_brange) d_randbytes(d_rng,d_brange)
{ {
message_port_register_out(pmt::mp("out")); message_port_register_out(pmt::mp("out"));
@@ -79,18 +79,18 @@ random_periodic_msg_source_impl::run(random_periodic_msg_source_impl *instance)
} }
dout << "PMS: number of messages left: " << d_nmsg_left << std::endl; dout << "PMS: number of messages left: " << d_nmsg_left << std::endl;
// Generate a random message // Generate a random message
pmt::pmt_t msg = generate_msg(); pmt::pmt_t msg = generate_msg();
message_port_pub( pmt::mp("out"), msg); message_port_pub( pmt::mp("out"), msg);
if(d_nmsg_left > 0) { if(d_nmsg_left > 0) {
d_nmsg_left--; d_nmsg_left--;
} }
delay = d_interval; delay = d_interval;
} }
boost::this_thread::sleep(boost::posix_time::milliseconds(delay)); boost::this_thread::sleep(boost::posix_time::milliseconds(delay));
} }
} catch(boost::thread_interrupted) { } catch(boost::thread_interrupted) {
gr::thread::scoped_lock(d_mutex); gr::thread::scoped_lock(d_mutex);
@@ -105,17 +105,17 @@ random_periodic_msg_source_impl::run(random_periodic_msg_source_impl *instance)
} }
// Generate a random message // Generate a random message
pmt::pmt_t pmt::pmt_t
random_periodic_msg_source_impl::generate_msg(){ random_periodic_msg_source_impl::generate_msg() {
// Construct random vector of specified length // Construct random vector of specified length
std::vector<unsigned char> vec(d_msg_len); std::vector<unsigned char> vec(d_msg_len);
// Fill w/random bytes // Fill w/random bytes
for( int i=0; i<d_msg_len; i++ ){ for( int i=0; i<d_msg_len; i++ ) {
vec[i] = ((unsigned char) d_randbytes()); vec[i] = ((unsigned char) d_randbytes());
} }
// Construct the PDU // Construct the PDU
pmt::pmt_t vecpmt(pmt::make_blob(&vec[0], d_msg_len)); pmt::pmt_t vecpmt(pmt::make_blob(&vec[0], d_msg_len));
return pmt::cons(pmt::PMT_NIL, vecpmt); return pmt::cons(pmt::PMT_NIL, vecpmt);
} }
void void
random_periodic_msg_source_impl::set_nmsg(int nmsg) { random_periodic_msg_source_impl::set_nmsg(int nmsg) {
@@ -168,7 +168,6 @@ random_periodic_msg_source_impl::is_running() {
random_periodic_msg_source::sptr random_periodic_msg_source::sptr
random_periodic_msg_source::make(int msg_len, float interval, int num_msg, random_periodic_msg_source::make(int msg_len, float interval, int num_msg,
bool quit, bool debug,int seed) { bool quit, bool debug,int seed) {
return gnuradio::get_initial_sptr(new random_periodic_msg_source_impl(msg_len, interval, num_msg, quit, debug, seed)); return gnuradio::get_initial_sptr(new random_periodic_msg_source_impl(msg_len, interval, num_msg, quit, debug, seed));
} }
+6 -6
View File
@@ -28,19 +28,19 @@ namespace foo {
class random_periodic_msg_source_impl : public random_periodic_msg_source { class random_periodic_msg_source_impl : public random_periodic_msg_source {
private: private:
void run(random_periodic_msg_source_impl *instance); void run(random_periodic_msg_source_impl *instance);
int d_msg_len; int d_msg_len;
int d_nmsg_total; int d_nmsg_total;
int d_nmsg_left; int d_nmsg_left;
unsigned int d_seed; unsigned int d_seed;
bool d_debug; bool d_debug;
bool d_quit; bool d_quit;
bool d_finished; bool d_finished;
float d_interval; float d_interval;
boost::thread *d_thread; boost::thread *d_thread;
gr::thread::mutex d_mutex; gr::thread::mutex d_mutex;
boost::mt19937 d_rng; boost::mt19937 d_rng;
boost::uniform_int<> d_brange; boost::variate_generator< boost::mt19937, boost::uniform_int<> > d_randbytes;
boost::variate_generator< boost::mt19937, boost::uniform_int<> > d_randbytes; boost::uniform_int<> d_brange;
public: public:
random_periodic_msg_source_impl(int msg_len, random_periodic_msg_source_impl(int msg_len,
@@ -56,7 +56,7 @@ namespace foo {
void start_tx(); void start_tx();
void stop_tx(); void stop_tx();
pmt::pmt_t generate_msg(); pmt::pmt_t generate_msg();
bool is_running(); bool is_running();
}; };
+6 -6
View File
@@ -11,9 +11,9 @@
#include "foo/packet_pad.h" #include "foo/packet_pad.h"
#include "foo/packet_pad2.h" #include "foo/packet_pad2.h"
#include "foo/periodic_msg_source.h" #include "foo/periodic_msg_source.h"
#include "foo/wireshark_connector.h"
#include "foo/rtt_measure.h"
#include "foo/random_periodic_msg_source.h" #include "foo/random_periodic_msg_source.h"
#include "foo/rtt_measure.h"
#include "foo/wireshark_connector.h"
%} %}
@@ -22,15 +22,15 @@
%include "foo/packet_pad.h" %include "foo/packet_pad.h"
%include "foo/packet_pad2.h" %include "foo/packet_pad2.h"
%include "foo/periodic_msg_source.h" %include "foo/periodic_msg_source.h"
%include "foo/wireshark_connector.h"
%include "foo/rtt_measure.h"
%include "foo/random_periodic_msg_source.h" %include "foo/random_periodic_msg_source.h"
%include "foo/rtt_measure.h"
%include "foo/wireshark_connector.h"
GR_SWIG_BLOCK_MAGIC2(foo, burst_tagger); GR_SWIG_BLOCK_MAGIC2(foo, burst_tagger);
GR_SWIG_BLOCK_MAGIC2(foo, packet_dropper); GR_SWIG_BLOCK_MAGIC2(foo, packet_dropper);
GR_SWIG_BLOCK_MAGIC2(foo, packet_pad); GR_SWIG_BLOCK_MAGIC2(foo, packet_pad);
GR_SWIG_BLOCK_MAGIC2(foo, packet_pad2); GR_SWIG_BLOCK_MAGIC2(foo, packet_pad2);
GR_SWIG_BLOCK_MAGIC2(foo, periodic_msg_source); GR_SWIG_BLOCK_MAGIC2(foo, periodic_msg_source);
GR_SWIG_BLOCK_MAGIC2(foo, wireshark_connector);
GR_SWIG_BLOCK_MAGIC2(foo, rtt_measure);
GR_SWIG_BLOCK_MAGIC2(foo, random_periodic_msg_source); GR_SWIG_BLOCK_MAGIC2(foo, random_periodic_msg_source);
GR_SWIG_BLOCK_MAGIC2(foo, rtt_measure);
GR_SWIG_BLOCK_MAGIC2(foo, wireshark_connector);