summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blossom2010-09-29 12:03:56 -0700
committerEric Blossom2010-09-29 12:03:56 -0700
commitdf0cfb734e5acf698d286e03ba6abccc13d9c586 (patch)
tree8bd1790a5a39ed94376d47ba12ad886d108f4b6c
parentf4e9ba2d94c9ae3340a79cce985560aeb48b526b (diff)
downloadgnuradio-df0cfb734e5acf698d286e03ba6abccc13d9c586.tar.gz
gnuradio-df0cfb734e5acf698d286e03ba6abccc13d9c586.tar.bz2
gnuradio-df0cfb734e5acf698d286e03ba6abccc13d9c586.zip
Move more formatting code into header_utils
-rw-r--r--vrt/lib/expanded_header.cc41
-rw-r--r--vrt/lib/expanded_if_context_section.cc155
-rw-r--r--vrt/lib/header_utils.cc191
-rw-r--r--vrt/lib/header_utils.h14
4 files changed, 208 insertions, 193 deletions
diff --git a/vrt/lib/expanded_header.cc b/vrt/lib/expanded_header.cc
index bc6a6190c..74a156dd2 100644
--- a/vrt/lib/expanded_header.cc
+++ b/vrt/lib/expanded_header.cc
@@ -154,47 +154,6 @@ namespace vrt {
return "<unknown pkt type>";
}
- static void wr_header(std::ostream &os, uint32_t x)
- {
- os << format("%#10x") % x;
-
- uint32_t t = (x >> 22) & 0x3;
- switch(t){
- case 0x0: os << " TSI=NONE"; break;
- case 0x1: os << " TSI=UTC"; break;
- case 0x2: os << " TSI=GPS"; break;
- case 0x3: os << " TSI=OTHER"; break;
- }
-
- t = (x >> 20) & 0x3;
- switch(t){
- case 0x0: os << " TSF=NONE"; break;
- case 0x1: os << " TSF=SAMPLE_CNT";break;
- case 0x2: os << " TSI=PICOSECS"; break;
- case 0x3: os << " TSI=FREE_RUN"; break;
- }
-
- uint32_t pt = x & VRTH_PT_MASK;
- if (pt == VRTH_PT_IF_CONTEXT || pt == VRTH_PT_EXT_CONTEXT){
- if (x & VRTH_TSM)
- os << " TSM=GENERAL";
- else
- os << " TSM=EXACT";
- }
- else if (0
- || pt == VRTH_PT_IF_DATA_WITH_SID
- || pt == VRTH_PT_IF_DATA_NO_SID
- || pt == VRTH_PT_EXT_DATA_WITH_SID
- || pt == VRTH_PT_EXT_DATA_NO_SID){
- if (x & VRTH_START_OF_BURST)
- os << " SOB";
- if (x & VRTH_END_OF_BURST)
- os << " EOB";
- }
-
- os << std::endl;
- }
-
void
expanded_header::write(std::ostream &port) const
{
diff --git a/vrt/lib/expanded_if_context_section.cc b/vrt/lib/expanded_if_context_section.cc
index ec75d9f4e..82acc3d1b 100644
--- a/vrt/lib/expanded_if_context_section.cc
+++ b/vrt/lib/expanded_if_context_section.cc
@@ -331,156 +331,8 @@ namespace vrt
return u.consumed_all();
}
- static void wr_hertz(std::ostream &os, vrt_hertz_t x)
- {
- os << format("%12g Hz") % vrt_hertz_to_double(x);
- os << std::endl;
- }
-
- static void wr_dbm(std::ostream &os, vrt_db_t x)
- {
- os << format("%10g dBm") % vrt_db_to_double(x);
- os << std::endl;
- }
-
- static void wr_db(std::ostream &os, vrt_db_t x)
- {
- os << format("%10g dB") % vrt_db_to_double(x);
- os << std::endl;
- }
-
- static void wr_temp(std::ostream &os, vrt_temp_t x)
- {
- os << format("%10g C") % vrt_temp_to_double(x);
- os << std::endl;
- }
-
- static void wr_angle(std::ostream &os, vrt_angle_t x)
- {
- if (x == VRT_GPS_UNKNOWN_VALUE)
- os << " UNKNOWN";
- else
- os << format("%10g deg") % vrt_angle_to_double(x);
-
- os << std::endl;
- }
-
- static void wr_distance(std::ostream &os, vrt_distance_t x)
- {
- if (x == VRT_GPS_UNKNOWN_VALUE)
- os << " UNKNOWN";
- else
- os << format("%10g m") % vrt_distance_to_double(x);
-
- os << std::endl;
- }
-
- static void wr_velocity(std::ostream &os, vrt_velocity_t x)
- {
- if (x == VRT_GPS_UNKNOWN_VALUE)
- os << " UNKNOWN";
- else
- os << format("%10g m/s") % vrt_velocity_to_double(x);
-
- os << std::endl;
- }
-
- static void wr_payload_fmt(std::ostream &os, vrt_payload_fmt_t f)
- {
- if (f.word0 & DF0_PACKED)
- os << " Packed";
-
- switch (f.word0 & DF0_REAL_CMPLX_TYPE_MASK){
- case DF0_REAL_CMPLX_TYPE_REAL: os << " Real"; break;
- case DF0_REAL_CMPLX_TYPE_CMPLX_CART: os << " Cmplx"; break;
- case DF0_REAL_CMPLX_TYPE_CMPLX_POLAR: os << " Polar"; break;
- case DF0_REAL_CMPLX_TYPE_RESERVED: os << " Reserved"; break;
- }
-
- switch(f.word0 & DF0_ITEM_FMT_MASK){
- case DF0_ITEM_FMT_SIGNED_FIXED_POINT: os << " S-Fixed"; break;
- case DF0_ITEM_FMT_UNSIGNED_FIXED_POINT: os << " U-Fixed"; break;
- case DF0_ITEM_FMT_IEEE_FLOAT: os << " float"; break;
- case DF0_ITEM_FMT_IEEE_DOUBLE: os << " double"; break;
- default:
- os << format(" ItemFmt=%#x") % ((f.word0 & DF0_ITEM_FMT_MASK) >> 24);
- break;
- }
-
- if (f.word0 & DF0_SAMPLE_COMPONENT_REPEATING)
- os << " SampleCompRpt";
-
- uint32_t t = (f.word0 & DF0_EVENT_TAG_SIZE_MASK) >> DF0_EVENT_TAG_SIZE_SHIFT;
- if (t != 0)
- os << format(" EvtTagSize=%d") % t;
-
- t = (f.word0 & DF0_CHANNEL_TAG_SIZE_MASK) >> DF0_CHANNEL_TAG_SIZE_SHIFT;
- if (t != 0)
- os << format(" ChanTagSize=%d") % t;
-
- t = (f.word0 & DF0_ITEM_PACKING_FIELD_SIZE_MASK) >> DF0_ITEM_PACKING_FIELD_SIZE_SHIFT;
- os << format(" FieldSize=%d") % (t + 1);
-
- t = (f.word0 & DF0_DATA_ITEM_SIZE_MASK) >> DF0_DATA_ITEM_SIZE_SHIFT;
- os << format(" ItemSize=%d") % (t + 1);
-
- t = (f.word1 & DF1_REPEAT_COUNT_MASK) >> DF1_REPEAT_COUNT_SHIFT;
- os << format(" RptCnt=%d") % (t + 1);
-
- t = (f.word1 & DF1_VECTOR_SIZE_MASK) >> DF1_VECTOR_SIZE_SHIFT;
- os << format(" VectSize=%d") % (t + 1);
-
- os << std::endl;
- }
-
- static void wr_formatted_gps(std::ostream &os,
- const vrt_formatted_gps_t &x)
- {
- uint32_t t = (x.tsi_tsf_manuf_oui >> 26) & 0x3;
- switch(t){
- case 0x0: os << " TSI=UNDEF"; break;
- case 0x1: os << " TSI=UTC"; break;
- case 0x2: os << " TSI=GPS"; break;
- case 0x3: os << " TSI=OTHER"; break;
- }
-
- t = (x.tsi_tsf_manuf_oui >> 24) & 0x3;
- switch(t){
- case 0x0: os << " TSF=UNDEF"; break;
- case 0x1: os << " TSF=SAMPLE_CNT";break;
- case 0x2: os << " TSI=PICOSECS"; break;
- case 0x3: os << " TSI=FREE_RUN"; break;
- }
-
- t = x.tsi_tsf_manuf_oui & 0x00ffffff;
- os << format(" manuf_oui=%#x\n") % t;
-
- wr_name(os, " fix int secs");
- //os << format("%10d\n") % x.integer_secs;
- wr_int_secs(os, x.integer_secs);
-
- wr_name(os, " fix frac secs");
- os << format("%10d\n") % get_frac_secs(&x.fractional_secs);
-
- wr_name(os, " latitude");
- wr_angle(os, x.latitude);
- wr_name(os, " longitude");
- wr_angle(os, x.longitude);
- wr_name(os, " altitude");
- wr_distance(os, x.altitude);
- wr_name(os, " speed_over_ground");
- wr_velocity(os, x.speed_over_ground);
- wr_name(os, " heading_angle");
- wr_angle(os, x.heading_angle);
- wr_name(os, " track_angle");
- wr_angle(os, x.track_angle);
- wr_name(os, " magnetic_variation");
- wr_angle(os, x.magnetic_variation);
-
- os << std::endl;
- }
-
- static void wr_cntx_list(std::ostream &os, const std::string &name, const std::vector<uint32_t> &v)
+ static void
+ wr_cntx_list(std::ostream &os, const std::string &name, const std::vector<uint32_t> &v)
{
if (v.empty())
return;
@@ -491,7 +343,8 @@ namespace vrt
os << std::endl;
}
- static void wr_cntx_assoc_lists(std::ostream &os, const exp_context_assocs &x)
+ static void
+ wr_cntx_assoc_lists(std::ostream &os, const exp_context_assocs &x)
{
os << std::endl;
wr_cntx_list(os, "source", x.source);
diff --git a/vrt/lib/header_utils.cc b/vrt/lib/header_utils.cc
index 1cd15dedf..0f7ac315d 100644
--- a/vrt/lib/header_utils.cc
+++ b/vrt/lib/header_utils.cc
@@ -20,6 +20,7 @@
*/
#include "header_utils.h"
+#include <vrt/bits.h>
#include <ostream>
#include <time.h>
#include <boost/format.hpp>
@@ -31,6 +32,47 @@ namespace vrt
{
namespace detail {
+ void wr_header(std::ostream &os, uint32_t x)
+ {
+ os << format("%#10x") % x;
+
+ uint32_t t = (x >> 22) & 0x3;
+ switch(t){
+ case 0x0: os << " TSI=NONE"; break;
+ case 0x1: os << " TSI=UTC"; break;
+ case 0x2: os << " TSI=GPS"; break;
+ case 0x3: os << " TSI=OTHER"; break;
+ }
+
+ t = (x >> 20) & 0x3;
+ switch(t){
+ case 0x0: os << " TSF=NONE"; break;
+ case 0x1: os << " TSF=SAMPLE_CNT";break;
+ case 0x2: os << " TSI=PICOSECS"; break;
+ case 0x3: os << " TSI=FREE_RUN"; break;
+ }
+
+ uint32_t pt = x & VRTH_PT_MASK;
+ if (pt == VRTH_PT_IF_CONTEXT || pt == VRTH_PT_EXT_CONTEXT){
+ if (x & VRTH_TSM)
+ os << " TSM=GENERAL";
+ else
+ os << " TSM=EXACT";
+ }
+ else if (0
+ || pt == VRTH_PT_IF_DATA_WITH_SID
+ || pt == VRTH_PT_IF_DATA_NO_SID
+ || pt == VRTH_PT_EXT_DATA_WITH_SID
+ || pt == VRTH_PT_EXT_DATA_NO_SID){
+ if (x & VRTH_START_OF_BURST)
+ os << " SOB";
+ if (x & VRTH_END_OF_BURST)
+ os << " EOB";
+ }
+
+ os << std::endl;
+ }
+
void wr_int_secs(std::ostream &os, uint32_t secs)
{
os << format("%10d") % secs;
@@ -65,5 +107,154 @@ namespace vrt
os << std::endl;
}
+ void wr_hertz(std::ostream &os, vrt_hertz_t x)
+ {
+ os << format("%12g Hz") % vrt_hertz_to_double(x);
+ os << std::endl;
+ }
+
+ void wr_dbm(std::ostream &os, vrt_db_t x)
+ {
+ os << format("%10g dBm") % vrt_db_to_double(x);
+ os << std::endl;
+ }
+
+ void wr_db(std::ostream &os, vrt_db_t x)
+ {
+ os << format("%10g dB") % vrt_db_to_double(x);
+ os << std::endl;
+ }
+
+ void wr_temp(std::ostream &os, vrt_temp_t x)
+ {
+ os << format("%10g C") % vrt_temp_to_double(x);
+ os << std::endl;
+ }
+
+ void wr_angle(std::ostream &os, vrt_angle_t x)
+ {
+ if (x == VRT_GPS_UNKNOWN_VALUE)
+ os << " UNKNOWN";
+ else
+ os << format("%10g deg") % vrt_angle_to_double(x);
+
+ os << std::endl;
+ }
+
+ void wr_distance(std::ostream &os, vrt_distance_t x)
+ {
+ if (x == VRT_GPS_UNKNOWN_VALUE)
+ os << " UNKNOWN";
+ else
+ os << format("%10g m") % vrt_distance_to_double(x);
+
+ os << std::endl;
+ }
+
+ void wr_velocity(std::ostream &os, vrt_velocity_t x)
+ {
+ if (x == VRT_GPS_UNKNOWN_VALUE)
+ os << " UNKNOWN";
+ else
+ os << format("%10g m/s") % vrt_velocity_to_double(x);
+
+ os << std::endl;
+ }
+
+ void wr_payload_fmt(std::ostream &os, vrt_payload_fmt_t f)
+ {
+ if (f.word0 & DF0_PACKED)
+ os << " Packed";
+
+ switch (f.word0 & DF0_REAL_CMPLX_TYPE_MASK){
+ case DF0_REAL_CMPLX_TYPE_REAL: os << " Real"; break;
+ case DF0_REAL_CMPLX_TYPE_CMPLX_CART: os << " Cmplx"; break;
+ case DF0_REAL_CMPLX_TYPE_CMPLX_POLAR: os << " Polar"; break;
+ case DF0_REAL_CMPLX_TYPE_RESERVED: os << " Reserved"; break;
+ }
+
+ switch(f.word0 & DF0_ITEM_FMT_MASK){
+ case DF0_ITEM_FMT_SIGNED_FIXED_POINT: os << " S-Fixed"; break;
+ case DF0_ITEM_FMT_UNSIGNED_FIXED_POINT: os << " U-Fixed"; break;
+ case DF0_ITEM_FMT_IEEE_FLOAT: os << " float"; break;
+ case DF0_ITEM_FMT_IEEE_DOUBLE: os << " double"; break;
+ default:
+ os << format(" ItemFmt=%#x") % ((f.word0 & DF0_ITEM_FMT_MASK) >> 24);
+ break;
+ }
+
+ if (f.word0 & DF0_SAMPLE_COMPONENT_REPEATING)
+ os << " SampleCompRpt";
+
+ uint32_t t = (f.word0 & DF0_EVENT_TAG_SIZE_MASK) >> DF0_EVENT_TAG_SIZE_SHIFT;
+ if (t != 0)
+ os << format(" EvtTagSize=%d") % t;
+
+ t = (f.word0 & DF0_CHANNEL_TAG_SIZE_MASK) >> DF0_CHANNEL_TAG_SIZE_SHIFT;
+ if (t != 0)
+ os << format(" ChanTagSize=%d") % t;
+
+ t = (f.word0 & DF0_ITEM_PACKING_FIELD_SIZE_MASK) >> DF0_ITEM_PACKING_FIELD_SIZE_SHIFT;
+ os << format(" FieldSize=%d") % (t + 1);
+
+ t = (f.word0 & DF0_DATA_ITEM_SIZE_MASK) >> DF0_DATA_ITEM_SIZE_SHIFT;
+ os << format(" ItemSize=%d") % (t + 1);
+
+ t = (f.word1 & DF1_REPEAT_COUNT_MASK) >> DF1_REPEAT_COUNT_SHIFT;
+ os << format(" RptCnt=%d") % (t + 1);
+
+ t = (f.word1 & DF1_VECTOR_SIZE_MASK) >> DF1_VECTOR_SIZE_SHIFT;
+ os << format(" VectSize=%d") % (t + 1);
+
+ os << std::endl;
+ }
+
+ void wr_formatted_gps(std::ostream &os,
+ const vrt_formatted_gps_t &x)
+ {
+ uint32_t t = (x.tsi_tsf_manuf_oui >> 26) & 0x3;
+ switch(t){
+ case 0x0: os << " TSI=UNDEF"; break;
+ case 0x1: os << " TSI=UTC"; break;
+ case 0x2: os << " TSI=GPS"; break;
+ case 0x3: os << " TSI=OTHER"; break;
+ }
+
+ t = (x.tsi_tsf_manuf_oui >> 24) & 0x3;
+ switch(t){
+ case 0x0: os << " TSF=UNDEF"; break;
+ case 0x1: os << " TSF=SAMPLE_CNT";break;
+ case 0x2: os << " TSI=PICOSECS"; break;
+ case 0x3: os << " TSI=FREE_RUN"; break;
+ }
+
+ t = x.tsi_tsf_manuf_oui & 0x00ffffff;
+ os << format(" manuf_oui=%#x\n") % t;
+
+ wr_name(os, " fix int secs");
+ //os << format("%10d\n") % x.integer_secs;
+ wr_int_secs(os, x.integer_secs);
+
+ wr_name(os, " fix frac secs");
+ os << format("%10d\n") % get_frac_secs(&x.fractional_secs);
+
+ wr_name(os, " latitude");
+ wr_angle(os, x.latitude);
+ wr_name(os, " longitude");
+ wr_angle(os, x.longitude);
+ wr_name(os, " altitude");
+ wr_distance(os, x.altitude);
+ wr_name(os, " speed_over_ground");
+ wr_velocity(os, x.speed_over_ground);
+ wr_name(os, " heading_angle");
+ wr_angle(os, x.heading_angle);
+ wr_name(os, " track_angle");
+ wr_angle(os, x.track_angle);
+ wr_name(os, " magnetic_variation");
+ wr_angle(os, x.magnetic_variation);
+
+ os << std::endl;
+ }
+
};
};
diff --git a/vrt/lib/header_utils.h b/vrt/lib/header_utils.h
index df087eac8..0d006ffdc 100644
--- a/vrt/lib/header_utils.h
+++ b/vrt/lib/header_utils.h
@@ -22,17 +22,29 @@
#define INCLUDED_VRT_HEADER_UTILS_H
#include <iosfwd>
+#include <string>
#include <stdint.h>
+#include <vrt/bits.h>
namespace vrt
{
namespace detail {
+ void wr_header(std::ostream &os, uint32_t x);
void wr_name(std::ostream &os, const std::string &x);
void wr_int_secs(std::ostream &os, uint32_t secs);
void wr_uint32_hex(std::ostream &os, uint32_t x);
void wr_uint32_dec(std::ostream &os, uint32_t x);
-
+ void wr_hertz(std::ostream &os, vrt_hertz_t x);
+ void wr_dbm(std::ostream &os, vrt_db_t x);
+ void wr_db(std::ostream &os, vrt_db_t x);
+ void wr_temp(std::ostream &os, vrt_temp_t x);
+ void wr_angle(std::ostream &os, vrt_angle_t x);
+ void wr_distance(std::ostream &os, vrt_distance_t x);
+ void wr_velocity(std::ostream &os, vrt_velocity_t x);
+ void wr_payload_fmt(std::ostream &os, vrt_payload_fmt_t f);
+ void wr_formatted_gps(std::ostream &os,
+ const vrt_formatted_gps_t &x);
};
};