diff --git a/decoder/src/lib/data_unit.cc b/decoder/src/lib/data_unit.cc index 354fed1..57e7301 100644 --- a/decoder/src/lib/data_unit.cc +++ b/decoder/src/lib/data_unit.cc @@ -29,6 +29,9 @@ #include #include +#include +using namespace std; + data_unit_sptr data_unit::make_data_unit(const_bit_queue& frame_body) { diff --git a/decoder/src/lib/hdu.cc b/decoder/src/lib/hdu.cc index 7b95a48..2b79115 100644 --- a/decoder/src/lib/hdu.cc +++ b/decoder/src/lib/hdu.cc @@ -29,6 +29,7 @@ #include #include +#include using namespace std; hdu::hdu(const_bit_queue& frame_body) : @@ -49,68 +50,71 @@ hdu::duid_str() const std::string hdu::snapshot() const { + size_t n = 0; ostringstream os; + // Begin + os << "(d"; + os << "p" << n++ << endl; + + // NID = NAC+DUID + // DUID - os << "(dp0" << endl; os << "S'duid'" << endl; - os << "p1" << endl; + os << "p" << n++ << endl; os << "S'" << duid_str() << "'" << endl; // NAC - os << "p2" << endl; + os << "p" << n++ << endl; os << "sS'nac'" << endl; - os << "p3" << endl; + os << "p" << n++ << endl; os << "S'" << nac_str() << "'" << endl; -#if 0 - // MI - os << "p4" << endl; - os << "sS'mi'" << endl; - os << "p5" << endl; - os << "S'" << mi_str() << "'" << endl; -#endif - - os << "p4" << endl; - os << "s." << endl; - -#if 0 // Source - os << "S'source'" << endl; - os << "p5" << endl; - os << "S''" << endl; - os << "p6" << endl; + os << "p" << n++ << endl; + os << "sS'source'" << endl; + os << "p" << n++ << endl; + os << "S'" << src_str() << "'" << endl; + // Dest - os << "S'dest'" << endl; - os << "p7" << endl; - os << "S''" << endl; - os << "p8" << endl; - // NID - os << "S'nid'" << endl; - os << "p9" << endl; - os << "S''" << endl; - os << "p10" << endl; + os << "p" << n++ << endl; + os << "sS'dest'" << endl; + os << "p" << n++ << endl; + os << "S'" << dest_str() << "'" << endl; + // MFID - os << "S'mfid'" << endl; - os << "p11" << endl; + os << "p" << n++ << endl; + os << "sS'mfid'" << endl; + os << "p" << n++ << endl; os << "S'" << mfid_str() << "'" << endl; - os << "p12" << endl; + // ALGID - os << "p3" << endl; - os << "S'algid'" << endl; - os << "p4" << endl; - os << "sS'" << algid_str() << "'" << endl; + os << "p" << n++ << endl; + os << "sS'algid'" << endl; + os << "p" << n++ << endl; + os << "S'" << algid_str() << "'" << endl; + // KID - os << "S'kid'" << endl; - os << "p15" << endl; - os << "S''" << endl; - os << "p16" << endl; + os << "p" << n++ << endl; + os << "sS'kid'" << endl; + os << "p" << n++ << endl; + os << "S'" << kid_str() << "'" << endl; + + // MI + os << "p" << n++ << endl; + os << "sS'mi'" << endl; + os << "p" << n++ << endl; + os << "S'" << mi_str() << "'" << endl; // TGID - os << "S'tgid'" << endl; - os << "p19" << endl; - os << "S''" << endl; -#endif + os << "p" << n++ << endl; + os << "sS'tgid'" << endl; + os << "p" << n++ << endl; + os << "S'" << tgid_str() << "'" << endl; + + // End + os << "p" << n++ << endl; + os << "s." << endl; return os.str(); } @@ -203,6 +207,18 @@ hdu::algid_str() const return lookup(algid, ALGIDS, ALGIDS_SZ); } +string +hdu::dest_str() const +{ + return "ToDo"; +} + +string +hdu::kid_str() const +{ + return "ToDo"; +} + std::string hdu::mi_str() const { @@ -226,6 +242,9 @@ hdu::mi_str() const uint16_t octet = mi[i]; os << hex << setfill('0') << setw(2) << octet; } + + clog << os.str() << endl; + return os.str(); } @@ -250,3 +269,15 @@ hdu::nac_str() const uint32_t nac = extract(frame_body(), NAC_BITS, NAC_BITS_SZ); return lookup(nac, NACS, NACS_SZ); } + +string +hdu::src_str() const +{ + return "ToDo"; +} + +string +hdu::tgid_str() const +{ + return "ToDo"; +} diff --git a/decoder/src/lib/hdu.h b/decoder/src/lib/hdu.h index ef0d874..82d5576 100644 --- a/decoder/src/lib/hdu.h +++ b/decoder/src/lib/hdu.h @@ -105,6 +105,20 @@ private: */ std::string algid_str() const; + /** + * Returns a string describing the message destination. + * + * \return A string identifying the source. + */ + virtual std::string dest_str() const; + + /** + * Returns a string describing the key id (KID). + * + * \return A string identifying the KID. + */ + virtual std::string kid_str() const; + /** * Returns a string describing the manufacturer ID (MFID). * @@ -115,7 +129,7 @@ private: /** * Returns a string describing the message indicator (MI). * - * \return A string identifying the MI + * \return A string identifying the MI. */ virtual std::string mi_str() const; @@ -126,6 +140,19 @@ private: */ virtual std::string nac_str() const; + /** + * Returns a string describing the message source. + * + * \return A string identifying the source. + */ + virtual std::string src_str() const; + + /** + * Returns a string describing the talk group id (TGID). + * + * \return A string identifying the TGID. + */ + virtual std::string tgid_str() const; }; #endif /* INCLUDED_HDU_H */ diff --git a/decoder/src/lib/op25_decoder_ff.cc b/decoder/src/lib/op25_decoder_ff.cc index 41bc1b7..743ad7f 100644 --- a/decoder/src/lib/op25_decoder_ff.cc +++ b/decoder/src/lib/op25_decoder_ff.cc @@ -144,7 +144,8 @@ op25_decoder_ff::identified() itpp::BCH bch(63, 16, 11,"6 3 3 1 1 4 1 3 6 7 2 3 5 4 5 3", true); swab(d_frame_hdr, NID, NID_SZ, b, 0); b = bch.decode(b); - if(b != zeroes) { + bool identified(b != zeroes); + if(identified) { b = bch.encode(b); unswab(b, 0, d_frame_hdr, NID, NID_SZ); d_data_unit = data_unit::make_data_unit(d_frame_hdr); @@ -152,7 +153,7 @@ op25_decoder_ff::identified() data_unit_sptr null; d_data_unit = null; } - return d_data_unit; + return identified; } void