summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-01-13 10:14:45 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-01-13 10:14:45 +0100
commit0f9f51279b77fecc1d8c9ea8fe0fc62d8e945645 (patch)
treed23947320efe789e351a2ebd288c96a23095d3ec
parentc74279c0af306e2fb4a1f03b0a698fb239f4c33b (diff)
downloaddabmod-0f9f51279b77fecc1d8c9ea8fe0fc62d8e945645.tar.gz
dabmod-0f9f51279b77fecc1d8c9ea8fe0fc62d8e945645.tar.bz2
dabmod-0f9f51279b77fecc1d8c9ea8fe0fc62d8e945645.zip
Update edi code from edilib
-rw-r--r--lib/edi/ETIDecoder.cpp2
-rw-r--r--lib/edi/PFT.cpp32
-rw-r--r--lib/edi/PFT.hpp11
3 files changed, 33 insertions, 12 deletions
diff --git a/lib/edi/ETIDecoder.cpp b/lib/edi/ETIDecoder.cpp
index 939706b..78e0ea6 100644
--- a/lib/edi/ETIDecoder.cpp
+++ b/lib/edi/ETIDecoder.cpp
@@ -406,7 +406,7 @@ bool ETIDecoder::decode_estn(const vector<uint8_t> &value, uint8_t n)
return true;
}
-bool ETIDecoder::decode_stardmy(const vector<uint8_t> &value)
+bool ETIDecoder::decode_stardmy(const vector<uint8_t>& /*value*/)
{
return true;
}
diff --git a/lib/edi/PFT.cpp b/lib/edi/PFT.cpp
index 4bd1030..4348f14 100644
--- a/lib/edi/PFT.cpp
+++ b/lib/edi/PFT.cpp
@@ -445,6 +445,22 @@ std::vector<uint8_t> AFBuilder::extractAF() const
return _af_packet;
}
+std::string AFBuilder::visualise() const
+{
+ stringstream ss;
+ ss << "|";
+ for (size_t i = 0; i < _Fcount; i++) {
+ if (_fragments.count(i)) {
+ ss << ".";
+ }
+ else {
+ ss << " ";
+ }
+ }
+ ss << "| " << AFBuilder::dar_to_string(canAttemptToDecode()) << " " << lifeTime;
+ return ss.str();
+}
+
void PFT::pushPFTFrag(const Fragment &fragment)
{
// Start decoding the first pseq we receive. In normal
@@ -473,11 +489,12 @@ void PFT::pushPFTFrag(const Fragment &fragment)
p.pushPFTFrag(fragment);
#if 0
- etiLog.log(debug, "After new frag with pseq %u, afbuilders: ", fragment.Pseq());
+ etiLog.log(debug, "Got frag %u:%u, afbuilders: ",
+ fragment.Pseq(), fragment.Findex());
for (const auto &k : m_afbuilders) {
- etiLog.log(debug, "%u ", k.first);
+ const bool isNextPseq = (m_next_pseq == k.first);
+ etiLog.level(debug) << (isNextPseq ? "->" : " ") << k.first << " " << k.second.visualise();
}
- etiLog.log(debug, "\n");
#endif
}
@@ -494,21 +511,16 @@ std::vector<uint8_t> PFT::getNextAFPacket()
}
auto &builder = m_afbuilders.at(m_next_pseq);
- //const auto nf = builder.numberOfFragments();
using dar_t = AFBuilder::decode_attempt_result_t;
if (builder.canAttemptToDecode() == dar_t::yes) {
- //etiLog.log(debug, "pseq %d (%d %d/%d) yes\n",
- // m_next_pseq, lt, nf.first, nf.second);
auto afpacket = builder.extractAF();
assert(not afpacket.empty());
incrementNextPseq();
return afpacket;
}
else if (builder.canAttemptToDecode() == dar_t::maybe) {
- //etiLog.log(debug, "pseq %d (%d %d/%d) maybe\n",
- // m_next_pseq, lt, nf.first, nf.second);
if (builder.lifeTime > 0) {
builder.lifeTime--;
}
@@ -518,15 +530,13 @@ std::vector<uint8_t> PFT::getNextAFPacket()
auto afpacket = builder.extractAF();
if (afpacket.empty()) {
- etiLog.log(debug,"pseq %d timed out after RS\n", m_next_pseq);
+ etiLog.log(debug,"pseq %d timed out after RS", m_next_pseq);
}
incrementNextPseq();
return afpacket;
}
}
else {
- //etiLog.log(debug, "pseq %d (%d %d/%d) no\n",
- // m_next_pseq, lt, nf.first, nf.second);
if (builder.lifeTime > 0) {
builder.lifeTime--;
}
diff --git a/lib/edi/PFT.hpp b/lib/edi/PFT.hpp
index 9b65d2e..1a2f617 100644
--- a/lib/edi/PFT.hpp
+++ b/lib/edi/PFT.hpp
@@ -83,6 +83,15 @@ class AFBuilder
no, // Not enough fragments present to permit RS
};
+ static std::string dar_to_string(decode_attempt_result_t dar) {
+ switch (dar) {
+ case decode_attempt_result_t::yes: return "y";
+ case decode_attempt_result_t::no: return "n";
+ case decode_attempt_result_t::maybe: return "m";
+ }
+ return "?";
+ }
+
AFBuilder(pseq_t Pseq, findex_t Fcount, size_t lifetime);
void pushPFTFrag(const Fragment &frag);
@@ -101,6 +110,8 @@ class AFBuilder
return {_fragments.size(), _Fcount};
}
+ std::string visualise(void) const;
+
/* The user of this instance can keep track of the lifetime of this
* builder
*/