From 89585b374b78375e6ff47ab1093d5fc0c12671eb Mon Sep 17 00:00:00 2001 From: Vasil Velichkov Date: Tue, 11 Sep 2018 14:15:53 +0300 Subject: burst_file_source: Fix reading longer bursts - Read bursts with pmt::deserialize directly from the std::filebuf - Remove the unused unserialized variable - Add tests Since df978693 when the rx_time tags are present in the incomming stream the gsm receiver adds fm_time to the burst's PMT and the bursts that burst file sink writes becomes longer because of the additional field. The burst file source block was expecting all burst to be 147 bytes long and reading files with longer bursts was failing with an unhandled exception. terminate called after throwing an instance of 'pmt::exception' thread[thread-per-block[5]: ]: pmt_cdr: wrong_type : #f what(): pmt::deserialize: malformed input stream, tag value = : 115 Change-Id: I989b0d6a6b214088b7880e5cbf7bb6725492dbfc --- lib/misc_utils/burst_file_source_impl.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'lib/misc_utils/burst_file_source_impl.cc') diff --git a/lib/misc_utils/burst_file_source_impl.cc b/lib/misc_utils/burst_file_source_impl.cc index 4367150..85d5ad9 100644 --- a/lib/misc_utils/burst_file_source_impl.cc +++ b/lib/misc_utils/burst_file_source_impl.cc @@ -28,8 +28,6 @@ #include "burst_file_source_impl.h" #include "stdio.h" -#define PMT_SIZE 174 - namespace gr { namespace gsm { @@ -86,16 +84,13 @@ namespace gr { void burst_file_source_impl::run() { - char *unserialized = (char*)malloc(sizeof(char) * PMT_SIZE); - while (d_input_file.read(unserialized, PMT_SIZE) && !d_finished) + std::filebuf* pbuf = d_input_file.rdbuf(); + while (!d_finished) { - if (d_input_file.bad()) - { + pmt::pmt_t burst = pmt::deserialize(*pbuf); + if (pmt::is_eof_object(burst)) { 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(); -- cgit v1.2.3