diff --git a/grc/satnogs_json_to_ecss_src.xml b/grc/satnogs_json_to_ecss_src.xml index 8d2e3e8..3a3e716 100644 --- a/grc/satnogs_json_to_ecss_src.xml +++ b/grc/satnogs_json_to_ecss_src.xml @@ -1,17 +1,19 @@ - JSON to ECSS source + JSON to ECSS satnogs_json_to_ecss_src satnogs import satnogs - satnogs.json_to_ecss() + satnogs.json_to_ecss_src() + - - out - message - in message + + + out + message + diff --git a/include/satnogs/json_to_ecss_src.h b/include/satnogs/json_to_ecss_src.h index fb82b12..6a477c3 100644 --- a/include/satnogs/json_to_ecss_src.h +++ b/include/satnogs/json_to_ecss_src.h @@ -690,7 +690,7 @@ namespace gr { * \ingroup satnogs * */ - class SATNOGS_API json_to_ecss_src : virtual public gr::sync_block + class SATNOGS_API json_to_ecss_src : virtual public gr::block { public: typedef boost::shared_ptr sptr; @@ -703,7 +703,7 @@ namespace gr { * class. satnogs::json_to_ecss_src::make is the public interface for * creating new instances. */ - static sptr make(const std::string& addr, uint16_t port, size_t mtu); + static sptr make(); }; diff --git a/lib/json_to_ecss_src_impl.cc b/lib/json_to_ecss_src_impl.cc index 4f5a849..0e5168e 100644 --- a/lib/json_to_ecss_src_impl.cc +++ b/lib/json_to_ecss_src_impl.cc @@ -685,22 +685,24 @@ #include #include +#define BUFFER_SIZE 2048 + namespace gr { namespace satnogs { json_to_ecss_src::sptr - json_to_ecss_src::make(const std::string& addr, uint16_t port, size_t mtu) + json_to_ecss_src::make() { return gnuradio::get_initial_sptr - (new json_to_ecss_src_impl(addr, port, mtu)); + (new json_to_ecss_src_impl()); } /* * The private constructor */ - json_to_ecss_src_impl::json_to_ecss_src_impl(const std::string& addr, uint16_t port, size_t mtu) - : gr::sync_block("json_to_ecss_src", + json_to_ecss_src_impl::json_to_ecss_src_impl() + : gr::block("json_to_ecss_src", gr::io_signature::make (0, 0, 0), gr::io_signature::make (0, 0, 0)), is_running(true), @@ -710,6 +712,8 @@ namespace gr { message_port_register_out(d_out_port); message_port_register_in(d_in_port); + d_buf = (uint8_t*)malloc(BUFFER_SIZE * sizeof(uint8_t)); + new boost::thread ( boost::bind (&json_to_ecss_src_impl::json_accepter, this)); } @@ -724,50 +728,20 @@ namespace gr { void json_to_ecss_src_impl::json_accepter(){ pmt::pmt_t message; - uint8_t *buf; size_t length; while(is_running){ - tc_tm_pkt pkt; message = delete_head_blocking(d_in_port,0); length = blob_length(message); - buf = uint8_t(length); - buf = blob_data(message); - std::istringstream ss(std::string(buf, buf + length)); + d_buf = (uint8_t*)blob_data(message); + std::istringstream ss(std::string(d_buf, d_buf + length)); ptree tree; read_json(ss,tree); - print_ptree(tree,0); - + BOOST_FOREACH(const ptree::value_type &v, tree) { + std::cout<<"First = "< -#include #include #include @@ -699,13 +698,12 @@ namespace gr { pmt::pmt_t d_in_port; pmt::pmt_t d_out_port; + uint8_t* d_buf; + void json_accepter(); - void - print_ptree(ptree &pt, int level); - std::string indent(int level); public: - json_to_ecss_src_impl(const std::string& addr, uint16_t port, size_t mtu); + json_to_ecss_src_impl(); ~json_to_ecss_src_impl(); // Where all the action really happens diff --git a/lib/udp_msg_source_impl.cc b/lib/udp_msg_source_impl.cc index 237e126..ea63e6f 100644 --- a/lib/udp_msg_source_impl.cc +++ b/lib/udp_msg_source_impl.cc @@ -100,7 +100,7 @@ namespace gr } /* All good until now. Allocate buffer memory and proceed */ - buf = new uint8_t(d_mtu); + buf = (uint8_t*)malloc(d_mtu*sizeof(uint8_t)); while(d_running){ ret = recvfrom(sock, buf, d_mtu, 0, &client_addr, &client_addr_len);