summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vrt/lib/Makefile.am2
-rw-r--r--vrt/lib/expanded_header.cc6
-rw-r--r--vrt/lib/expanded_if_context_section.cc8
-rw-r--r--vrt/lib/header_utils.cc52
-rw-r--r--vrt/lib/header_utils.h36
5 files changed, 101 insertions, 3 deletions
diff --git a/vrt/lib/Makefile.am b/vrt/lib/Makefile.am
index 8ed5b0e87..ef2110876 100644
--- a/vrt/lib/Makefile.am
+++ b/vrt/lib/Makefile.am
@@ -33,6 +33,7 @@ libvrt_la_SOURCES = \
data_handler.cc \
expanded_header.cc \
expanded_if_context_section.cc \
+ header_utils.cc \
rx.cc \
rx_packet_handler.cc \
socket_rx_buffer.cc
@@ -46,6 +47,7 @@ noinst_HEADERS = \
data_handler.h \
expanded_header_unpack_switch_body.h \
expanded_header_pack_switch_body.h \
+ header_utils.h \
socket_rx_buffer.h
EXTRA_DIST = \
diff --git a/vrt/lib/expanded_header.cc b/vrt/lib/expanded_header.cc
index 85a27f830..06056551e 100644
--- a/vrt/lib/expanded_header.cc
+++ b/vrt/lib/expanded_header.cc
@@ -25,6 +25,7 @@
#include <vrt/expanded_header.h>
#include <gruel/inet.h>
#include <boost/format.hpp>
+#include "header_utils.h"
using boost::format;
using boost::io::group;
@@ -32,6 +33,8 @@ using boost::io::group;
namespace vrt {
+ using namespace detail;
+
// lookup tables indexed by packet type
unsigned char expanded_header::s_if_data[16] = {
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -183,7 +186,8 @@ namespace vrt {
if (integer_secs_p()){
wr_name(port, "int secs");
- port << format("%10d\n") % integer_secs;
+ //port << format("%10d\n") % integer_secs;
+ wr_int_secs(port, integer_secs);
}
if (fractional_secs_p()){
diff --git a/vrt/lib/expanded_if_context_section.cc b/vrt/lib/expanded_if_context_section.cc
index b44cc9b0b..80232a807 100644
--- a/vrt/lib/expanded_if_context_section.cc
+++ b/vrt/lib/expanded_if_context_section.cc
@@ -26,6 +26,7 @@
#include <string.h>
#include <gruel/inet.h> // ntohl
#include <boost/format.hpp>
+#include "header_utils.h"
using boost::format;
using boost::io::group;
@@ -33,6 +34,8 @@ using boost::io::group;
namespace vrt
{
+ using namespace detail;
+
void
expanded_if_context_section::clear()
{
@@ -470,7 +473,8 @@ namespace vrt
os << format(" manuf_oui=%#10x") % t;
wr_name(os, "fix int secs");
- os << format("%10d\n") % x.integer_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);
@@ -578,7 +582,7 @@ namespace vrt
if (cif & CI_TIMESTAMP_CAL_TIME){
wr_name(os, "timestamp_cal_time");
- wr_uint32_dec(os, timestamp_cal_time);
+ wr_int_secs(os, timestamp_cal_time);
}
if (cif & CI_TEMPERATURE){
diff --git a/vrt/lib/header_utils.cc b/vrt/lib/header_utils.cc
new file mode 100644
index 000000000..3c97df861
--- /dev/null
+++ b/vrt/lib/header_utils.cc
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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.
+ *
+ * GNU Radio 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "header_utils.h"
+#include <ostream>
+#include <time.h>
+#include <boost/format.hpp>
+
+using boost::format;
+using boost::io::group;
+
+namespace vrt
+{
+ namespace detail {
+
+ void wr_int_secs(std::ostream &os, uint32_t secs)
+ {
+ os << format("%10d") % secs;
+
+ time_t t = secs;
+ struct tm r;
+
+ if (gmtime_r(&t, &r)){
+ // ISO 8601 date + time
+ os << format(" %04d-%02d-%02d %02d:%02d:%02dZ")
+ % (r.tm_year + 1900) % (r.tm_mon + 1) % r.tm_mday
+ % r.tm_hour % r.tm_min % r.tm_sec;
+ }
+
+ os << std::endl;
+ }
+
+ };
+};
diff --git a/vrt/lib/header_utils.h b/vrt/lib/header_utils.h
new file mode 100644
index 000000000..823d37b6b
--- /dev/null
+++ b/vrt/lib/header_utils.h
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio 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.
+ *
+ * GNU Radio 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_VRT_HEADER_UTILS_H
+#define INCLUDED_VRT_HEADER_UTILS_H
+
+#include <iosfwd>
+#include <stdint.h>
+
+namespace vrt
+{
+ namespace detail {
+
+ void wr_int_secs(std::ostream &os, uint32_t secs);
+
+ };
+};
+
+#endif /* INCLUDED_VRT_HEADER_UTILS_H */