Merged origin/msg-file-sink-source-101 into dev, fixed conflicts. Issue #101
This commit is contained in:
commit
e91edbdc11
|
@ -49,6 +49,8 @@
|
||||||
<block>gsm_bursts_printer</block>
|
<block>gsm_bursts_printer</block>
|
||||||
<block>gsm_burst_file_sink</block>
|
<block>gsm_burst_file_sink</block>
|
||||||
<block>gsm_burst_file_source</block>
|
<block>gsm_burst_file_source</block>
|
||||||
|
<block>gsm_message_file_sink</block>
|
||||||
|
<block>gsm_message_file_source</block>
|
||||||
<block>gsm_extract_system_info</block>
|
<block>gsm_extract_system_info</block>
|
||||||
<block>gsm_extract_immediate_assignment</block>
|
<block>gsm_extract_immediate_assignment</block>
|
||||||
<block>gsm_controlled_rotator_cc</block>
|
<block>gsm_controlled_rotator_cc</block>
|
||||||
|
|
|
@ -27,5 +27,7 @@ install(FILES
|
||||||
gsm_clock_offset_corrector.xml
|
gsm_clock_offset_corrector.xml
|
||||||
gsm_tmsi_dumper.xml
|
gsm_tmsi_dumper.xml
|
||||||
gsm_burst_file_sink.xml
|
gsm_burst_file_sink.xml
|
||||||
gsm_burst_file_source.xml DESTINATION share/gnuradio/grc/blocks
|
gsm_burst_file_source.xml
|
||||||
|
gsm_message_file_sink.xml
|
||||||
|
gsm_message_file_source.xml DESTINATION share/gnuradio/grc/blocks
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<block>
|
||||||
|
<name>Message file sink</name>
|
||||||
|
<key>gsm_message_file_sink</key>
|
||||||
|
<import>import grgsm</import>
|
||||||
|
<make>grgsm.message_file_sink($filename)</make>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Destination file</name>
|
||||||
|
<key>filename</key>
|
||||||
|
<value>/tmp/output.msg</value>
|
||||||
|
<type>file_open</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<sink>
|
||||||
|
<name>in</name>
|
||||||
|
<type>message</type>
|
||||||
|
</sink>
|
||||||
|
|
||||||
|
<doc>
|
||||||
|
This block stores incoming gsm messages to a file.
|
||||||
|
</doc>
|
||||||
|
</block>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<block>
|
||||||
|
<name>Message file source</name>
|
||||||
|
<key>gsm_message_file_source</key>
|
||||||
|
<import>import grgsm</import>
|
||||||
|
<make>grgsm.message_file_source($filename)</make>
|
||||||
|
|
||||||
|
<param>
|
||||||
|
<name>Source file</name>
|
||||||
|
<key>filename</key>
|
||||||
|
<value>/tmp/output.msg</value>
|
||||||
|
<type>file_open</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
|
<source>
|
||||||
|
<name>out</name>
|
||||||
|
<type>message</type>
|
||||||
|
</source>
|
||||||
|
|
||||||
|
<doc>
|
||||||
|
This block outputs gsm messages stored in a file.
|
||||||
|
</doc>
|
||||||
|
</block>
|
|
@ -24,6 +24,8 @@ install(FILES
|
||||||
bursts_printer.h
|
bursts_printer.h
|
||||||
burst_file_source.h
|
burst_file_source.h
|
||||||
burst_file_sink.h
|
burst_file_sink.h
|
||||||
|
message_file_sink.h
|
||||||
|
message_file_source.h
|
||||||
extract_system_info.h
|
extract_system_info.h
|
||||||
extract_immediate_assignment.h
|
extract_immediate_assignment.h
|
||||||
controlled_rotator_cc.h
|
controlled_rotator_cc.h
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/* -*- c++ -*- */
|
||||||
|
/* @file
|
||||||
|
* @author Roman Khassraf <rkhassraf@gmail.com>
|
||||||
|
* @section LICENSE
|
||||||
|
*
|
||||||
|
* Gr-gsm 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, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_GSM_MESSAGE_FILE_SINK_H
|
||||||
|
#define INCLUDED_GSM_MESSAGE_FILE_SINK_H
|
||||||
|
|
||||||
|
#include <grgsm/api.h>
|
||||||
|
#include <gnuradio/block.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace gsm {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief <+description of block+>
|
||||||
|
* \ingroup gsm
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class GSM_API message_file_sink : virtual public gr::block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef boost::shared_ptr<message_file_sink> sptr;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Return a shared_ptr to a new instance of grgsm::message_file_sink.
|
||||||
|
*
|
||||||
|
* To avoid accidental use of raw pointers, grgsm::message_file_sink's
|
||||||
|
* constructor is in a private implementation
|
||||||
|
* class. grgsm::message_file_sink::make is the public interface for
|
||||||
|
* creating new instances.
|
||||||
|
*/
|
||||||
|
static sptr make(const std::string &filename);
|
||||||
|
};
|
||||||
|
} // namespace gsm
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_GSM_MESSAGE_FILE_SINK_H */
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/* -*- c++ -*- */
|
||||||
|
/* @file
|
||||||
|
* @author Roman Khassraf <rkhassraf@gmail.com>
|
||||||
|
* @section LICENSE
|
||||||
|
*
|
||||||
|
* Gr-gsm 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, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_GSM_MESSAGE_FILE_SOURCE_H
|
||||||
|
#define INCLUDED_GSM_MESSAGE_FILE_SOURCE_H
|
||||||
|
|
||||||
|
#include <grgsm/api.h>
|
||||||
|
#include <gnuradio/block.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace gsm {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief <+description of block+>
|
||||||
|
* \ingroup gsm
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class GSM_API message_file_source : virtual public gr::block
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef boost::shared_ptr<message_file_source> sptr;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Return a shared_ptr to a new instance of grgsm::message_file_source.
|
||||||
|
*
|
||||||
|
* To avoid accidental use of raw pointers, grgsm::message_file_source's
|
||||||
|
* constructor is in a private implementation
|
||||||
|
* class. grgsm::message_file_source::make is the public interface for
|
||||||
|
* creating new instances.
|
||||||
|
*/
|
||||||
|
static sptr make(const std::string &filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace gsm
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_GSM_MESSAGE_FILE_SOURCE_H */
|
||||||
|
|
|
@ -56,6 +56,8 @@ list(APPEND grgsm_sources
|
||||||
misc_utils/tmsi_dumper_impl.cc
|
misc_utils/tmsi_dumper_impl.cc
|
||||||
misc_utils/burst_file_sink_impl.cc
|
misc_utils/burst_file_sink_impl.cc
|
||||||
misc_utils/burst_file_source_impl.cc
|
misc_utils/burst_file_source_impl.cc
|
||||||
|
misc_utils/message_file_sink_impl.cc
|
||||||
|
misc_utils/message_file_source_impl.cc
|
||||||
qa_utils/burst_sink_impl.cc
|
qa_utils/burst_sink_impl.cc
|
||||||
qa_utils/burst_source_impl.cc
|
qa_utils/burst_source_impl.cc
|
||||||
qa_utils/message_source_impl.cc
|
qa_utils/message_source_impl.cc
|
||||||
|
@ -63,6 +65,7 @@ list(APPEND grgsm_sources
|
||||||
decryption/decryption_impl.cc
|
decryption/decryption_impl.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_library(gnuradio-grgsm SHARED ${grgsm_sources})
|
add_library(gnuradio-grgsm SHARED ${grgsm_sources})
|
||||||
target_link_libraries(gnuradio-grgsm ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES} ${LIBOSMOCORE_LIBRARIES}
|
target_link_libraries(gnuradio-grgsm ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES} ${LIBOSMOCORE_LIBRARIES}
|
||||||
# libraries required by plotting.h - have troubles to be installed by pybombs
|
# libraries required by plotting.h - have troubles to be installed by pybombs
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/* -*- c++ -*- */
|
||||||
|
/* @file
|
||||||
|
* @author Roman Khassraf <rkhassraf@gmail.com>
|
||||||
|
* @section LICENSE
|
||||||
|
*
|
||||||
|
* Gr-gsm 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, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gnuradio/io_signature.h>
|
||||||
|
#include "message_file_sink_impl.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace gsm {
|
||||||
|
|
||||||
|
message_file_sink::sptr
|
||||||
|
message_file_sink::make(const std::string &filename)
|
||||||
|
{
|
||||||
|
return gnuradio::get_initial_sptr
|
||||||
|
(new message_file_sink_impl(filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The private constructor
|
||||||
|
*/
|
||||||
|
message_file_sink_impl::message_file_sink_impl(const std::string &filename)
|
||||||
|
: gr::block("message_file_sink",
|
||||||
|
gr::io_signature::make(0, 0, 0),
|
||||||
|
gr::io_signature::make(0, 0, 0)),
|
||||||
|
d_output_file(filename.c_str(), std::ofstream::binary)
|
||||||
|
{
|
||||||
|
message_port_register_in(pmt::mp("in"));
|
||||||
|
set_msg_handler(pmt::mp("in"), boost::bind(&message_file_sink_impl::process_message, this, _1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our virtual destructor.
|
||||||
|
*/
|
||||||
|
message_file_sink_impl::~message_file_sink_impl()
|
||||||
|
{
|
||||||
|
if (d_output_file.is_open())
|
||||||
|
{
|
||||||
|
d_output_file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void message_file_sink_impl::process_message(pmt::pmt_t msg)
|
||||||
|
{
|
||||||
|
std::string s = pmt::serialize_str(msg);
|
||||||
|
const char *serialized = s.data();
|
||||||
|
d_output_file.write(serialized, s.length());
|
||||||
|
}
|
||||||
|
} /* namespace gsm */
|
||||||
|
} /* namespace gr */
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/* -*- c++ -*- */
|
||||||
|
/* @file
|
||||||
|
* @author Roman Khassraf <rkhassraf@gmail.com>
|
||||||
|
* @section LICENSE
|
||||||
|
*
|
||||||
|
* Gr-gsm 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, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_GSM_MESSAGE_FILE_SINK_IMPL_H
|
||||||
|
#define INCLUDED_GSM_MESSAGE_FILE_SINK_IMPL_H
|
||||||
|
|
||||||
|
#include <grgsm/misc_utils/message_file_sink.h>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace gsm {
|
||||||
|
|
||||||
|
class message_file_sink_impl : public message_file_sink
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::ofstream d_output_file;
|
||||||
|
public:
|
||||||
|
message_file_sink_impl(const std::string &filename);
|
||||||
|
~message_file_sink_impl();
|
||||||
|
void process_message(pmt::pmt_t msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace gsm
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_GSM_MESSAGE_FILE_SINK_IMPL_H */
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
/* -*- c++ -*- */
|
||||||
|
/* @file
|
||||||
|
* @author Roman Khassraf <rkhassraf@gmail.com>
|
||||||
|
* @section LICENSE
|
||||||
|
*
|
||||||
|
* Gr-gsm 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, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gnuradio/io_signature.h>
|
||||||
|
#include "message_file_source_impl.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define PMT_SIZE 49
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace gsm {
|
||||||
|
|
||||||
|
message_file_source::sptr
|
||||||
|
message_file_source::make(const std::string &filename)
|
||||||
|
{
|
||||||
|
return gnuradio::get_initial_sptr
|
||||||
|
(new message_file_source_impl(filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The private constructor
|
||||||
|
*/
|
||||||
|
message_file_source_impl::message_file_source_impl(const std::string &filename)
|
||||||
|
: gr::block("message_file_source",
|
||||||
|
gr::io_signature::make(0, 0, 0),
|
||||||
|
gr::io_signature::make(0, 0, 0)),
|
||||||
|
d_input_file(filename.c_str(), std::ifstream::binary),
|
||||||
|
d_finished(false)
|
||||||
|
{
|
||||||
|
message_port_register_out(pmt::mp("out"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our virtual destructor.
|
||||||
|
*/
|
||||||
|
message_file_source_impl::~message_file_source_impl()
|
||||||
|
{
|
||||||
|
if (d_finished == false){
|
||||||
|
d_finished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool message_file_source_impl::start()
|
||||||
|
{
|
||||||
|
d_finished = false;
|
||||||
|
d_thread = boost::shared_ptr<gr::thread::thread>
|
||||||
|
(new gr::thread::thread(boost::bind(&message_file_source_impl::run, this)));
|
||||||
|
return block::start();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool message_file_source_impl::stop()
|
||||||
|
{
|
||||||
|
d_finished = true;
|
||||||
|
d_thread->interrupt();
|
||||||
|
d_thread->join();
|
||||||
|
return block::stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool message_file_source_impl::finished()
|
||||||
|
{
|
||||||
|
return d_finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
void message_file_source_impl::run()
|
||||||
|
{
|
||||||
|
char *unserialized = (char*)malloc(sizeof(char) * PMT_SIZE);
|
||||||
|
while (d_input_file.read(unserialized, PMT_SIZE) && !d_finished)
|
||||||
|
{
|
||||||
|
if (d_input_file.bad())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string s(unserialized, PMT_SIZE);
|
||||||
|
pmt::pmt_t burst = pmt::deserialize_str(s);
|
||||||
|
message_port_pub(pmt::mp("out"), burst);
|
||||||
|
}
|
||||||
|
d_input_file.close();
|
||||||
|
post(pmt::mp("system"), pmt::cons(pmt::mp("done"), pmt::from_long(1)));
|
||||||
|
}
|
||||||
|
} /* namespace gsm */
|
||||||
|
} /* namespace gr */
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/* -*- c++ -*- */
|
||||||
|
/* @file
|
||||||
|
* @author Roman Khassraf <rkhassraf@gmail.com>
|
||||||
|
* @section LICENSE
|
||||||
|
*
|
||||||
|
* Gr-gsm 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, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_GSM_MESSAGE_FILE_SOURCE_IMPL_H
|
||||||
|
#define INCLUDED_GSM_MESSAGE_FILE_SOURCE_IMPL_H
|
||||||
|
|
||||||
|
#include <grgsm/misc_utils/message_file_source.h>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
namespace gr {
|
||||||
|
namespace gsm {
|
||||||
|
|
||||||
|
class message_file_source_impl : public message_file_source
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
boost::shared_ptr<gr::thread::thread> d_thread;
|
||||||
|
std::ifstream d_input_file;
|
||||||
|
bool d_finished;
|
||||||
|
void run();
|
||||||
|
public:
|
||||||
|
message_file_source_impl(const std::string &filename);
|
||||||
|
~message_file_source_impl();
|
||||||
|
bool start();
|
||||||
|
bool stop();
|
||||||
|
bool finished();
|
||||||
|
};
|
||||||
|
} // namespace gsm
|
||||||
|
} // namespace gr
|
||||||
|
|
||||||
|
#endif /* INCLUDED_GSM_MESSAGE_FILE_SOURCE_IMPL_H */
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# @file
|
||||||
|
# @author Roman Khassraf <rkhassraf@gmail.com>
|
||||||
|
# @section LICENSE
|
||||||
|
#
|
||||||
|
# Gr-gsm 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, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# Gr-gsm 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 gr-gsm; see the file COPYING. If not, write to
|
||||||
|
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
# Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
from gnuradio import gr, gr_unittest, blocks
|
||||||
|
import grgsm
|
||||||
|
import os
|
||||||
|
import pmt
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
class qa_message_source_sink (gr_unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp (self):
|
||||||
|
self.tb = gr.top_block()
|
||||||
|
self.tmpfile = tempfile.NamedTemporaryFile()
|
||||||
|
|
||||||
|
def tearDown (self):
|
||||||
|
self.tmpfile.close()
|
||||||
|
|
||||||
|
#def getOutput(self):
|
||||||
|
#self.tmpfile.seek(0)
|
||||||
|
#return self.tmpfile.read()
|
||||||
|
|
||||||
|
#def getOutputExpected(self, expected_lines):
|
||||||
|
#out = ""
|
||||||
|
#for l in expected_lines:
|
||||||
|
#out = out + l + "\n"
|
||||||
|
#return out
|
||||||
|
|
||||||
|
def test_001_no_prefix_no_header (self):
|
||||||
|
"""
|
||||||
|
Four messages, without any prefix, no gsmtap header
|
||||||
|
"""
|
||||||
|
msgs_input = [
|
||||||
|
"02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b",
|
||||||
|
#"02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b",
|
||||||
|
#"02 04 01 00 00 00 cb 00 00 1d 3d 0e 01 00 00 00 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00",
|
||||||
|
#"02 04 01 00 00 00 cb 00 00 1d 3d 12 02 00 00 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b"
|
||||||
|
]
|
||||||
|
|
||||||
|
# there is a whitespace at the beginning of message_printer output
|
||||||
|
msgs_expected = [
|
||||||
|
"02 04 01 00 00 00 c9 00 00 1d 3c e5 02 00 01 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b",
|
||||||
|
#"02 04 01 00 00 00 ca 00 00 1d 3c e9 02 00 02 00 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b",
|
||||||
|
#" 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e5 04 00",
|
||||||
|
#" 15 06 21 00 01 f0 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b"
|
||||||
|
]
|
||||||
|
|
||||||
|
src = grgsm.message_source(msgs_input)
|
||||||
|
file_sink = grgsm.message_file_sink(self.tmpfile.name)
|
||||||
|
|
||||||
|
#printer = grgsm.message_printer(pmt.intern(""), False)
|
||||||
|
#self.tb.msg_connect(src, "msgs", printer, "msgs")
|
||||||
|
self.tb.run()
|
||||||
|
|
||||||
|
#self.assertEqual(self.getOutput(), self.getOutputExpected(msgs_expected))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
gr_unittest.run(qa_message_source_sink, "qa_message_source_sink.xml")
|
|
@ -33,6 +33,8 @@
|
||||||
#include "grgsm/qa_utils/burst_source.h"
|
#include "grgsm/qa_utils/burst_source.h"
|
||||||
#include "grgsm/qa_utils/message_source.h"
|
#include "grgsm/qa_utils/message_source.h"
|
||||||
#include "grgsm/qa_utils/message_sink.h"
|
#include "grgsm/qa_utils/message_sink.h"
|
||||||
|
#include "grgsm/misc_utils/message_file_sink.h"
|
||||||
|
#include "grgsm/misc_utils/message_file_source.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "grgsm/receiver/receiver.h"
|
%include "grgsm/receiver/receiver.h"
|
||||||
|
@ -82,6 +84,10 @@ GR_SWIG_BLOCK_MAGIC2(gsm, controlled_const_source_f);
|
||||||
GR_SWIG_BLOCK_MAGIC2(gsm, message_printer);
|
GR_SWIG_BLOCK_MAGIC2(gsm, message_printer);
|
||||||
%include "grgsm/misc_utils/tmsi_dumper.h"
|
%include "grgsm/misc_utils/tmsi_dumper.h"
|
||||||
GR_SWIG_BLOCK_MAGIC2(gsm, tmsi_dumper);
|
GR_SWIG_BLOCK_MAGIC2(gsm, tmsi_dumper);
|
||||||
|
%include "grgsm/misc_utils/message_file_sink.h"
|
||||||
|
GR_SWIG_BLOCK_MAGIC2(gsm, message_file_sink);
|
||||||
|
%include "grgsm/misc_utils/message_file_source.h"
|
||||||
|
GR_SWIG_BLOCK_MAGIC2(gsm, message_file_source);
|
||||||
|
|
||||||
%include "grgsm/qa_utils/burst_sink.h"
|
%include "grgsm/qa_utils/burst_sink.h"
|
||||||
GR_SWIG_BLOCK_MAGIC2(gsm, burst_sink);
|
GR_SWIG_BLOCK_MAGIC2(gsm, burst_sink);
|
||||||
|
@ -91,4 +97,3 @@ GR_SWIG_BLOCK_MAGIC2(gsm, burst_source);
|
||||||
GR_SWIG_BLOCK_MAGIC2(gsm, message_source);
|
GR_SWIG_BLOCK_MAGIC2(gsm, message_source);
|
||||||
%include "grgsm/qa_utils/message_sink.h"
|
%include "grgsm/qa_utils/message_sink.h"
|
||||||
GR_SWIG_BLOCK_MAGIC2(gsm, message_sink);
|
GR_SWIG_BLOCK_MAGIC2(gsm, message_sink);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue