aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-06 16:27:33 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-05-06 16:27:33 +0200
commit8e58cdc98ced276cf04fb8b330b4426327a6ebcc (patch)
tree4701a2754c5aba58b22d9b99193d661b1e0d021a
parent7d3a19da3bd0ff290905c301536e17a9af7bd55c (diff)
downloadodr-edilib-8e58cdc98ced276cf04fb8b330b4426327a6ebcc.tar.gz
odr-edilib-8e58cdc98ced276cf04fb8b330b4426327a6ebcc.tar.bz2
odr-edilib-8e58cdc98ced276cf04fb8b330b4426327a6ebcc.zip
Show timestamps for TCP
-rw-r--r--test/main.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/test/main.cpp b/test/main.cpp
index 39ea1d3..9d76050 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -150,6 +150,31 @@ static options_t parseargs(int argc, char **argv)
return options;
}
+static void analyse_timestamp(
+ TimestampDecoder& ts_dec,
+ EdiDecoder::ETIWriter& writer,
+ const EdiDecoder::eti_frame_t& eti
+ )
+{
+ const uint8_t fct = eti.frame[4];
+ const std::time_t now = std::time(nullptr);
+
+ ts_dec.updateTimestampEti(writer.get_framephase(), writer.get_mnsc(), writer.get_timestamp(), fct);
+
+ const auto ts = ts_dec.getTimestamp();
+
+ fprintf(stderr, "%ld: Got ETI Frame with FCT %d at %s: seconds=%d, utco=%d, now-EDI=%ld, MNSC: %d, now-MNSC=%ld, MNSC-EDI=%ld\n",
+ now,
+ fct,
+ eti.calculate_timestamp().c_str(),
+ eti.seconds, eti.utco,
+ now - eti.timestamp_in_unix_epoch(),
+ ts->timestamp_sec,
+ now - ts->timestamp_sec,
+ ts->timestamp_sec - eti.timestamp_in_unix_epoch()
+ );
+}
+
int main(int argc, char **argv)
{
if (argc == 1) {
@@ -206,25 +231,8 @@ int main(int argc, char **argv)
}
const auto eti = writer.getEtiFrame();
-
if (not eti.frame.empty() and options.verbose > 0) {
- const uint8_t fct = eti.frame[4];
- const std::time_t now = std::time(nullptr);
-
- ts_dec.updateTimestampEti(writer.get_framephase(), writer.get_mnsc(), writer.get_timestamp(), fct);
-
- const auto ts = ts_dec.getTimestamp();
-
- fprintf(stderr, "%ld: Got ETI Frame with FCT %d at %s: seconds=%d, utco=%d, now-EDI=%ld, MNSC: %d, now-MNSC=%ld, MNSC-EDI=%ld\n",
- now,
- fct,
- eti.calculate_timestamp().c_str(),
- eti.seconds, eti.utco,
- now - eti.timestamp_in_unix_epoch(),
- ts->timestamp_sec,
- now - ts->timestamp_sec,
- ts->timestamp_sec - eti.timestamp_in_unix_epoch()
- );
+ analyse_timestamp(ts_dec, writer, eti);
}
if (fd_eti and not eti.frame.empty()) {
@@ -273,6 +281,9 @@ int main(int argc, char **argv)
decoder.push_bytes(buf);
const auto eti = writer.getEtiFrame();
+ if (not eti.frame.empty() and options.verbose > 0) {
+ analyse_timestamp(ts_dec, writer, eti);
+ }
if (fd_eti) {
if (not eti.frame.empty()) {
fwrite(eti.frame.data(), eti.frame.size(), 1, fd_eti);