summaryrefslogtreecommitdiffstats
path: root/lib/edi/common.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-09-05 17:09:18 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-09-05 17:09:18 +0200
commit1ed62f38f32b219f1eb7e9e06024f9fa86eb58bc (patch)
tree3e9efdc4d4b04171136a00cf772edf93f0bac04e /lib/edi/common.cpp
parenteb9652e7406a693617932e5c4ed2bcd40d069c06 (diff)
downloaddabmux-1ed62f38f32b219f1eb7e9e06024f9fa86eb58bc.tar.gz
dabmux-1ed62f38f32b219f1eb7e9e06024f9fa86eb58bc.tar.bz2
dabmux-1ed62f38f32b219f1eb7e9e06024f9fa86eb58bc.zip
lib: update from common code cdf104a and 2847f4d
Diffstat (limited to 'lib/edi/common.cpp')
-rw-r--r--lib/edi/common.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/edi/common.cpp b/lib/edi/common.cpp
index b4b0c79..4629b55 100644
--- a/lib/edi/common.cpp
+++ b/lib/edi/common.cpp
@@ -61,6 +61,25 @@ time_t frame_timestamp_t::to_unix_epoch() const
return 946684800 + seconds - utco;
}
+double frame_timestamp_t::diff_ms(const frame_timestamp_t& other) const
+{
+ const double lhs = (double)seconds + (tsta / 16384000.0);
+ const double rhs = (double)other.seconds + (other.tsta / 16384000.0);
+ return lhs - rhs;
+}
+
+frame_timestamp_t frame_timestamp_t::from_unix_epoch(std::time_t time, uint32_t tai_utc_offset, uint32_t tsta)
+{
+ frame_timestamp_t ts;
+
+ const std::time_t posix_timestamp_1_jan_2000 = 946684800;
+
+ ts.utco = tai_utc_offset - 32;
+ ts.seconds = time - posix_timestamp_1_jan_2000 + ts.utco;
+ ts.tsta = tsta;
+ return ts;
+}
+
std::chrono::system_clock::time_point frame_timestamp_t::to_system_clock() const
{
auto ts = chrono::system_clock::from_time_t(to_unix_epoch());
@@ -202,7 +221,7 @@ decode_state_t TagDispatcher::decode_afpacket(
return {false, 0};
}
- if (m_last_seq + 1 != seq) {
+ if (m_last_seq + (uint16_t)1 != seq) {
etiLog.level(warn) << "EDI AF Packet sequence error, " << seq;
}
m_last_seq = seq;