This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Piotr Krysik gerrit-no-reply at lists.osmocom.orgPiotr Krysik has submitted this change and it was merged. ( https://gerrit.osmocom.org/10731 )
Change subject: Format the output into ostringstream and then write it at once.
......................................................................
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
---
M lib/misc_utils/bursts_printer_impl.cc
M lib/misc_utils/message_printer_impl.cc
2 files changed, 21 insertions(+), 16 deletions(-)
Approvals:
Piotr Krysik: Looks good to me, approved; Verified
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 @@
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)
diff --git a/lib/misc_utils/message_printer_impl.cc b/lib/misc_utils/message_printer_impl.cc
index e8aa2d3..8342946 100644
--- a/lib/misc_utils/message_printer_impl.cc
+++ b/lib/misc_utils/message_printer_impl.cc
@@ -46,26 +46,27 @@
gsmtap_hdr * header = (gsmtap_hdr *)message_plus_header;
uint32_t frame_nr = be32toh(header->frame_number);
- 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 << ": ";
}
int start_index = sizeof(gsmtap_hdr);
@@ -77,9 +78,11 @@
for(int ii=start_index; ii<message_plus_header_len; ii++)
{
- printf(" %02x", message_plus_header[ii]);
+ out<<" "<<(std::hex)<<std::setw(2)<<std::setfill('0')<<(uint32_t)message_plus_header[ii];
}
- std::cout << std::endl;
+
+ out << std::endl;
+ std::cout << out.str() << std::flush;
}
message_printer::sptr
--
To view, visit https://gerrit.osmocom.org/10731
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: gr-gsm
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I1012ed26371b4c67163545652f0a1ce0f576af9e
Gerrit-Change-Number: 10731
Gerrit-PatchSet: 2
Gerrit-Owner: Vasil Velichkov <vvvelichkov at gmail.com>
Gerrit-Reviewer: Piotr Krysik <ptrkrysik at gmail.com>
Gerrit-Reviewer: Vasil Velichkov <vvvelichkov at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180911/2540a3c0/attachment.htm>