diff options
author | Vasil Velichkov <vvvelichkov@gmail.com> | 2018-08-31 00:59:48 +0300 |
---|---|---|
committer | Piotr Krysik <ptrkrysik@gmail.com> | 2018-09-13 15:35:44 +0200 |
commit | 9e46c4807dd48629469e3c7587c13b98162acd49 (patch) | |
tree | 92e3a9da36ad682544851941b1bb40f47cfdc712 /lib/misc_utils/bursts_printer_impl.cc | |
parent | 1e04c1fd9c4fac6759bd0020524b68f96de4abf8 (diff) |
Format the output into ostringstream and then write it at once.
This fixes the garbled output when multiple printers are used in a
flowgraph.
closes #255
closes #420
Change-Id: I1012ed26371b4c67163545652f0a1ce0f576af9e
Diffstat (limited to 'lib/misc_utils/bursts_printer_impl.cc')
-rw-r--r-- | lib/misc_utils/bursts_printer_impl.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/misc_utils/bursts_printer_impl.cc b/lib/misc_utils/bursts_printer_impl.cc index c22e60b..ab9c319 100644 --- a/lib/misc_utils/bursts_printer_impl.cc +++ b/lib/misc_utils/bursts_printer_impl.cc @@ -66,48 +66,50 @@ namespace gr { return; } - std::cout << d_prepend_string; + std::ostringstream out; + out << d_prepend_string; if (d_prepend_fnr) { - std::cout << frame_nr; + out << frame_nr; } if (d_prepend_fnr && d_prepend_frame_count) { - std::cout << " "; + out << " "; } if (d_prepend_frame_count) { // calculate fn count using libosmogsm - std::cout << osmo_a5_fn_count(frame_nr); + out << osmo_a5_fn_count(frame_nr); } if (d_prepend_fnr || d_prepend_frame_count) { - std::cout << ": "; + out << ": "; } if (d_print_payload_only) { for (int ii=0; ii<57; ii++) { - std::cout << std::setprecision(1) << static_cast<int>(burst[ii + 3]); + out << std::setprecision(1) << static_cast<int>(burst[ii + 3]); } for (int ii=0; ii<57; ii++) { - std::cout << std::setprecision(1) << static_cast<int>(burst[ii + 88]); + out << std::setprecision(1) << static_cast<int>(burst[ii + 88]); } } else { for(int ii=0; ii<burst_len; ii++) { - std::cout << std::setprecision(1) << static_cast<int>(burst[ii]); + out << std::setprecision(1) << static_cast<int>(burst[ii]); } } - std::cout << std::endl; + out << std::endl; + std::cout << out.str() << std::flush; } bool bursts_printer_impl::is_dummy_burst(int8_t *burst, size_t burst_len) |