From 4fb88ffb7347ebbedc2248d4161a1c9ef09d2943 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 28 May 2023 10:40:24 -0400 Subject: [PATCH 01/22] trying to debug --- trunk-recorder/systems/p25_parser.cc | 284 ++++++++++++++++----------- trunk-recorder/systems/p25_parser.h | 1 + 2 files changed, 165 insertions(+), 120 deletions(-) diff --git a/trunk-recorder/systems/p25_parser.cc b/trunk-recorder/systems/p25_parser.cc index af94f8604..830f15d9a 100644 --- a/trunk-recorder/systems/p25_parser.cc +++ b/trunk-recorder/systems/p25_parser.cc @@ -38,18 +38,6 @@ double P25Parser::get_bandwidth(int chan_id, int sys_num) { return 0; } -std::string P25Parser::channel_id_to_string(int chan_id, int sys_num) { - double f = channel_id_to_frequency(chan_id, sys_num); - - if (f == 0) { - return "ID"; // << std::hex << chan_id; - } else { - std::ostringstream strs; - strs << f / 1000000.0; - return strs.str(); - } -} - double P25Parser::channel_id_to_frequency(int chan_id, int sys_num) { // long id = (chan_id >> 12) & 0xf; long channel = chan_id & 0xfff; @@ -68,6 +56,18 @@ double P25Parser::channel_id_to_frequency(int chan_id, int sys_num) { return 0; } +std::string P25Parser::channel_id_to_string(int chan_id, int sys_num) { + double f = channel_id_to_frequency(chan_id, sys_num); + + if (f == 0) { + return "ID"; // << std::hex << chan_id; + } else { + std::ostringstream strs; + strs << f / 1000000.0; + return strs.str(); + } +} + unsigned long P25Parser::bitset_shift_mask(boost::dynamic_bitset<> &tsbk, int shift, unsigned long long mask) { boost::dynamic_bitset<> bitmask(tsbk.size(), mask); unsigned long result = ((tsbk >> shift) & bitmask).to_ulong(); @@ -78,6 +78,16 @@ unsigned long P25Parser::bitset_shift_mask(boost::dynamic_bitset<> &tsbk, int sh return result; } +unsigned long P25Parser::bitset_shift_left_mask(boost::dynamic_bitset<> &tsbk, int shift, unsigned long long mask) { + boost::dynamic_bitset<> bitmask(tsbk.size(), mask); + unsigned long result = ((tsbk << shift) & bitmask).to_ulong(); + + // std::cout << " " << std::dec<< shift << " " << tsbk.size() << " [ " << + // mask << " ] = " << result << " - " << ((tsbk >> shift) & bitmask) << + // std::endl; + return result; +} + std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost::dynamic_bitset<> &header, boost::dynamic_bitset<> &mbt_data, unsigned long sa, unsigned long nac, int sys_num) { std::vector messages; TrunkMessage message; @@ -99,19 +109,21 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.freq = 0; message.opcode = opcode; - BOOST_LOG_TRIVIAL(trace) << "decode_mbt_data: $" << opcode; + BOOST_LOG_TRIVIAL(info) << "decode_mbt_data: $" << opcode; if (opcode == 0x0) { // grp voice channel grant // unsigned long mfrid = bitset_shift_mask(header, 72, 0xff); + unsigned long ch1 = bitset_shift_mask(mbt_data, 64, 0xffff); + unsigned long ch2 = bitset_shift_mask(mbt_data, 48, 0xffff); + unsigned long ga = bitset_shift_mask(mbt_data, 32, 0xffff); + unsigned long f1 = channel_id_to_frequency(ch1, sys_num); + unsigned long f2 = channel_id_to_frequency(ch2, sys_num); unsigned long sa = bitset_shift_mask(header, 48, 0xffffff); bool emergency = (bool)bitset_shift_mask(header, 24, 0x80); bool encrypted = (bool)bitset_shift_mask(header, 24, 0x40); bool duplex = (bool)bitset_shift_mask(header, 24, 0x20); bool mode = (bool)bitset_shift_mask(header, 24, 0x10); unsigned long priority = bitset_shift_mask(header, 24, 0x07); - unsigned long ch1 = bitset_shift_mask(mbt_data, 64, 0xffff); - // unsigned long ch2 = bitset_shift_mask(mbt_data, 48, 0xffff); - unsigned long ga = bitset_shift_mask(mbt_data, 32, 0xffff); - unsigned long f1 = channel_id_to_frequency(ch1, sys_num); + message.message_type = GRANT; message.freq = f1; @@ -131,9 +143,46 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.tdma_slot = 0; } - os << "mbt00\tChan Grant\tChannel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga << "\tTDMA " << get_tdma_slot(ch1, sys_num) << "\tsa " << sa << "\tEncrypt " << encrypted << "\tBandwidth: " << get_bandwidth(ch1, sys_num); + os << "mbt00\tChan Grant\tChannel 1 ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tChannel 2 ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tga " << std::setw(7) << ga << "\tTDMA " << get_tdma_slot(ch1, sys_num) << "\tsa " << sa << "\tEncrypt " << encrypted << "\tBandwidth: " << get_bandwidth(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(debug) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); + } else if (opcode == 0x02) { // grp regroup voice channel grant + unsigned long mfrid = bitset_shift_mask(mbt_data, 168, 0xff); + if (mfrid == 0x90) { // MOT_GRG_CN_GRANT_EXP + unsigned long ch1 = bitset_shift_mask(mbt_data, 80, 0xffff); + unsigned long ch2 = bitset_shift_mask(mbt_data, 64, 0xffff); + unsigned long sg = bitset_shift_mask(mbt_data, 48, 0xffff); + unsigned long f1 = channel_id_to_frequency(ch1, sys_num); + unsigned long f2 = channel_id_to_frequency(ch2, sys_num); + message.message_type = GRANT; + message.freq = f1; + message.talkgroup = sg; + + if (get_tdma_slot(ch1, sys_num) >= 0) { + message.phase2_tdma = true; + message.tdma_slot = get_tdma_slot(ch1, sys_num); + } else { + message.phase2_tdma = false; + message.tdma_slot = 0; + } + + os << "mbt02\tmfid90_grg_cn_grant_exp\tChannel 1 ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tChannel 2 ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tsg " << std::setw(7) << sg << "\tTDMA " << get_tdma_slot(ch1, sys_num) << "\tBandwidth: " << get_bandwidth(ch1, sys_num); + message.meta = os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); + } + } else if (opcode == 0x028) { // grp_aff_rsp + unsigned long mfrid = bitset_shift_mask(mbt_data, 56, 0xff); + unsigned long wacn = (bitset_shift_left_mask(header, 4, 0xffff0) + bitset_shift_mask(mbt_data, 188, 0xf)); + unsigned long syid = bitset_shift_mask(mbt_data, 176, 0xfff); + unsigned long gid = bitset_shift_mask(mbt_data, 160, 0xffff); + unsigned long ada = bitset_shift_mask(mbt_data, 144, 0xffff); + unsigned long ga = bitset_shift_mask(mbt_data, 128, 0xffff); + unsigned long lg = bitset_shift_mask(mbt_data, 127, 0x1); + unsigned long gav = bitset_shift_mask(mbt_data, 120, 0x3); + + os << "mbt28\tmbt(0x28) grp_aff_rsp:\tMFRID: " << mfrid << "\tWACN: " << wacn << "\tSYID: " << syid << "\tLG: " << lg << "\tGAV: " << gav << "\tADA: " << ada << "\tGA: " << ga << "\tLG: " << lg; + message.meta = os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } else if (opcode == 0x3a) { // rfss status unsigned long syid = bitset_shift_mask(header, 48, 0xfff); unsigned long rfid = bitset_shift_mask(mbt_data, 88, 0xff); @@ -146,7 +195,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.sys_id = syid; os << "mbt3a rfss status: syid: " << syid << " rfid " << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ")"; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } else if (opcode == 0x3b) { // network status unsigned long wacn = bitset_shift_mask(mbt_data, 76, 0xfffff); unsigned long syid = bitset_shift_mask(header, 48, 0xfff); @@ -161,14 +210,14 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.sys_id = syid; message.freq = f1; } - BOOST_LOG_TRIVIAL(trace) << "mbt3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; + BOOST_LOG_TRIVIAL(info) << "mbt3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; } else if (opcode == 0x3c) { // adjacent status unsigned long syid = bitset_shift_mask(header, 48, 0xfff); unsigned long rfid = bitset_shift_mask(header, 24, 0xff); unsigned long stid = bitset_shift_mask(header, 16, 0xff); unsigned long ch1 = bitset_shift_mask(mbt_data, 80, 0xffff); unsigned long ch2 = bitset_shift_mask(mbt_data, 64, 0xffff); - BOOST_LOG_TRIVIAL(trace) << "mbt3c adjacent status " + BOOST_LOG_TRIVIAL(info) << "mbt3c adjacent status " << "syid " << syid << " rfid " << rfid << " stid " << stid << " ch1 " << ch1 << " ch2 " << ch2; } else if (opcode == 0x04) { // Unit to Unit Voice Service Channel Grant -Extended (UU_V_CH_GRANT) // unsigned long mfrid = bitset_shift_mask(header, 80, 0xff); @@ -199,9 +248,9 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.tdma_slot = 0; } - BOOST_LOG_TRIVIAL(debug) << "mbt04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; + BOOST_LOG_TRIVIAL(info) << "mbt04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else { - BOOST_LOG_TRIVIAL(debug) << "mbt other: " << opcode; + BOOST_LOG_TRIVIAL(info) << "mbt other: " << opcode; return messages; } messages.push_back(message); @@ -214,6 +263,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, TrunkMessage message; std::ostringstream os; + // TSBK is shifted 16 prior for the missing CRC prior to this function unsigned long opcode = bitset_shift_mask(tsbk, 88, 0x3f); // x3f message.message_type = UNKNOWN; @@ -231,23 +281,16 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, BOOST_LOG_TRIVIAL(trace) << "TSBK: opcode: $" << std::hex << opcode; if (opcode == 0x00) { // group voice chan grant + // Group Voice Channel Grant (GRP_V_CH_GRANT) + unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); - // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); - bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); - bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); - bool duplex = (bool)bitset_shift_mask(tsbk, 72, 0x20); - bool mode = (bool)bitset_shift_mask(tsbk, 72, 0x10); - unsigned long priority = bitset_shift_mask(tsbk, 72, 0x07); - unsigned long ch = bitset_shift_mask(tsbk, 56, 0xffff); - unsigned long ga = bitset_shift_mask(tsbk, 40, 0xffff); - unsigned long sa = bitset_shift_mask(tsbk, 16, 0xffffff); - if (mfrid == 0x90) { + if (mfrid == 0x90) { // MOT_GRG_ADD_CMD unsigned long sg = bitset_shift_mask(tsbk, 64, 0xffff); unsigned long ga1 = bitset_shift_mask(tsbk, 48, 0xffff); unsigned long ga2 = bitset_shift_mask(tsbk, 32, 0xffff); unsigned long ga3 = bitset_shift_mask(tsbk, 16, 0xffff); - BOOST_LOG_TRIVIAL(debug) << "tsbk00\tMoto Patch Add \tsg: " << sg << "\tga1: " << ga1 << "\tga2: " << ga2 << "\tga3: " << ga3; + BOOST_LOG_TRIVIAL(info) << "tsbk00\tMoto Patch Add \tsg: " << sg << "\tga1: " << ga1 << "\tga2: " << ga2 << "\tga3: " << ga3; message.message_type = PATCH_ADD; PatchData moto_patch_data; moto_patch_data.sg = sg; @@ -256,6 +299,15 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, moto_patch_data.ga3 = ga3; message.patch_data = moto_patch_data; } else { + unsigned long opts = bitset_shift_mask(tsbk, 72, 0xff); + bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); + bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); + bool duplex = (bool)bitset_shift_mask(tsbk, 72, 0x20); + bool mode = (bool)bitset_shift_mask(tsbk, 72, 0x10); + unsigned long priority = bitset_shift_mask(tsbk, 72, 0x07); + unsigned long ch = bitset_shift_mask(tsbk, 56, 0xffff); + unsigned long ga = bitset_shift_mask(tsbk, 40, 0xffff); + unsigned long sa = bitset_shift_mask(tsbk, 16, 0xffffff); unsigned long f1 = channel_id_to_frequency(ch, sys_num); message.message_type = GRANT; message.freq = f1; @@ -276,31 +328,23 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "tsbk00\tChan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tsa " << sa << "\tEncrypt " << encrypted << "\tBandwidth: " << get_bandwidth(ch, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(debug) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } } else if (opcode == 0x02) { // group voice chan grant update unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); - bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); - bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); - bool duplex = (bool)bitset_shift_mask(tsbk, 72, 0x20); - bool mode = (bool)bitset_shift_mask(tsbk, 72, 0x10); - unsigned long priority = bitset_shift_mask(tsbk, 72, 0x07); + // Group Voice Channel Grant Update (GRP_V_CH_GRANT_UPDT) : TIA.102-AABC-B-2005 page 34 + // Options are not present in an UPDATE if (mfrid == 0x90) { unsigned long ch = bitset_shift_mask(tsbk, 56, 0xffff); - unsigned long f = channel_id_to_frequency(ch, sys_num); unsigned long sg = bitset_shift_mask(tsbk, 40, 0xffff); unsigned long sa = bitset_shift_mask(tsbk, 16, 0xffffff); + unsigned long f = channel_id_to_frequency(ch, sys_num); - message.message_type = GRANT; + message.message_type = UPDATE; message.freq = f; message.talkgroup = sg; message.source = sa; - message.emergency = emergency; - message.encrypted = encrypted; - message.duplex = duplex; - message.mode = mode; - message.priority = priority; if (get_tdma_slot(ch, sys_num) >= 0) { message.phase2_tdma = true; @@ -310,9 +354,9 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.tdma_slot = 0; } - os << "tsbk02\tMoto Patch Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tsg " << std::setw(7) << sg << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tsa " << sa; + os << "tsbk02\tMoto Grant Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tsg " << std::setw(7) << sg << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tsa " << sa; message.meta = os.str(); - BOOST_LOG_TRIVIAL(debug) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } else { unsigned long ch1 = bitset_shift_mask(tsbk, 64, 0xffff); unsigned long ga1 = bitset_shift_mask(tsbk, 48, 0xffff); @@ -324,11 +368,6 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.message_type = UPDATE; message.freq = f1; message.talkgroup = ga1; - message.emergency = emergency; - message.encrypted = encrypted; - message.duplex = duplex; - message.mode = mode; - message.priority = priority; if (get_tdma_slot(ch1, sys_num) >= 0) { message.phase2_tdma = true; @@ -351,16 +390,17 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.tdma_slot = 0; } - os << "tsbk02\tGrant Update\tChannel ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tga " << std::setw(7) << ga2 << "\tTDMA " << get_tdma_slot(ch2, sys_num); + os << "tsbk02\tGrant Update 2nd\tChannel ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tga " << std::setw(7) << ga2 << "\tTDMA " << get_tdma_slot(ch2, sys_num) << " | "; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + } os << "tsbk02\tGrant Update\tChannel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } } else if (opcode == 0x03) { // Group Voice Channel Update-Explicit (GRP_V_CH_GRANT_UPDT_EXP) + // group voice chan grant update exp : TIA.102-AABC-B-2005 page 56 unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); @@ -407,32 +447,34 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "MOT_GRG_CN_GRANT_UPDT(0x03): \tChannel ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tsg " << std::setw(7) << sg2 << "\tTDMA " << get_tdma_slot(ch2, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } os << "MOT_GRG_CN_GRANT_UPDT(0x03): \tChannel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tsg " << std::setw(7) << sg1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } else { unsigned long ch1 = bitset_shift_mask(tsbk, 48, 0xffff); + unsigned long ch2 = bitset_shift_mask(tsbk, 32, 0xffff); unsigned long ga1 = bitset_shift_mask(tsbk, 16, 0xffff); unsigned long f1 = channel_id_to_frequency(ch1, sys_num); + unsigned long f2 = channel_id_to_frequency(ch2, sys_num); message.message_type = UPDATE; - message.freq = f1; + message.freq = f2; message.talkgroup = ga1; message.emergency = emergency; message.encrypted = encrypted; if (get_tdma_slot(ch1, sys_num) >= 0) { message.phase2_tdma = true; - message.tdma_slot = get_tdma_slot(ch1, sys_num); + message.tdma_slot = get_tdma_slot(ch2, sys_num); } else { message.phase2_tdma = false; message.tdma_slot = 0; } - os << "tsbk03\tExplicit Grant Update\tChannel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); + os << "tsbk03\tExplicit Grant Update\tTX Channel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tRX Channel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } } else if (opcode == 0x04) { // Unit to Unit Voice Service Channel Grant (UU_V_CH_GRANT) // unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); @@ -464,7 +506,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.tdma_slot = 0; } - BOOST_LOG_TRIVIAL(debug) << "tsbk04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; + BOOST_LOG_TRIVIAL(info) << "tsbk04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else if (opcode == 0x05) { // Unit To Unit Answer Request bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); @@ -483,7 +525,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.source = sa; message.talkgroup = si; - BOOST_LOG_TRIVIAL(debug) << "tsbk05\tUnit To Unit Answer Request\tsa " << sa << "\tSource ID: " << si; + BOOST_LOG_TRIVIAL(info) << "tsbk05\tUnit To Unit Answer Request\tsa " << sa << "\tSource ID: " << si; } else if (opcode == 0x06) { // Unit to Unit Voice Channel Grant Update (UU_V_CH_GRANT_UPDT) // unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -515,13 +557,13 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.mode = mode; message.priority = priority; - BOOST_LOG_TRIVIAL(trace) << "tsbk06\tUnit to Unit Chan Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; + BOOST_LOG_TRIVIAL(info) << "tsbk06\tUnit to Unit Chan Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else if (opcode == 0x08) { - BOOST_LOG_TRIVIAL(debug) << "tsbk08: Telephone Interconnect Voice Channel Grant"; + BOOST_LOG_TRIVIAL(info) << "tsbk08: Telephone Interconnect Voice Channel Grant"; } else if (opcode == 0x09) { - BOOST_LOG_TRIVIAL(debug) << "tsbk09: Telephone Interconnect Voice Channel Grant Update"; + BOOST_LOG_TRIVIAL(info) << "tsbk09: Telephone Interconnect Voice Channel Grant Update"; } else if (opcode == 0x0a) { - BOOST_LOG_TRIVIAL(debug) << "tsbk0a: Telephone Interconnect Answer Request"; + BOOST_LOG_TRIVIAL(info) << "tsbk0a: Telephone Interconnect Answer Request"; } else if (opcode == 0x14) { bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); @@ -542,21 +584,21 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.source = sa; message.freq = fT; - BOOST_LOG_TRIVIAL(debug) << "tsbk14\tSNDCP Data Channel Grant\tsa " << sa << "\tChannels: " << chT << "/" << chR << " Freqs: " << format_freq(fT) << "/" << format_freq(fR) << " NSAPI: " << nsapi; + BOOST_LOG_TRIVIAL(info) << "tsbk14\tSNDCP Data Channel Grant\tsa " << sa << "\tChannels: " << chT << "/" << chR << " Freqs: " << format_freq(fT) << "/" << format_freq(fR) << " NSAPI: " << nsapi; } else if (opcode == 0x15) { - BOOST_LOG_TRIVIAL(debug) << "tsbk15: SNDCP Data Page Request"; + BOOST_LOG_TRIVIAL(info) << "tsbk15: SNDCP Data Page Request"; } else if (opcode == 0x16) { - BOOST_LOG_TRIVIAL(debug) << "tsbk16: SNDCP Data Channel Announcement -Explicit"; + BOOST_LOG_TRIVIAL(info) << "tsbk16: SNDCP Data Channel Announcement -Explicit"; } else if (opcode == 0x18) { - BOOST_LOG_TRIVIAL(debug) << "tsbk18: Status Update"; + BOOST_LOG_TRIVIAL(info) << "tsbk18: Status Update"; } else if (opcode == 0x1a) { - BOOST_LOG_TRIVIAL(debug) << "tsbk1a: Status Query"; + BOOST_LOG_TRIVIAL(info) << "tsbk1a: Status Query"; } else if (opcode == 0x1c) { - BOOST_LOG_TRIVIAL(debug) << "tsbk1c: Messag Update"; + BOOST_LOG_TRIVIAL(info) << "tsbk1c: Messag Update"; } else if (opcode == 0x1d) { - BOOST_LOG_TRIVIAL(debug) << "tsbk1d: Radio Unit Monitor Command"; + BOOST_LOG_TRIVIAL(info) << "tsbk1d: Radio Unit Monitor Command"; } else if (opcode == 0x1f) { - BOOST_LOG_TRIVIAL(debug) << "tsbk1f: Call Alert"; + BOOST_LOG_TRIVIAL(info) << "tsbk1f: Call Alert"; } else if (opcode == 0x20) { // Acknowledge response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); unsigned long ga = bitset_shift_mask(tsbk, 40, 0xffff); @@ -567,13 +609,13 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.talkgroup = ga; message.source = sa; - BOOST_LOG_TRIVIAL(debug) << "tsbk20\tAcknowledge Response\tga " << std::dec << ga << "\tsa " << sa << "\tReserved: " << op; + BOOST_LOG_TRIVIAL(info) << "tsbk20\tAcknowledge Response\tga " << std::dec << ga << "\tsa " << sa << "\tReserved: " << op; } else if (opcode == 0x21) { - BOOST_LOG_TRIVIAL(debug) << "tsbk21: Extended Function Command"; + BOOST_LOG_TRIVIAL(info) << "tsbk21: Extended Function Command"; } else if (opcode == 0x24) { - BOOST_LOG_TRIVIAL(debug) << "tsbk24: Extended Function Command"; + BOOST_LOG_TRIVIAL(info) << "tsbk24: Extended Function Command"; } else if (opcode == 0x27) { - BOOST_LOG_TRIVIAL(debug) << "tsbk27: Deny Response"; + BOOST_LOG_TRIVIAL(info) << "tsbk27: Deny Response"; } else if (opcode == 0x28) { // Unit Group Affiliation Response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -585,7 +627,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.source = ta; message.talkgroup = ga; - BOOST_LOG_TRIVIAL(debug) << "tsbk2f\tUnit Group Affiliation\tSource ID: " << std::setw(7) << ta << "\tGroup Address: " << std::dec << ga << "\tAnouncement Goup: " << aga; + BOOST_LOG_TRIVIAL(info) << "tsbk2f\tUnit Group Affiliation\tSource ID: " << std::setw(7) << ta << "\tGroup Address: " << std::dec << ga << "\tAnouncement Goup: " << aga; } else if (opcode == 0x29) { // Secondary Control Channel Broadcast - Explicit unsigned long rfid = bitset_shift_mask(tsbk, 72, 0xff); unsigned long stid = bitset_shift_mask(tsbk, 64, 0xff); @@ -608,10 +650,10 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, os << "tsbk29 secondary cc: rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") ch2 " << ch2 << "(" << channel_id_to_string(ch2, sys_num) << ") "; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } else if (opcode == 0x2a) { // Group Affiliation Query - BOOST_LOG_TRIVIAL(debug) << "tsbk2a Group Affiliation Query"; + BOOST_LOG_TRIVIAL(info) << "tsbk2a Group Affiliation Query"; } else if (opcode == 0x2b) { // Location Registration Response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); unsigned long ga = bitset_shift_mask(tsbk, 56, 0xffff); @@ -622,7 +664,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.talkgroup = ga; message.source = sa; - BOOST_LOG_TRIVIAL(debug) << "tsbk2b\tLocation Registration Response\tga " << std::dec << ga << "\tsa " << sa << "\tValue: " << rv; + BOOST_LOG_TRIVIAL(info) << "tsbk2b\tLocation Registration Response\tga " << std::dec << ga << "\tsa " << sa << "\tValue: " << rv; } else if (opcode == 0x2c) { // Unit Registration Response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -632,11 +674,11 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.message_type = REGISTRATION; message.source = si; - BOOST_LOG_TRIVIAL(debug) << "tsbk2c\tUnit Registration COMMAND\tsa " << std::setw(7) << sa << " Source ID: " << si; + BOOST_LOG_TRIVIAL(info) << "tsbk2c\tUnit Registration COMMAND\tsa " << std::setw(7) << sa << " Source ID: " << si; } else if (opcode == 0x2d) { // - BOOST_LOG_TRIVIAL(debug) << "tsbk2d AUTHENTICATION COMMAND"; + BOOST_LOG_TRIVIAL(info) << "tsbk2d AUTHENTICATION COMMAND"; } else if (opcode == 0x2e) { // - BOOST_LOG_TRIVIAL(debug) << "tsbk2e DE-REGISTRATION ACKNOWLEDGE"; + BOOST_LOG_TRIVIAL(info) << "tsbk2e DE-REGISTRATION ACKNOWLEDGE"; } else if (opcode == 0x2f) { // Unit DeRegistration Ack // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -645,7 +687,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.message_type = DEREGISTRATION; message.source = si; - BOOST_LOG_TRIVIAL(debug) << "tsbk2f\tUnit Deregistration ACK\tSource ID: " << std::setw(7) << si; + BOOST_LOG_TRIVIAL(info) << "tsbk2f\tUnit Deregistration ACK\tSource ID: " << std::setw(7) << si; } else if (opcode == 0x30) { unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); if (mfrid == 0xA4) { // GRG_EXENC_CMD (M/A-COM patch) @@ -667,7 +709,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(debug) << "tsbk30 M/A-COM GROUP REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; + BOOST_LOG_TRIVIAL(info) << "tsbk30 M/A-COM GROUP REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; } else { message.message_type = PATCH_ADD; PatchData harris_patch_data; @@ -676,7 +718,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(debug) << "tsbk30 M/A-COM UNIT REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; + BOOST_LOG_TRIVIAL(info) << "tsbk30 M/A-COM UNIT REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; } } else { // Deactivate if (grg_g == 1) { // Group request @@ -687,7 +729,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(debug) << "tsbk30 M/A-COM GROUP REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; + BOOST_LOG_TRIVIAL(info) << "tsbk30 M/A-COM GROUP REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; } else { message.message_type = PATCH_DELETE; PatchData harris_patch_data; @@ -696,16 +738,16 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(debug) << "tsbk30 M/A-COM UNIT REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; + BOOST_LOG_TRIVIAL(info) << "tsbk30 M/A-COM UNIT REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; } } } else { - BOOST_LOG_TRIVIAL(trace) << "tsbk30 TDMA SYNCHRONIZATION BROADCAST"; + BOOST_LOG_TRIVIAL(info) << "tsbk30 TDMA SYNCHRONIZATION BROADCAST"; } } else if (opcode == 0x31) { // - BOOST_LOG_TRIVIAL(debug) << "tsbk31 AUTHENTICATION DEMAND"; + BOOST_LOG_TRIVIAL(info) << "tsbk31 AUTHENTICATION DEMAND"; } else if (opcode == 0x32) { // - BOOST_LOG_TRIVIAL(debug) << "tsbk32 AUTHENTICATION RESPONSE"; + BOOST_LOG_TRIVIAL(info) << "tsbk32 AUTHENTICATION RESPONSE"; } else if (opcode == 0x33) { // iden_up_tdma unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); @@ -737,7 +779,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, slots_per_carrier[channel_type], // tdma; 6.25}; add_channel(iden, temp_chan, sys_num); - BOOST_LOG_TRIVIAL(trace) << "tsbk33 iden up tdma id " << std::dec << iden << " f " << temp_chan.frequency << " offset " << temp_chan.offset << " spacing " << temp_chan.step << " slots/carrier " << temp_chan.slots_per_carrier; + BOOST_LOG_TRIVIAL(info) << "tsbk33 iden up tdma id " << std::dec << iden << " f " << temp_chan.frequency << " offset " << temp_chan.offset << " spacing " << temp_chan.step << " slots/carrier " << temp_chan.slots_per_carrier; } } else if (opcode == 0x34) { // iden_up vhf uhf unsigned long iden = bitset_shift_mask(tsbk, 76, 0xf); @@ -769,15 +811,15 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, bandwidth}; add_channel(iden, temp_chan, sys_num); - BOOST_LOG_TRIVIAL(trace) << "tsbk34 iden vhf/uhf id " << std::dec << iden << " toff " << toff * spac * 0.125 * 1e-3 << " spac " << spac * 0.125 << " freq " << freq * 0.000005 << " [ " << txt[toff_sign] << "]"; + BOOST_LOG_TRIVIAL(info) << "tsbk34 iden vhf/uhf id " << std::dec << iden << " toff " << toff * spac * 0.125 * 1e-3 << " spac " << spac * 0.125 << " freq " << freq * 0.000005 << " [ " << txt[toff_sign] << "]"; } else if (opcode == 0x35) { // Time and Date Announcement - BOOST_LOG_TRIVIAL(debug) << "tsbk35 Time and Date Announcement"; + BOOST_LOG_TRIVIAL(info) << "tsbk35 Time and Date Announcement"; } else if (opcode == 0x36) { // - BOOST_LOG_TRIVIAL(debug) << "tsbk36 ROAMING ADDRESS COMMAND"; + BOOST_LOG_TRIVIAL(info) << "tsbk36 ROAMING ADDRESS COMMAND"; } else if (opcode == 0x37) { // - BOOST_LOG_TRIVIAL(debug) << "tsbk37 ROAMING ADDRESS UPDATE"; + BOOST_LOG_TRIVIAL(info) << "tsbk37 ROAMING ADDRESS UPDATE"; } else if (opcode == 0x38) { // - BOOST_LOG_TRIVIAL(trace) << "tsbk38 SYSTEM SERVICE BROADCAST"; + BOOST_LOG_TRIVIAL(info) << "tsbk38 SYSTEM SERVICE BROADCAST"; } else if (opcode == 0x39) { // secondary cc unsigned long rfid = bitset_shift_mask(tsbk, 72, 0xff); unsigned long stid = bitset_shift_mask(tsbk, 64, 0xff); @@ -799,7 +841,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "tsbk39 secondary cc: rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") ch2 " << ch2 << "(" << channel_id_to_string(ch2, sys_num) << ") "; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } else if (opcode == 0x3a) { // rfss status unsigned long syid = bitset_shift_mask(tsbk, 56, 0xfff); unsigned long rfid = bitset_shift_mask(tsbk, 48, 0xff); @@ -809,7 +851,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.sys_id = syid; os << "tsbk3a rfss status: syid: " << syid << " rfid " << rfid << " stid " << stid << " ch1 " << chan << "(" << channel_id_to_string(chan, sys_num) << ")"; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(info) << os.str(); } else if (opcode == 0x3b) { // network status unsigned long wacn = bitset_shift_mask(tsbk, 52, 0xfffff); unsigned long syid = bitset_shift_mask(tsbk, 40, 0xfff); @@ -822,13 +864,13 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.sys_id = syid; message.freq = f1; } - BOOST_LOG_TRIVIAL(trace) << "tsbk3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; + BOOST_LOG_TRIVIAL(info) << "tsbk3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; } else if (opcode == 0x3c) { // adjacent status unsigned long rfid = bitset_shift_mask(tsbk, 48, 0xff); unsigned long stid = bitset_shift_mask(tsbk, 40, 0xff); unsigned long ch1 = bitset_shift_mask(tsbk, 24, 0xffff); unsigned long f1 = channel_id_to_frequency(ch1, sys_num); - BOOST_LOG_TRIVIAL(trace) << "tsbk3c\tAdjacent Status\t rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; + BOOST_LOG_TRIVIAL(info) << "tsbk3c\tAdjacent Status\t rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; if (f1) { it = channels[stid].find((ch1 >> 12) & 0xf); @@ -839,7 +881,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, // self.adjacent[f1] = 'rfid: %d stid:%d uplink:%f // tbl:%d' % (rfid, stid, (f1 + self.freq_table[table]['offset']) / // 1000000.0, table) - BOOST_LOG_TRIVIAL(trace) << "\ttsbk3c Chan " << temp_chan.frequency << " " << temp_chan.step; + BOOST_LOG_TRIVIAL(info) << "\ttsbk3c Chan " << temp_chan.frequency << " " << temp_chan.step; } } } else if (opcode == 0x3d) { // iden_up @@ -864,9 +906,9 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, 1, // slots bw * .125}; add_channel(iden, temp_chan, sys_num); - BOOST_LOG_TRIVIAL(trace) << "tsbk3d iden id " << std::dec << iden << " toff " << toff * 0.25 << " spac " << spac * 0.125 << " freq " << freq * 0.000005; + BOOST_LOG_TRIVIAL(info) << "tsbk3d iden id " << std::dec << iden << " toff " << toff * 0.25 << " spac " << spac * 0.125 << " freq " << freq * 0.000005; } else { - BOOST_LOG_TRIVIAL(debug) << "tsbk other " << std::hex << opcode; + BOOST_LOG_TRIVIAL(info) << "tsbk other " << std::hex << opcode; return messages; } messages.push_back(message); @@ -876,7 +918,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, void P25Parser::print_bitset(boost::dynamic_bitset<> &tsbk) { /*boost::dynamic_bitset<> bitmask(tsbk.size(), 0x3f); unsigned long result = (tsbk & bitmask).to_ulong(); - BOOST_LOG_TRIVIAL(debug) << tsbk << " = " << std::hex << result;*/ + BOOST_LOG_TRIVIAL(info) << tsbk << " = " << std::hex << result;*/ } void printbincharpad(char c) { @@ -900,7 +942,7 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System if (type == -2) { // # request from gui std::string cmd = msg->to_string(); - BOOST_LOG_TRIVIAL(debug) << "process_qmsg: command: " << cmd; + BOOST_LOG_TRIVIAL(info) << "process_qmsg: command: " << cmd; // self.update_state(cmd, curr_time) messages.push_back(message); @@ -911,7 +953,7 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System messages.push_back(message); return messages; } else if (type < 0) { - BOOST_LOG_TRIVIAL(debug) << "unknown message type " << type; + BOOST_LOG_TRIVIAL(info) << "unknown message type " << type; messages.push_back(message); return messages; } @@ -941,8 +983,10 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System BOOST_LOG_TRIVIAL(trace) << std::hex << "nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); // //" at %f state %d len %d" %(nac, type, time.time(), self.state, len(s)) - if ((type == 7) || (type == 12)) // and nac not in self.trunked_systems: + if ((type != 7) && (type != 12)) // and nac not in self.trunked_systems: { + BOOST_LOG_TRIVIAL(info) << std::hex << "NON TBSK: nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); + /* if not self.configs: # TODO: allow whitelist/blacklist rather than blind automatic-add @@ -1008,12 +1052,12 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System mbt_data <<= 32; // for missing crc unsigned long opcode = bitset_shift_mask(header, 32, 0x3f); unsigned long link_id = bitset_shift_mask(header, 48, 0xffffff); - /*BOOST_LOG_TRIVIAL(trace) << "RAW Data " < decode_mbt_data(unsigned long opcode, boost::dynamic_bitset<> &header, boost::dynamic_bitset<> &mbt_data, unsigned long link_id, unsigned long nac, int sys_num); std::vector decode_tsbk(boost::dynamic_bitset<> &tsbk, unsigned long nac, int sys_num); unsigned long bitset_shift_mask(boost::dynamic_bitset<> &tsbk, int shift, unsigned long long mask); + unsigned long bitset_shift_left_mask(boost::dynamic_bitset<> &tsbk, int shift, unsigned long long mask); std::string channel_id_to_string(int chan_id, int sys_num); void print_bitset(boost::dynamic_bitset<> &tsbk); void add_channel(int chan_id, Channel chan, int sys_num); From a0d5691d8285e9adac7761b26224f7846832c20e Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 28 May 2023 12:40:03 -0400 Subject: [PATCH 02/22] Update main.cc --- trunk-recorder/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 292c85e28..9901bdb2a 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1119,7 +1119,7 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { else { recording_started = start_recorder(call, message, sys); if (recording_started && !grant_message) { - BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE"; + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE"; } } calls.push_back(call); From 527d17df5b8bff6cb5b9899b26001096c7f536e2 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 28 May 2023 12:42:38 -0400 Subject: [PATCH 03/22] Update main.cc --- trunk-recorder/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 9901bdb2a..fe992aff2 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1119,7 +1119,7 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { else { recording_started = start_recorder(call, message, sys); if (recording_started && !grant_message) { - BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE"; + BOOST_LOG_TRIVIAL(info) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mThis was an UPDATE\u001b[0m"; } } calls.push_back(call); From b040dcfd05396d3dc97e217d2e3a16dbc60de6e0 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 28 May 2023 22:51:56 -0400 Subject: [PATCH 04/22] Only stop recording when control channel timesout too --- trunk-recorder/call_impl.cc | 2 +- trunk-recorder/main.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index 260122371..3d7de85d7 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -119,7 +119,7 @@ void Call_impl::conclude_call() { if (!recorder) { BOOST_LOG_TRIVIAL(error) << "Call_impl::end_call() State is recording, but no recorder assigned!"; } - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tCall Elapsed: " << this->elapsed(); + BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mConcluding Recorded Call\u001b[0m - Last Update: " << this->since_last_update() << "s\tRecorder last write:" << recorder->since_last_write() << "\tCall Elapsed: " << this->elapsed(); if (was_update) { BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\t\u001b[33mCall was UPDATE not GRANT\u001b[0m"; diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index fe992aff2..67825e4e2 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -887,7 +887,7 @@ void manage_calls() { // OR // - the recorder has been stopped // actually, we don't want to remove a recorder as soon as it is stopped because we want to drain everything from the gnuradio flowgraph - if (recorder->since_last_write() > config.call_timeout) { + if ((recorder->since_last_write() > config.call_timeout) && (call->since_last_update() > config.call_timeout)) { BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); call->set_state(COMPLETED); From 166b2802635f2a2839dde5aac33900866ee00019 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 29 May 2023 08:29:31 -0400 Subject: [PATCH 05/22] Update p25_parser.cc Default encrypted to false - needed if we are going to treat updates as call starts --- trunk-recorder/systems/p25_parser.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/trunk-recorder/systems/p25_parser.cc b/trunk-recorder/systems/p25_parser.cc index 830f15d9a..a414943f3 100644 --- a/trunk-recorder/systems/p25_parser.cc +++ b/trunk-recorder/systems/p25_parser.cc @@ -101,6 +101,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.sys_num = sys_num; message.talkgroup = 0; message.emergency = false; + message.encrypted = false; message.duplex = false; message.mode = false; message.priority = 0; @@ -274,6 +275,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.sys_num = sys_num; message.talkgroup = 0; message.emergency = false; + message.encrypted = false; message.phase2_tdma = false; message.tdma_slot = 0; message.freq = 0; @@ -530,11 +532,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, // unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); - bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); - bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); - bool duplex = (bool)bitset_shift_mask(tsbk, 72, 0x20); - bool mode = (bool)bitset_shift_mask(tsbk, 72, 0x10); - unsigned long priority = bitset_shift_mask(tsbk, 72, 0x07); + unsigned long ch = bitset_shift_mask(tsbk, 64, 0xffff); unsigned long f = channel_id_to_frequency(ch, sys_num); unsigned long sa = bitset_shift_mask(tsbk, 16, 0xffffff); @@ -551,11 +549,6 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.phase2_tdma = false; message.tdma_slot = 0; } - message.emergency = emergency; - message.encrypted = encrypted; - message.duplex = duplex; - message.mode = mode; - message.priority = priority; BOOST_LOG_TRIVIAL(info) << "tsbk06\tUnit to Unit Chan Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else if (opcode == 0x08) { From cf44f0847d7abe9d4cc62a24e16786913f138b69 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 29 May 2023 09:58:37 -0400 Subject: [PATCH 06/22] Turn off excessive logging --- trunk-recorder/systems/p25_parser.cc | 148 +++++++++++++-------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/trunk-recorder/systems/p25_parser.cc b/trunk-recorder/systems/p25_parser.cc index a414943f3..6ab3ff5f7 100644 --- a/trunk-recorder/systems/p25_parser.cc +++ b/trunk-recorder/systems/p25_parser.cc @@ -110,7 +110,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.freq = 0; message.opcode = opcode; - BOOST_LOG_TRIVIAL(info) << "decode_mbt_data: $" << opcode; + BOOST_LOG_TRIVIAL(trace) << "decode_mbt_data: $" << opcode; if (opcode == 0x0) { // grp voice channel grant // unsigned long mfrid = bitset_shift_mask(header, 72, 0xff); unsigned long ch1 = bitset_shift_mask(mbt_data, 64, 0xffff); @@ -146,7 +146,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost os << "mbt00\tChan Grant\tChannel 1 ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tChannel 2 ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tga " << std::setw(7) << ga << "\tTDMA " << get_tdma_slot(ch1, sys_num) << "\tsa " << sa << "\tEncrypt " << encrypted << "\tBandwidth: " << get_bandwidth(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } else if (opcode == 0x02) { // grp regroup voice channel grant unsigned long mfrid = bitset_shift_mask(mbt_data, 168, 0xff); if (mfrid == 0x90) { // MOT_GRG_CN_GRANT_EXP @@ -169,7 +169,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost os << "mbt02\tmfid90_grg_cn_grant_exp\tChannel 1 ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tChannel 2 ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tsg " << std::setw(7) << sg << "\tTDMA " << get_tdma_slot(ch1, sys_num) << "\tBandwidth: " << get_bandwidth(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } } else if (opcode == 0x028) { // grp_aff_rsp unsigned long mfrid = bitset_shift_mask(mbt_data, 56, 0xff); @@ -183,7 +183,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost os << "mbt28\tmbt(0x28) grp_aff_rsp:\tMFRID: " << mfrid << "\tWACN: " << wacn << "\tSYID: " << syid << "\tLG: " << lg << "\tGAV: " << gav << "\tADA: " << ada << "\tGA: " << ga << "\tLG: " << lg; message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } else if (opcode == 0x3a) { // rfss status unsigned long syid = bitset_shift_mask(header, 48, 0xfff); unsigned long rfid = bitset_shift_mask(mbt_data, 88, 0xff); @@ -196,7 +196,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.sys_id = syid; os << "mbt3a rfss status: syid: " << syid << " rfid " << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ")"; message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } else if (opcode == 0x3b) { // network status unsigned long wacn = bitset_shift_mask(mbt_data, 76, 0xfffff); unsigned long syid = bitset_shift_mask(header, 48, 0xfff); @@ -211,14 +211,14 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.sys_id = syid; message.freq = f1; } - BOOST_LOG_TRIVIAL(info) << "mbt3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; + BOOST_LOG_TRIVIAL(trace) << "mbt3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; } else if (opcode == 0x3c) { // adjacent status unsigned long syid = bitset_shift_mask(header, 48, 0xfff); unsigned long rfid = bitset_shift_mask(header, 24, 0xff); unsigned long stid = bitset_shift_mask(header, 16, 0xff); unsigned long ch1 = bitset_shift_mask(mbt_data, 80, 0xffff); unsigned long ch2 = bitset_shift_mask(mbt_data, 64, 0xffff); - BOOST_LOG_TRIVIAL(info) << "mbt3c adjacent status " + BOOST_LOG_TRIVIAL(trace) << "mbt3c adjacent status " << "syid " << syid << " rfid " << rfid << " stid " << stid << " ch1 " << ch1 << " ch2 " << ch2; } else if (opcode == 0x04) { // Unit to Unit Voice Service Channel Grant -Extended (UU_V_CH_GRANT) // unsigned long mfrid = bitset_shift_mask(header, 80, 0xff); @@ -249,9 +249,9 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.tdma_slot = 0; } - BOOST_LOG_TRIVIAL(info) << "mbt04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; + BOOST_LOG_TRIVIAL(trace) << "mbt04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else { - BOOST_LOG_TRIVIAL(info) << "mbt other: " << opcode; + BOOST_LOG_TRIVIAL(trace) << "mbt other: " << opcode; return messages; } messages.push_back(message); @@ -281,7 +281,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.freq = 0; message.opcode = opcode; - BOOST_LOG_TRIVIAL(trace) << "TSBK: opcode: $" << std::hex << opcode; + BOOST_LOG_TRIVIAL(debug) << "TSBK: opcode: $" << std::hex << opcode; if (opcode == 0x00) { // group voice chan grant // Group Voice Channel Grant (GRP_V_CH_GRANT) @@ -292,7 +292,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, unsigned long ga1 = bitset_shift_mask(tsbk, 48, 0xffff); unsigned long ga2 = bitset_shift_mask(tsbk, 32, 0xffff); unsigned long ga3 = bitset_shift_mask(tsbk, 16, 0xffff); - BOOST_LOG_TRIVIAL(info) << "tsbk00\tMoto Patch Add \tsg: " << sg << "\tga1: " << ga1 << "\tga2: " << ga2 << "\tga3: " << ga3; + BOOST_LOG_TRIVIAL(trace) << "tsbk00\tMoto Patch Add \tsg: " << sg << "\tga1: " << ga1 << "\tga2: " << ga2 << "\tga3: " << ga3; message.message_type = PATCH_ADD; PatchData moto_patch_data; moto_patch_data.sg = sg; @@ -330,7 +330,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "tsbk00\tChan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tsa " << sa << "\tEncrypt " << encrypted << "\tBandwidth: " << get_bandwidth(ch, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } } else if (opcode == 0x02) { // group voice chan grant update unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); @@ -358,7 +358,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, os << "tsbk02\tMoto Grant Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tsg " << std::setw(7) << sg << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tsa " << sa; message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } else { unsigned long ch1 = bitset_shift_mask(tsbk, 64, 0xffff); unsigned long ga1 = bitset_shift_mask(tsbk, 48, 0xffff); @@ -399,7 +399,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "tsbk02\tGrant Update\tChannel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } } else if (opcode == 0x03) { // Group Voice Channel Update-Explicit (GRP_V_CH_GRANT_UPDT_EXP) // group voice chan grant update exp : TIA.102-AABC-B-2005 page 56 @@ -449,11 +449,11 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "MOT_GRG_CN_GRANT_UPDT(0x03): \tChannel ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tsg " << std::setw(7) << sg2 << "\tTDMA " << get_tdma_slot(ch2, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } os << "MOT_GRG_CN_GRANT_UPDT(0x03): \tChannel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tsg " << std::setw(7) << sg1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } else { unsigned long ch1 = bitset_shift_mask(tsbk, 48, 0xffff); unsigned long ch2 = bitset_shift_mask(tsbk, 32, 0xffff); @@ -476,7 +476,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, os << "tsbk03\tExplicit Grant Update\tTX Channel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tRX Channel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } } else if (opcode == 0x04) { // Unit to Unit Voice Service Channel Grant (UU_V_CH_GRANT) // unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); @@ -508,7 +508,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.tdma_slot = 0; } - BOOST_LOG_TRIVIAL(info) << "tsbk04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; + BOOST_LOG_TRIVIAL(trace) << "tsbk04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else if (opcode == 0x05) { // Unit To Unit Answer Request bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); @@ -527,7 +527,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.source = sa; message.talkgroup = si; - BOOST_LOG_TRIVIAL(info) << "tsbk05\tUnit To Unit Answer Request\tsa " << sa << "\tSource ID: " << si; + BOOST_LOG_TRIVIAL(trace) << "tsbk05\tUnit To Unit Answer Request\tsa " << sa << "\tSource ID: " << si; } else if (opcode == 0x06) { // Unit to Unit Voice Channel Grant Update (UU_V_CH_GRANT_UPDT) // unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -550,13 +550,13 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.tdma_slot = 0; } - BOOST_LOG_TRIVIAL(info) << "tsbk06\tUnit to Unit Chan Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; + BOOST_LOG_TRIVIAL(trace) << "tsbk06\tUnit to Unit Chan Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else if (opcode == 0x08) { - BOOST_LOG_TRIVIAL(info) << "tsbk08: Telephone Interconnect Voice Channel Grant"; + BOOST_LOG_TRIVIAL(trace) << "tsbk08: Telephone Interconnect Voice Channel Grant"; } else if (opcode == 0x09) { - BOOST_LOG_TRIVIAL(info) << "tsbk09: Telephone Interconnect Voice Channel Grant Update"; + BOOST_LOG_TRIVIAL(trace) << "tsbk09: Telephone Interconnect Voice Channel Grant Update"; } else if (opcode == 0x0a) { - BOOST_LOG_TRIVIAL(info) << "tsbk0a: Telephone Interconnect Answer Request"; + BOOST_LOG_TRIVIAL(trace) << "tsbk0a: Telephone Interconnect Answer Request"; } else if (opcode == 0x14) { bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); @@ -577,21 +577,21 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.source = sa; message.freq = fT; - BOOST_LOG_TRIVIAL(info) << "tsbk14\tSNDCP Data Channel Grant\tsa " << sa << "\tChannels: " << chT << "/" << chR << " Freqs: " << format_freq(fT) << "/" << format_freq(fR) << " NSAPI: " << nsapi; + BOOST_LOG_TRIVIAL(trace) << "tsbk14\tSNDCP Data Channel Grant\tsa " << sa << "\tChannels: " << chT << "/" << chR << " Freqs: " << format_freq(fT) << "/" << format_freq(fR) << " NSAPI: " << nsapi; } else if (opcode == 0x15) { - BOOST_LOG_TRIVIAL(info) << "tsbk15: SNDCP Data Page Request"; + BOOST_LOG_TRIVIAL(trace) << "tsbk15: SNDCP Data Page Request"; } else if (opcode == 0x16) { - BOOST_LOG_TRIVIAL(info) << "tsbk16: SNDCP Data Channel Announcement -Explicit"; + BOOST_LOG_TRIVIAL(trace) << "tsbk16: SNDCP Data Channel Announcement -Explicit"; } else if (opcode == 0x18) { - BOOST_LOG_TRIVIAL(info) << "tsbk18: Status Update"; + BOOST_LOG_TRIVIAL(trace) << "tsbk18: Status Update"; } else if (opcode == 0x1a) { - BOOST_LOG_TRIVIAL(info) << "tsbk1a: Status Query"; + BOOST_LOG_TRIVIAL(trace) << "tsbk1a: Status Query"; } else if (opcode == 0x1c) { - BOOST_LOG_TRIVIAL(info) << "tsbk1c: Messag Update"; + BOOST_LOG_TRIVIAL(trace) << "tsbk1c: Messag Update"; } else if (opcode == 0x1d) { - BOOST_LOG_TRIVIAL(info) << "tsbk1d: Radio Unit Monitor Command"; + BOOST_LOG_TRIVIAL(trace) << "tsbk1d: Radio Unit Monitor Command"; } else if (opcode == 0x1f) { - BOOST_LOG_TRIVIAL(info) << "tsbk1f: Call Alert"; + BOOST_LOG_TRIVIAL(trace) << "tsbk1f: Call Alert"; } else if (opcode == 0x20) { // Acknowledge response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); unsigned long ga = bitset_shift_mask(tsbk, 40, 0xffff); @@ -602,13 +602,13 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.talkgroup = ga; message.source = sa; - BOOST_LOG_TRIVIAL(info) << "tsbk20\tAcknowledge Response\tga " << std::dec << ga << "\tsa " << sa << "\tReserved: " << op; + BOOST_LOG_TRIVIAL(trace) << "tsbk20\tAcknowledge Response\tga " << std::dec << ga << "\tsa " << sa << "\tReserved: " << op; } else if (opcode == 0x21) { - BOOST_LOG_TRIVIAL(info) << "tsbk21: Extended Function Command"; + BOOST_LOG_TRIVIAL(trace) << "tsbk21: Extended Function Command"; } else if (opcode == 0x24) { - BOOST_LOG_TRIVIAL(info) << "tsbk24: Extended Function Command"; + BOOST_LOG_TRIVIAL(trace) << "tsbk24: Extended Function Command"; } else if (opcode == 0x27) { - BOOST_LOG_TRIVIAL(info) << "tsbk27: Deny Response"; + BOOST_LOG_TRIVIAL(trace) << "tsbk27: Deny Response"; } else if (opcode == 0x28) { // Unit Group Affiliation Response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -620,7 +620,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.source = ta; message.talkgroup = ga; - BOOST_LOG_TRIVIAL(info) << "tsbk2f\tUnit Group Affiliation\tSource ID: " << std::setw(7) << ta << "\tGroup Address: " << std::dec << ga << "\tAnouncement Goup: " << aga; + BOOST_LOG_TRIVIAL(trace) << "tsbk2f\tUnit Group Affiliation\tSource ID: " << std::setw(7) << ta << "\tGroup Address: " << std::dec << ga << "\tAnouncement Goup: " << aga; } else if (opcode == 0x29) { // Secondary Control Channel Broadcast - Explicit unsigned long rfid = bitset_shift_mask(tsbk, 72, 0xff); unsigned long stid = bitset_shift_mask(tsbk, 64, 0xff); @@ -643,10 +643,10 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, os << "tsbk29 secondary cc: rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") ch2 " << ch2 << "(" << channel_id_to_string(ch2, sys_num) << ") "; message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } else if (opcode == 0x2a) { // Group Affiliation Query - BOOST_LOG_TRIVIAL(info) << "tsbk2a Group Affiliation Query"; + BOOST_LOG_TRIVIAL(trace) << "tsbk2a Group Affiliation Query"; } else if (opcode == 0x2b) { // Location Registration Response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); unsigned long ga = bitset_shift_mask(tsbk, 56, 0xffff); @@ -657,7 +657,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.talkgroup = ga; message.source = sa; - BOOST_LOG_TRIVIAL(info) << "tsbk2b\tLocation Registration Response\tga " << std::dec << ga << "\tsa " << sa << "\tValue: " << rv; + BOOST_LOG_TRIVIAL(trace) << "tsbk2b\tLocation Registration Response\tga " << std::dec << ga << "\tsa " << sa << "\tValue: " << rv; } else if (opcode == 0x2c) { // Unit Registration Response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -667,11 +667,11 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.message_type = REGISTRATION; message.source = si; - BOOST_LOG_TRIVIAL(info) << "tsbk2c\tUnit Registration COMMAND\tsa " << std::setw(7) << sa << " Source ID: " << si; + BOOST_LOG_TRIVIAL(trace) << "tsbk2c\tUnit Registration COMMAND\tsa " << std::setw(7) << sa << " Source ID: " << si; } else if (opcode == 0x2d) { // - BOOST_LOG_TRIVIAL(info) << "tsbk2d AUTHENTICATION COMMAND"; + BOOST_LOG_TRIVIAL(trace) << "tsbk2d AUTHENTICATION COMMAND"; } else if (opcode == 0x2e) { // - BOOST_LOG_TRIVIAL(info) << "tsbk2e DE-REGISTRATION ACKNOWLEDGE"; + BOOST_LOG_TRIVIAL(trace) << "tsbk2e DE-REGISTRATION ACKNOWLEDGE"; } else if (opcode == 0x2f) { // Unit DeRegistration Ack // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -680,7 +680,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.message_type = DEREGISTRATION; message.source = si; - BOOST_LOG_TRIVIAL(info) << "tsbk2f\tUnit Deregistration ACK\tSource ID: " << std::setw(7) << si; + BOOST_LOG_TRIVIAL(trace) << "tsbk2f\tUnit Deregistration ACK\tSource ID: " << std::setw(7) << si; } else if (opcode == 0x30) { unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); if (mfrid == 0xA4) { // GRG_EXENC_CMD (M/A-COM patch) @@ -702,7 +702,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(info) << "tsbk30 M/A-COM GROUP REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; + BOOST_LOG_TRIVIAL(trace) << "tsbk30 M/A-COM GROUP REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; } else { message.message_type = PATCH_ADD; PatchData harris_patch_data; @@ -711,7 +711,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(info) << "tsbk30 M/A-COM UNIT REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; + BOOST_LOG_TRIVIAL(trace) << "tsbk30 M/A-COM UNIT REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; } } else { // Deactivate if (grg_g == 1) { // Group request @@ -722,7 +722,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(info) << "tsbk30 M/A-COM GROUP REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; + BOOST_LOG_TRIVIAL(trace) << "tsbk30 M/A-COM GROUP REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; } else { message.message_type = PATCH_DELETE; PatchData harris_patch_data; @@ -731,16 +731,16 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(info) << "tsbk30 M/A-COM UNIT REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; + BOOST_LOG_TRIVIAL(trace) << "tsbk30 M/A-COM UNIT REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; } } } else { - BOOST_LOG_TRIVIAL(info) << "tsbk30 TDMA SYNCHRONIZATION BROADCAST"; + BOOST_LOG_TRIVIAL(trace) << "tsbk30 TDMA SYNCHRONIZATION BROADCAST"; } } else if (opcode == 0x31) { // - BOOST_LOG_TRIVIAL(info) << "tsbk31 AUTHENTICATION DEMAND"; + BOOST_LOG_TRIVIAL(trace) << "tsbk31 AUTHENTICATION DEMAND"; } else if (opcode == 0x32) { // - BOOST_LOG_TRIVIAL(info) << "tsbk32 AUTHENTICATION RESPONSE"; + BOOST_LOG_TRIVIAL(trace) << "tsbk32 AUTHENTICATION RESPONSE"; } else if (opcode == 0x33) { // iden_up_tdma unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); @@ -772,7 +772,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, slots_per_carrier[channel_type], // tdma; 6.25}; add_channel(iden, temp_chan, sys_num); - BOOST_LOG_TRIVIAL(info) << "tsbk33 iden up tdma id " << std::dec << iden << " f " << temp_chan.frequency << " offset " << temp_chan.offset << " spacing " << temp_chan.step << " slots/carrier " << temp_chan.slots_per_carrier; + BOOST_LOG_TRIVIAL(trace) << "tsbk33 iden up tdma id " << std::dec << iden << " f " << temp_chan.frequency << " offset " << temp_chan.offset << " spacing " << temp_chan.step << " slots/carrier " << temp_chan.slots_per_carrier; } } else if (opcode == 0x34) { // iden_up vhf uhf unsigned long iden = bitset_shift_mask(tsbk, 76, 0xf); @@ -804,15 +804,15 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, bandwidth}; add_channel(iden, temp_chan, sys_num); - BOOST_LOG_TRIVIAL(info) << "tsbk34 iden vhf/uhf id " << std::dec << iden << " toff " << toff * spac * 0.125 * 1e-3 << " spac " << spac * 0.125 << " freq " << freq * 0.000005 << " [ " << txt[toff_sign] << "]"; + BOOST_LOG_TRIVIAL(trace) << "tsbk34 iden vhf/uhf id " << std::dec << iden << " toff " << toff * spac * 0.125 * 1e-3 << " spac " << spac * 0.125 << " freq " << freq * 0.000005 << " [ " << txt[toff_sign] << "]"; } else if (opcode == 0x35) { // Time and Date Announcement - BOOST_LOG_TRIVIAL(info) << "tsbk35 Time and Date Announcement"; + BOOST_LOG_TRIVIAL(trace) << "tsbk35 Time and Date Announcement"; } else if (opcode == 0x36) { // - BOOST_LOG_TRIVIAL(info) << "tsbk36 ROAMING ADDRESS COMMAND"; + BOOST_LOG_TRIVIAL(trace) << "tsbk36 ROAMING ADDRESS COMMAND"; } else if (opcode == 0x37) { // - BOOST_LOG_TRIVIAL(info) << "tsbk37 ROAMING ADDRESS UPDATE"; + BOOST_LOG_TRIVIAL(trace) << "tsbk37 ROAMING ADDRESS UPDATE"; } else if (opcode == 0x38) { // - BOOST_LOG_TRIVIAL(info) << "tsbk38 SYSTEM SERVICE BROADCAST"; + BOOST_LOG_TRIVIAL(trace) << "tsbk38 SYSTEM SERVICE BROADCAST"; } else if (opcode == 0x39) { // secondary cc unsigned long rfid = bitset_shift_mask(tsbk, 72, 0xff); unsigned long stid = bitset_shift_mask(tsbk, 64, 0xff); @@ -834,7 +834,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "tsbk39 secondary cc: rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") ch2 " << ch2 << "(" << channel_id_to_string(ch2, sys_num) << ") "; message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } else if (opcode == 0x3a) { // rfss status unsigned long syid = bitset_shift_mask(tsbk, 56, 0xfff); unsigned long rfid = bitset_shift_mask(tsbk, 48, 0xff); @@ -844,7 +844,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.sys_id = syid; os << "tsbk3a rfss status: syid: " << syid << " rfid " << rfid << " stid " << stid << " ch1 " << chan << "(" << channel_id_to_string(chan, sys_num) << ")"; message.meta = os.str(); - BOOST_LOG_TRIVIAL(info) << os.str(); + BOOST_LOG_TRIVIAL(trace) << os.str(); } else if (opcode == 0x3b) { // network status unsigned long wacn = bitset_shift_mask(tsbk, 52, 0xfffff); unsigned long syid = bitset_shift_mask(tsbk, 40, 0xfff); @@ -857,13 +857,13 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.sys_id = syid; message.freq = f1; } - BOOST_LOG_TRIVIAL(info) << "tsbk3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; + BOOST_LOG_TRIVIAL(trace) << "tsbk3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; } else if (opcode == 0x3c) { // adjacent status unsigned long rfid = bitset_shift_mask(tsbk, 48, 0xff); unsigned long stid = bitset_shift_mask(tsbk, 40, 0xff); unsigned long ch1 = bitset_shift_mask(tsbk, 24, 0xffff); unsigned long f1 = channel_id_to_frequency(ch1, sys_num); - BOOST_LOG_TRIVIAL(info) << "tsbk3c\tAdjacent Status\t rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; + BOOST_LOG_TRIVIAL(trace) << "tsbk3c\tAdjacent Status\t rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; if (f1) { it = channels[stid].find((ch1 >> 12) & 0xf); @@ -874,7 +874,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, // self.adjacent[f1] = 'rfid: %d stid:%d uplink:%f // tbl:%d' % (rfid, stid, (f1 + self.freq_table[table]['offset']) / // 1000000.0, table) - BOOST_LOG_TRIVIAL(info) << "\ttsbk3c Chan " << temp_chan.frequency << " " << temp_chan.step; + BOOST_LOG_TRIVIAL(trace) << "\ttsbk3c Chan " << temp_chan.frequency << " " << temp_chan.step; } } } else if (opcode == 0x3d) { // iden_up @@ -899,9 +899,9 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, 1, // slots bw * .125}; add_channel(iden, temp_chan, sys_num); - BOOST_LOG_TRIVIAL(info) << "tsbk3d iden id " << std::dec << iden << " toff " << toff * 0.25 << " spac " << spac * 0.125 << " freq " << freq * 0.000005; + BOOST_LOG_TRIVIAL(trace) << "tsbk3d iden id " << std::dec << iden << " toff " << toff * 0.25 << " spac " << spac * 0.125 << " freq " << freq * 0.000005; } else { - BOOST_LOG_TRIVIAL(info) << "tsbk other " << std::hex << opcode; + BOOST_LOG_TRIVIAL(trace) << "tsbk other " << std::hex << opcode; return messages; } messages.push_back(message); @@ -911,7 +911,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, void P25Parser::print_bitset(boost::dynamic_bitset<> &tsbk) { /*boost::dynamic_bitset<> bitmask(tsbk.size(), 0x3f); unsigned long result = (tsbk & bitmask).to_ulong(); - BOOST_LOG_TRIVIAL(info) << tsbk << " = " << std::hex << result;*/ + BOOST_LOG_TRIVIAL(trace) << tsbk << " = " << std::hex << result;*/ } void printbincharpad(char c) { @@ -935,7 +935,7 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System if (type == -2) { // # request from gui std::string cmd = msg->to_string(); - BOOST_LOG_TRIVIAL(info) << "process_qmsg: command: " << cmd; + BOOST_LOG_TRIVIAL(trace) << "process_qmsg: command: " << cmd; // self.update_state(cmd, curr_time) messages.push_back(message); @@ -946,7 +946,7 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System messages.push_back(message); return messages; } else if (type < 0) { - BOOST_LOG_TRIVIAL(info) << "unknown message type " << type; + BOOST_LOG_TRIVIAL(trace) << "unknown message type " << type; messages.push_back(message); return messages; } @@ -974,11 +974,11 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System } s = s.substr(2); - BOOST_LOG_TRIVIAL(trace) << std::hex << "nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); + BOOST_LOG_TRIVIAL(debug) << std::hex << "nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); // //" at %f state %d len %d" %(nac, type, time.time(), self.state, len(s)) if ((type != 7) && (type != 12)) // and nac not in self.trunked_systems: { - BOOST_LOG_TRIVIAL(info) << std::hex << "NON TBSK: nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); + BOOST_LOG_TRIVIAL(trace) << std::hex << "NON TBSK: nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); /* if not self.configs: @@ -1045,12 +1045,12 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System mbt_data <<= 32; // for missing crc unsigned long opcode = bitset_shift_mask(header, 32, 0x3f); unsigned long link_id = bitset_shift_mask(header, 48, 0xffffff); - /*BOOST_LOG_TRIVIAL(info) << "RAW Data " < Date: Mon, 29 May 2023 10:02:39 -0400 Subject: [PATCH 07/22] Update p25_parser.cc --- trunk-recorder/systems/p25_parser.cc | 148 +++++++++++++-------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/trunk-recorder/systems/p25_parser.cc b/trunk-recorder/systems/p25_parser.cc index 6ab3ff5f7..0c8522597 100644 --- a/trunk-recorder/systems/p25_parser.cc +++ b/trunk-recorder/systems/p25_parser.cc @@ -110,7 +110,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.freq = 0; message.opcode = opcode; - BOOST_LOG_TRIVIAL(trace) << "decode_mbt_data: $" << opcode; + BOOST_LOG_TRIVIAL(debug) << "decode_mbt_data: $" << opcode; if (opcode == 0x0) { // grp voice channel grant // unsigned long mfrid = bitset_shift_mask(header, 72, 0xff); unsigned long ch1 = bitset_shift_mask(mbt_data, 64, 0xffff); @@ -146,7 +146,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost os << "mbt00\tChan Grant\tChannel 1 ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tChannel 2 ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tga " << std::setw(7) << ga << "\tTDMA " << get_tdma_slot(ch1, sys_num) << "\tsa " << sa << "\tEncrypt " << encrypted << "\tBandwidth: " << get_bandwidth(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } else if (opcode == 0x02) { // grp regroup voice channel grant unsigned long mfrid = bitset_shift_mask(mbt_data, 168, 0xff); if (mfrid == 0x90) { // MOT_GRG_CN_GRANT_EXP @@ -169,7 +169,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost os << "mbt02\tmfid90_grg_cn_grant_exp\tChannel 1 ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tChannel 2 ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tsg " << std::setw(7) << sg << "\tTDMA " << get_tdma_slot(ch1, sys_num) << "\tBandwidth: " << get_bandwidth(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } } else if (opcode == 0x028) { // grp_aff_rsp unsigned long mfrid = bitset_shift_mask(mbt_data, 56, 0xff); @@ -183,7 +183,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost os << "mbt28\tmbt(0x28) grp_aff_rsp:\tMFRID: " << mfrid << "\tWACN: " << wacn << "\tSYID: " << syid << "\tLG: " << lg << "\tGAV: " << gav << "\tADA: " << ada << "\tGA: " << ga << "\tLG: " << lg; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } else if (opcode == 0x3a) { // rfss status unsigned long syid = bitset_shift_mask(header, 48, 0xfff); unsigned long rfid = bitset_shift_mask(mbt_data, 88, 0xff); @@ -196,7 +196,7 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.sys_id = syid; os << "mbt3a rfss status: syid: " << syid << " rfid " << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ")"; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } else if (opcode == 0x3b) { // network status unsigned long wacn = bitset_shift_mask(mbt_data, 76, 0xfffff); unsigned long syid = bitset_shift_mask(header, 48, 0xfff); @@ -211,14 +211,14 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.sys_id = syid; message.freq = f1; } - BOOST_LOG_TRIVIAL(trace) << "mbt3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; + BOOST_LOG_TRIVIAL(debug) << "mbt3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; } else if (opcode == 0x3c) { // adjacent status unsigned long syid = bitset_shift_mask(header, 48, 0xfff); unsigned long rfid = bitset_shift_mask(header, 24, 0xff); unsigned long stid = bitset_shift_mask(header, 16, 0xff); unsigned long ch1 = bitset_shift_mask(mbt_data, 80, 0xffff); unsigned long ch2 = bitset_shift_mask(mbt_data, 64, 0xffff); - BOOST_LOG_TRIVIAL(trace) << "mbt3c adjacent status " + BOOST_LOG_TRIVIAL(debug) << "mbt3c adjacent status " << "syid " << syid << " rfid " << rfid << " stid " << stid << " ch1 " << ch1 << " ch2 " << ch2; } else if (opcode == 0x04) { // Unit to Unit Voice Service Channel Grant -Extended (UU_V_CH_GRANT) // unsigned long mfrid = bitset_shift_mask(header, 80, 0xff); @@ -249,9 +249,9 @@ std::vector P25Parser::decode_mbt_data(unsigned long opcode, boost message.tdma_slot = 0; } - BOOST_LOG_TRIVIAL(trace) << "mbt04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; + BOOST_LOG_TRIVIAL(debug) << "mbt04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else { - BOOST_LOG_TRIVIAL(trace) << "mbt other: " << opcode; + BOOST_LOG_TRIVIAL(debug) << "mbt other: " << opcode; return messages; } messages.push_back(message); @@ -281,7 +281,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.freq = 0; message.opcode = opcode; - BOOST_LOG_TRIVIAL(debug) << "TSBK: opcode: $" << std::hex << opcode; + BOOST_LOG_TRIVIAL(trace) << "TSBK: opcode: $" << std::hex << opcode; if (opcode == 0x00) { // group voice chan grant // Group Voice Channel Grant (GRP_V_CH_GRANT) @@ -292,7 +292,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, unsigned long ga1 = bitset_shift_mask(tsbk, 48, 0xffff); unsigned long ga2 = bitset_shift_mask(tsbk, 32, 0xffff); unsigned long ga3 = bitset_shift_mask(tsbk, 16, 0xffff); - BOOST_LOG_TRIVIAL(trace) << "tsbk00\tMoto Patch Add \tsg: " << sg << "\tga1: " << ga1 << "\tga2: " << ga2 << "\tga3: " << ga3; + BOOST_LOG_TRIVIAL(debug) << "tsbk00\tMoto Patch Add \tsg: " << sg << "\tga1: " << ga1 << "\tga2: " << ga2 << "\tga3: " << ga3; message.message_type = PATCH_ADD; PatchData moto_patch_data; moto_patch_data.sg = sg; @@ -330,7 +330,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "tsbk00\tChan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tsa " << sa << "\tEncrypt " << encrypted << "\tBandwidth: " << get_bandwidth(ch, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } } else if (opcode == 0x02) { // group voice chan grant update unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); @@ -358,7 +358,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, os << "tsbk02\tMoto Grant Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tsg " << std::setw(7) << sg << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tsa " << sa; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } else { unsigned long ch1 = bitset_shift_mask(tsbk, 64, 0xffff); unsigned long ga1 = bitset_shift_mask(tsbk, 48, 0xffff); @@ -399,7 +399,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "tsbk02\tGrant Update\tChannel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } } else if (opcode == 0x03) { // Group Voice Channel Update-Explicit (GRP_V_CH_GRANT_UPDT_EXP) // group voice chan grant update exp : TIA.102-AABC-B-2005 page 56 @@ -449,11 +449,11 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "MOT_GRG_CN_GRANT_UPDT(0x03): \tChannel ID: " << std::setw(5) << ch2 << "\tFreq: " << format_freq(f2) << "\tsg " << std::setw(7) << sg2 << "\tTDMA " << get_tdma_slot(ch2, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } os << "MOT_GRG_CN_GRANT_UPDT(0x03): \tChannel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tsg " << std::setw(7) << sg1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } else { unsigned long ch1 = bitset_shift_mask(tsbk, 48, 0xffff); unsigned long ch2 = bitset_shift_mask(tsbk, 32, 0xffff); @@ -476,7 +476,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, os << "tsbk03\tExplicit Grant Update\tTX Channel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tRX Channel ID: " << std::setw(5) << ch1 << "\tFreq: " << format_freq(f1) << "\tga " << std::setw(7) << ga1 << "\tTDMA " << get_tdma_slot(ch1, sys_num); message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } } else if (opcode == 0x04) { // Unit to Unit Voice Service Channel Grant (UU_V_CH_GRANT) // unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); @@ -508,7 +508,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.tdma_slot = 0; } - BOOST_LOG_TRIVIAL(trace) << "tsbk04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; + BOOST_LOG_TRIVIAL(debug) << "tsbk04\tUnit to Unit Chan Grant\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else if (opcode == 0x05) { // Unit To Unit Answer Request bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); @@ -527,7 +527,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.source = sa; message.talkgroup = si; - BOOST_LOG_TRIVIAL(trace) << "tsbk05\tUnit To Unit Answer Request\tsa " << sa << "\tSource ID: " << si; + BOOST_LOG_TRIVIAL(debug) << "tsbk05\tUnit To Unit Answer Request\tsa " << sa << "\tSource ID: " << si; } else if (opcode == 0x06) { // Unit to Unit Voice Channel Grant Update (UU_V_CH_GRANT_UPDT) // unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -550,13 +550,13 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.tdma_slot = 0; } - BOOST_LOG_TRIVIAL(trace) << "tsbk06\tUnit to Unit Chan Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; + BOOST_LOG_TRIVIAL(debug) << "tsbk06\tUnit to Unit Chan Update\tChannel ID: " << std::setw(5) << ch << "\tFreq: " << format_freq(f) << "\tTarget ID: " << std::setw(7) << ta << "\tTDMA " << get_tdma_slot(ch, sys_num) << "\tSource ID: " << sa; } else if (opcode == 0x08) { - BOOST_LOG_TRIVIAL(trace) << "tsbk08: Telephone Interconnect Voice Channel Grant"; + BOOST_LOG_TRIVIAL(debug) << "tsbk08: Telephone Interconnect Voice Channel Grant"; } else if (opcode == 0x09) { - BOOST_LOG_TRIVIAL(trace) << "tsbk09: Telephone Interconnect Voice Channel Grant Update"; + BOOST_LOG_TRIVIAL(debug) << "tsbk09: Telephone Interconnect Voice Channel Grant Update"; } else if (opcode == 0x0a) { - BOOST_LOG_TRIVIAL(trace) << "tsbk0a: Telephone Interconnect Answer Request"; + BOOST_LOG_TRIVIAL(debug) << "tsbk0a: Telephone Interconnect Answer Request"; } else if (opcode == 0x14) { bool emergency = (bool)bitset_shift_mask(tsbk, 72, 0x80); bool encrypted = (bool)bitset_shift_mask(tsbk, 72, 0x40); @@ -577,21 +577,21 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.source = sa; message.freq = fT; - BOOST_LOG_TRIVIAL(trace) << "tsbk14\tSNDCP Data Channel Grant\tsa " << sa << "\tChannels: " << chT << "/" << chR << " Freqs: " << format_freq(fT) << "/" << format_freq(fR) << " NSAPI: " << nsapi; + BOOST_LOG_TRIVIAL(debug) << "tsbk14\tSNDCP Data Channel Grant\tsa " << sa << "\tChannels: " << chT << "/" << chR << " Freqs: " << format_freq(fT) << "/" << format_freq(fR) << " NSAPI: " << nsapi; } else if (opcode == 0x15) { - BOOST_LOG_TRIVIAL(trace) << "tsbk15: SNDCP Data Page Request"; + BOOST_LOG_TRIVIAL(debug) << "tsbk15: SNDCP Data Page Request"; } else if (opcode == 0x16) { - BOOST_LOG_TRIVIAL(trace) << "tsbk16: SNDCP Data Channel Announcement -Explicit"; + BOOST_LOG_TRIVIAL(debug) << "tsbk16: SNDCP Data Channel Announcement -Explicit"; } else if (opcode == 0x18) { - BOOST_LOG_TRIVIAL(trace) << "tsbk18: Status Update"; + BOOST_LOG_TRIVIAL(debug) << "tsbk18: Status Update"; } else if (opcode == 0x1a) { - BOOST_LOG_TRIVIAL(trace) << "tsbk1a: Status Query"; + BOOST_LOG_TRIVIAL(debug) << "tsbk1a: Status Query"; } else if (opcode == 0x1c) { - BOOST_LOG_TRIVIAL(trace) << "tsbk1c: Messag Update"; + BOOST_LOG_TRIVIAL(debug) << "tsbk1c: Messag Update"; } else if (opcode == 0x1d) { - BOOST_LOG_TRIVIAL(trace) << "tsbk1d: Radio Unit Monitor Command"; + BOOST_LOG_TRIVIAL(debug) << "tsbk1d: Radio Unit Monitor Command"; } else if (opcode == 0x1f) { - BOOST_LOG_TRIVIAL(trace) << "tsbk1f: Call Alert"; + BOOST_LOG_TRIVIAL(debug) << "tsbk1f: Call Alert"; } else if (opcode == 0x20) { // Acknowledge response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); unsigned long ga = bitset_shift_mask(tsbk, 40, 0xffff); @@ -602,13 +602,13 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.talkgroup = ga; message.source = sa; - BOOST_LOG_TRIVIAL(trace) << "tsbk20\tAcknowledge Response\tga " << std::dec << ga << "\tsa " << sa << "\tReserved: " << op; + BOOST_LOG_TRIVIAL(debug) << "tsbk20\tAcknowledge Response\tga " << std::dec << ga << "\tsa " << sa << "\tReserved: " << op; } else if (opcode == 0x21) { - BOOST_LOG_TRIVIAL(trace) << "tsbk21: Extended Function Command"; + BOOST_LOG_TRIVIAL(debug) << "tsbk21: Extended Function Command"; } else if (opcode == 0x24) { - BOOST_LOG_TRIVIAL(trace) << "tsbk24: Extended Function Command"; + BOOST_LOG_TRIVIAL(debug) << "tsbk24: Extended Function Command"; } else if (opcode == 0x27) { - BOOST_LOG_TRIVIAL(trace) << "tsbk27: Deny Response"; + BOOST_LOG_TRIVIAL(debug) << "tsbk27: Deny Response"; } else if (opcode == 0x28) { // Unit Group Affiliation Response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -620,7 +620,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.source = ta; message.talkgroup = ga; - BOOST_LOG_TRIVIAL(trace) << "tsbk2f\tUnit Group Affiliation\tSource ID: " << std::setw(7) << ta << "\tGroup Address: " << std::dec << ga << "\tAnouncement Goup: " << aga; + BOOST_LOG_TRIVIAL(debug) << "tsbk2f\tUnit Group Affiliation\tSource ID: " << std::setw(7) << ta << "\tGroup Address: " << std::dec << ga << "\tAnouncement Goup: " << aga; } else if (opcode == 0x29) { // Secondary Control Channel Broadcast - Explicit unsigned long rfid = bitset_shift_mask(tsbk, 72, 0xff); unsigned long stid = bitset_shift_mask(tsbk, 64, 0xff); @@ -643,10 +643,10 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, os << "tsbk29 secondary cc: rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") ch2 " << ch2 << "(" << channel_id_to_string(ch2, sys_num) << ") "; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } else if (opcode == 0x2a) { // Group Affiliation Query - BOOST_LOG_TRIVIAL(trace) << "tsbk2a Group Affiliation Query"; + BOOST_LOG_TRIVIAL(debug) << "tsbk2a Group Affiliation Query"; } else if (opcode == 0x2b) { // Location Registration Response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); unsigned long ga = bitset_shift_mask(tsbk, 56, 0xffff); @@ -657,7 +657,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.talkgroup = ga; message.source = sa; - BOOST_LOG_TRIVIAL(trace) << "tsbk2b\tLocation Registration Response\tga " << std::dec << ga << "\tsa " << sa << "\tValue: " << rv; + BOOST_LOG_TRIVIAL(debug) << "tsbk2b\tLocation Registration Response\tga " << std::dec << ga << "\tsa " << sa << "\tValue: " << rv; } else if (opcode == 0x2c) { // Unit Registration Response // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -667,11 +667,11 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.message_type = REGISTRATION; message.source = si; - BOOST_LOG_TRIVIAL(trace) << "tsbk2c\tUnit Registration COMMAND\tsa " << std::setw(7) << sa << " Source ID: " << si; + BOOST_LOG_TRIVIAL(debug) << "tsbk2c\tUnit Registration COMMAND\tsa " << std::setw(7) << sa << " Source ID: " << si; } else if (opcode == 0x2d) { // - BOOST_LOG_TRIVIAL(trace) << "tsbk2d AUTHENTICATION COMMAND"; + BOOST_LOG_TRIVIAL(debug) << "tsbk2d AUTHENTICATION COMMAND"; } else if (opcode == 0x2e) { // - BOOST_LOG_TRIVIAL(trace) << "tsbk2e DE-REGISTRATION ACKNOWLEDGE"; + BOOST_LOG_TRIVIAL(debug) << "tsbk2e DE-REGISTRATION ACKNOWLEDGE"; } else if (opcode == 0x2f) { // Unit DeRegistration Ack // unsigned long mfrid = bitset_shift_mask(tsbk,80,0xff); // unsigned long opts = bitset_shift_mask(tsbk,72,0xff); @@ -680,7 +680,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.message_type = DEREGISTRATION; message.source = si; - BOOST_LOG_TRIVIAL(trace) << "tsbk2f\tUnit Deregistration ACK\tSource ID: " << std::setw(7) << si; + BOOST_LOG_TRIVIAL(debug) << "tsbk2f\tUnit Deregistration ACK\tSource ID: " << std::setw(7) << si; } else if (opcode == 0x30) { unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); if (mfrid == 0xA4) { // GRG_EXENC_CMD (M/A-COM patch) @@ -702,7 +702,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(trace) << "tsbk30 M/A-COM GROUP REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; + BOOST_LOG_TRIVIAL(debug) << "tsbk30 M/A-COM GROUP REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; } else { message.message_type = PATCH_ADD; PatchData harris_patch_data; @@ -711,7 +711,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(trace) << "tsbk30 M/A-COM UNIT REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; + BOOST_LOG_TRIVIAL(debug) << "tsbk30 M/A-COM UNIT REQUEST PATCH sg TGID is " << sg << " patched with TGID " << ga; } } else { // Deactivate if (grg_g == 1) { // Group request @@ -722,7 +722,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(trace) << "tsbk30 M/A-COM GROUP REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; + BOOST_LOG_TRIVIAL(debug) << "tsbk30 M/A-COM GROUP REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; } else { message.message_type = PATCH_DELETE; PatchData harris_patch_data; @@ -731,16 +731,16 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, harris_patch_data.ga2 = ga; harris_patch_data.ga3 = ga; message.patch_data = harris_patch_data; - BOOST_LOG_TRIVIAL(trace) << "tsbk30 M/A-COM UNIT REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; + BOOST_LOG_TRIVIAL(debug) << "tsbk30 M/A-COM UNIT REQUEST PATCH DELETE for sg " << sg << " with TGID " << ga; } } } else { - BOOST_LOG_TRIVIAL(trace) << "tsbk30 TDMA SYNCHRONIZATION BROADCAST"; + BOOST_LOG_TRIVIAL(debug) << "tsbk30 TDMA SYNCHRONIZATION BROADCAST"; } } else if (opcode == 0x31) { // - BOOST_LOG_TRIVIAL(trace) << "tsbk31 AUTHENTICATION DEMAND"; + BOOST_LOG_TRIVIAL(debug) << "tsbk31 AUTHENTICATION DEMAND"; } else if (opcode == 0x32) { // - BOOST_LOG_TRIVIAL(trace) << "tsbk32 AUTHENTICATION RESPONSE"; + BOOST_LOG_TRIVIAL(debug) << "tsbk32 AUTHENTICATION RESPONSE"; } else if (opcode == 0x33) { // iden_up_tdma unsigned long mfrid = bitset_shift_mask(tsbk, 80, 0xff); @@ -772,7 +772,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, slots_per_carrier[channel_type], // tdma; 6.25}; add_channel(iden, temp_chan, sys_num); - BOOST_LOG_TRIVIAL(trace) << "tsbk33 iden up tdma id " << std::dec << iden << " f " << temp_chan.frequency << " offset " << temp_chan.offset << " spacing " << temp_chan.step << " slots/carrier " << temp_chan.slots_per_carrier; + BOOST_LOG_TRIVIAL(debug) << "tsbk33 iden up tdma id " << std::dec << iden << " f " << temp_chan.frequency << " offset " << temp_chan.offset << " spacing " << temp_chan.step << " slots/carrier " << temp_chan.slots_per_carrier; } } else if (opcode == 0x34) { // iden_up vhf uhf unsigned long iden = bitset_shift_mask(tsbk, 76, 0xf); @@ -804,15 +804,15 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, bandwidth}; add_channel(iden, temp_chan, sys_num); - BOOST_LOG_TRIVIAL(trace) << "tsbk34 iden vhf/uhf id " << std::dec << iden << " toff " << toff * spac * 0.125 * 1e-3 << " spac " << spac * 0.125 << " freq " << freq * 0.000005 << " [ " << txt[toff_sign] << "]"; + BOOST_LOG_TRIVIAL(debug) << "tsbk34 iden vhf/uhf id " << std::dec << iden << " toff " << toff * spac * 0.125 * 1e-3 << " spac " << spac * 0.125 << " freq " << freq * 0.000005 << " [ " << txt[toff_sign] << "]"; } else if (opcode == 0x35) { // Time and Date Announcement - BOOST_LOG_TRIVIAL(trace) << "tsbk35 Time and Date Announcement"; + BOOST_LOG_TRIVIAL(debug) << "tsbk35 Time and Date Announcement"; } else if (opcode == 0x36) { // - BOOST_LOG_TRIVIAL(trace) << "tsbk36 ROAMING ADDRESS COMMAND"; + BOOST_LOG_TRIVIAL(debug) << "tsbk36 ROAMING ADDRESS COMMAND"; } else if (opcode == 0x37) { // - BOOST_LOG_TRIVIAL(trace) << "tsbk37 ROAMING ADDRESS UPDATE"; + BOOST_LOG_TRIVIAL(debug) << "tsbk37 ROAMING ADDRESS UPDATE"; } else if (opcode == 0x38) { // - BOOST_LOG_TRIVIAL(trace) << "tsbk38 SYSTEM SERVICE BROADCAST"; + BOOST_LOG_TRIVIAL(debug) << "tsbk38 SYSTEM SERVICE BROADCAST"; } else if (opcode == 0x39) { // secondary cc unsigned long rfid = bitset_shift_mask(tsbk, 72, 0xff); unsigned long stid = bitset_shift_mask(tsbk, 64, 0xff); @@ -834,7 +834,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, } os << "tsbk39 secondary cc: rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") ch2 " << ch2 << "(" << channel_id_to_string(ch2, sys_num) << ") "; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } else if (opcode == 0x3a) { // rfss status unsigned long syid = bitset_shift_mask(tsbk, 56, 0xfff); unsigned long rfid = bitset_shift_mask(tsbk, 48, 0xff); @@ -844,7 +844,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.sys_id = syid; os << "tsbk3a rfss status: syid: " << syid << " rfid " << rfid << " stid " << stid << " ch1 " << chan << "(" << channel_id_to_string(chan, sys_num) << ")"; message.meta = os.str(); - BOOST_LOG_TRIVIAL(trace) << os.str(); + BOOST_LOG_TRIVIAL(debug) << os.str(); } else if (opcode == 0x3b) { // network status unsigned long wacn = bitset_shift_mask(tsbk, 52, 0xfffff); unsigned long syid = bitset_shift_mask(tsbk, 40, 0xfff); @@ -857,13 +857,13 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, message.sys_id = syid; message.freq = f1; } - BOOST_LOG_TRIVIAL(trace) << "tsbk3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; + BOOST_LOG_TRIVIAL(debug) << "tsbk3b net stat: wacn " << std::dec << wacn << " syid " << syid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; } else if (opcode == 0x3c) { // adjacent status unsigned long rfid = bitset_shift_mask(tsbk, 48, 0xff); unsigned long stid = bitset_shift_mask(tsbk, 40, 0xff); unsigned long ch1 = bitset_shift_mask(tsbk, 24, 0xffff); unsigned long f1 = channel_id_to_frequency(ch1, sys_num); - BOOST_LOG_TRIVIAL(trace) << "tsbk3c\tAdjacent Status\t rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; + BOOST_LOG_TRIVIAL(debug) << "tsbk3c\tAdjacent Status\t rfid " << std::dec << rfid << " stid " << stid << " ch1 " << ch1 << "(" << channel_id_to_string(ch1, sys_num) << ") "; if (f1) { it = channels[stid].find((ch1 >> 12) & 0xf); @@ -874,7 +874,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, // self.adjacent[f1] = 'rfid: %d stid:%d uplink:%f // tbl:%d' % (rfid, stid, (f1 + self.freq_table[table]['offset']) / // 1000000.0, table) - BOOST_LOG_TRIVIAL(trace) << "\ttsbk3c Chan " << temp_chan.frequency << " " << temp_chan.step; + BOOST_LOG_TRIVIAL(debug) << "\ttsbk3c Chan " << temp_chan.frequency << " " << temp_chan.step; } } } else if (opcode == 0x3d) { // iden_up @@ -899,9 +899,9 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, 1, // slots bw * .125}; add_channel(iden, temp_chan, sys_num); - BOOST_LOG_TRIVIAL(trace) << "tsbk3d iden id " << std::dec << iden << " toff " << toff * 0.25 << " spac " << spac * 0.125 << " freq " << freq * 0.000005; + BOOST_LOG_TRIVIAL(debug) << "tsbk3d iden id " << std::dec << iden << " toff " << toff * 0.25 << " spac " << spac * 0.125 << " freq " << freq * 0.000005; } else { - BOOST_LOG_TRIVIAL(trace) << "tsbk other " << std::hex << opcode; + BOOST_LOG_TRIVIAL(debug) << "tsbk other " << std::hex << opcode; return messages; } messages.push_back(message); @@ -911,7 +911,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, void P25Parser::print_bitset(boost::dynamic_bitset<> &tsbk) { /*boost::dynamic_bitset<> bitmask(tsbk.size(), 0x3f); unsigned long result = (tsbk & bitmask).to_ulong(); - BOOST_LOG_TRIVIAL(trace) << tsbk << " = " << std::hex << result;*/ + BOOST_LOG_TRIVIAL(debug) << tsbk << " = " << std::hex << result;*/ } void printbincharpad(char c) { @@ -935,7 +935,7 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System if (type == -2) { // # request from gui std::string cmd = msg->to_string(); - BOOST_LOG_TRIVIAL(trace) << "process_qmsg: command: " << cmd; + BOOST_LOG_TRIVIAL(debug) << "process_qmsg: command: " << cmd; // self.update_state(cmd, curr_time) messages.push_back(message); @@ -946,7 +946,7 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System messages.push_back(message); return messages; } else if (type < 0) { - BOOST_LOG_TRIVIAL(trace) << "unknown message type " << type; + BOOST_LOG_TRIVIAL(debug) << "unknown message type " << type; messages.push_back(message); return messages; } @@ -974,11 +974,11 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System } s = s.substr(2); - BOOST_LOG_TRIVIAL(debug) << std::hex << "nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); + BOOST_LOG_TRIVIAL(trace) << std::hex << "nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); // //" at %f state %d len %d" %(nac, type, time.time(), self.state, len(s)) if ((type != 7) && (type != 12)) // and nac not in self.trunked_systems: { - BOOST_LOG_TRIVIAL(trace) << std::hex << "NON TBSK: nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); + BOOST_LOG_TRIVIAL(debug) << std::hex << "NON TBSK: nac " << nac << std::dec << " type " << type << " size " << msg->to_string().length() << " mesg len: " << msg->length(); /* if not self.configs: @@ -1045,12 +1045,12 @@ std::vector P25Parser::parse_message(gr::message::sptr msg, System mbt_data <<= 32; // for missing crc unsigned long opcode = bitset_shift_mask(header, 32, 0x3f); unsigned long link_id = bitset_shift_mask(header, 48, 0xffffff); - /*BOOST_LOG_TRIVIAL(trace) << "RAW Data " < Date: Mon, 29 May 2023 10:21:21 -0400 Subject: [PATCH 08/22] Update transmission_sink.cc --- trunk-recorder/gr_blocks/transmission_sink.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 9829bb34f..d26519dfd 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -146,7 +146,7 @@ bool transmission_sink::start_recording(Call *call) { state = IDLE; /* Should reset more variables here */ - BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting wavfile sink SRC ID: " << curr_src_id << " Conventional: " << d_conventional; + BOOST_LOG_TRIVIAL(trace) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tStarting wavfile sink SRC ID: " << curr_src_id << " Conventional: " << d_conventional; return true; } From 71105016e2ed18cc29211453bd092588556b7e4a Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 29 May 2023 22:12:34 -0400 Subject: [PATCH 09/22] Updated the Mermaid charts --- docs/notes/CALL-HANDLING.md | 56 ++++++++++--------------------------- trunk-recorder/main.cc | 1 + 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/docs/notes/CALL-HANDLING.md b/docs/notes/CALL-HANDLING.md index 7dec672f2..98733e227 100644 --- a/docs/notes/CALL-HANDLING.md +++ b/docs/notes/CALL-HANDLING.md @@ -2,13 +2,12 @@ Use [Mermaid Live](https://mermaid.live/) to edit the charts. ```mermaid flowchart TD -A[Control Channel] -->|GRANT| B["handle_call_grant()"] +A[Control Channel] -->|GRANT or UPDATE| B["handle_call_grant()"] B --> C{Existing Call on Freq?} C -.->|Yes| D{Same Talkgroup?} C -.->|No| G["new Call()"] -D -.->|Yes| E["call->set_record_more_transmissions(True)"] -D -.->|No| F[Delete Existing Call] -F -.-> G +D -.->|Yes| E["call->update()"] +D -.->|No| F[Do nothing.\n The Recorder will notice the \ndifferent Talkgroup and stop] G -.-> H["start_recording()"] ``` @@ -16,60 +15,35 @@ G -.-> H["start_recording()"] flowchart TD A1[Voice Channel] --> B1[Transmission Sink] B1 -.->|Samples| C1{State} +B1 -.->|GROUP ID| V1{GROUP ID \n==\nCALL TG} +V1 -.->|Mismatch|Q1{Sample\nCount} +Q1 -.->|0| R1[state = IGNORE] +Q1 -.->|>0| S1[End Transmission] +S1 --> T1[state = STOPPED] C1 -.->|STOPPED| D1[Drop Samples] -C1 -.->|IDLE| F1["Setup files\nrecord_more_transmissions = false;\nd_first_work = false;\nstate = RECORDING"] +C1 -.->|IGNORE| D1 +C1 -.->|IDLE| F1["Setup files\nstate = RECORDING"] C1 -.->|RECORDING| G1[Write Samples] +G1 --> U1[Update d_last_write_time] F1 -.-> G1 B1 -.->|TERMINATOR| H1["End Transmission"] -H1 -.-> I1{"record_more_transmissions"} -I1 -.->|False| J1["state = STOPPED"] -I1 -.->|True| K1["state = IDLE"] -L1["set_record_more_transmissions(True)"] -.-> N1{state == STOPPED} -N1 -.->|True| O1["state == IDLE"] -N1 -.->|False| P1["record_mode_transmissions = True"] -O1 -.-> P1 +H1 -.-> K1["state = IDLE"] ``` -```mermaid -flowchart TD -A[Control Channel] -->|UPDATE| B["handle_call_update()"] -B -.-> C[Find Call] -C -.-> D{"call->state"} -D -.->|COMPLETED| E[Do Nothing] -D -.->|INACTIVE| F["call->state==RECORDING"] -F -.-> G["call->update()"] -D -.->|RECORDING| G -G -.-> H["call->set_record_more_transmissions(True)"] - -``` - - ```mermaid flowchart TD A[For Each Call] -->|Call| B{state} - - -B -.->|RECORDING| C{"last_update > 1.0"} -C -.->|True| E["call->set_record_more_transmissions(false)\nstate = INACTIVE"] +B -.->|RECORDING| C{call->last_update > 3.0 &&\nrecroder->d_last_write_time > 3.0} +C -.->|True| H["Conclude Call"] C -.->|False| D[Next] -E -.-> D -B -.->|MONITORING| F{"last_update > 1.0"} +B -.->|MONITORING| F{"last_update > 3.0"} F -.->|True| G["Delete Call"] G -.-> D F -.->|False| D -B -.->|COMPLETED| H["Conclude Call"] H -.-> Z["Delete Call"] Z -.-> D -B -.->|INACTIVE| I{"since last_update > 5.0"} -I -.->|True| J[state = COMPLETED] -J -.-> K[Conclude Call] -K -.-> L[Delete Call] -I -.->|False| D -L -.-> D - - ``` diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 67825e4e2..092d4ea08 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -1001,6 +1001,7 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { continue; } + /* This is for Multi-Site support */ if (call->get_talkgroup() == message.talkgroup) { if ((call->get_phase2_tdma() == message.phase2_tdma) && (call->get_tdma_slot() == message.tdma_slot) ) { if (call->get_sys_num() != message.sys_num) { From c594ab7f64e508d608cacbe0651bdd79bda2bf2e Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 29 May 2023 22:19:08 -0400 Subject: [PATCH 10/22] REmoved COMPLETED --- trunk-recorder/call_impl.cc | 12 ++---------- trunk-recorder/main.cc | 21 ++------------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/trunk-recorder/call_impl.cc b/trunk-recorder/call_impl.cc index 3d7de85d7..06cc9c321 100644 --- a/trunk-recorder/call_impl.cc +++ b/trunk-recorder/call_impl.cc @@ -100,8 +100,7 @@ void Call_impl::stop_call() { // If the call is being recorded, check to see if the recorder is currently in an INACTIVE state. This means that the recorder is not // doing anything and can be stopped. if ((state == RECORDING) && this->get_recorder()->is_idle()) { - BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\tStopping Recorded Call_impl, setting call state to COMPLETED - Last Update: " << this->since_last_update() << "s"; - this->set_state(COMPLETED); + BOOST_LOG_TRIVIAL(info) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "\tFreq: " << format_freq(get_freq()) << "\tStopping Recorded Call_impl - Last Update: " << this->since_last_update() << "s"; } } } @@ -113,7 +112,7 @@ void Call_impl::conclude_call() { // BOOST_LOG_TRIVIAL(info) << "conclude_call()"; stop_time = time(NULL); - if (state == COMPLETED || (state == MONITORING && monitoringState == SUPERSEDED)) { + if (state == RECORDING || (state == MONITORING && monitoringState == SUPERSEDED)) { final_length = recorder->get_current_length(); if (!recorder) { @@ -136,9 +135,6 @@ void Call_impl::conclude_call() { Call_Concluder::conclude_call(this, sys, config); } - else { - BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tTG: " << this->get_talkgroup_display() << "Concluding call, but call state is not COMPLETED!"; - } } void Call_impl::set_sigmf_recorder(Recorder *r) { @@ -321,16 +317,12 @@ bool Call_impl::add_source(long src) { } bool Call_impl::update(TrunkMessage message) { - if ((state == INACTIVE) || (state == COMPLETED)) { - BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tCall_impl Update, but state is: " << state << " - Call_impl TG: " << get_talkgroup() << "\t Call_impl Freq: " << get_freq() << "\tMsg Tg: " << message.talkgroup << "\tMsg Freq: " << message.freq; - } else { last_update = time(NULL); if ((message.freq != this->curr_freq) || (message.talkgroup != this->talkgroup)) { BOOST_LOG_TRIVIAL(error) << "[" << sys->get_short_name() << "]\t\033[0;34m" << this->get_call_num() << "C\033[0m\tCall_impl Update, message mismatch - Call_impl TG: " << get_talkgroup() << "\t Call_impl Freq: " << get_freq() << "\tMsg Tg: " << message.talkgroup << "\tMsg Freq: " << message.freq; } else { return add_source(message.source); } - } return false; } diff --git a/trunk-recorder/main.cc b/trunk-recorder/main.cc index 092d4ea08..9d9ac33c7 100644 --- a/trunk-recorder/main.cc +++ b/trunk-recorder/main.cc @@ -792,7 +792,6 @@ void manage_conventional_call(Call *call) { // if no additional recording has happened in the past X periods, stop and open new file if (call->get_idle_count() > config.call_timeout) { Recorder *recorder = call->get_recorder(); - call->set_state(COMPLETED); call->conclude_call(); call->restart_call(); if (recorder != NULL) { @@ -801,7 +800,6 @@ void manage_conventional_call(Call *call) { } } else if ((call->get_current_length() > call->get_system()->get_max_duration()) && (call->get_system()->get_max_duration() > 0)) { Recorder *recorder = call->get_recorder(); - call->set_state(COMPLETED); call->conclude_call(); call->restart_call(); if (recorder != NULL) { @@ -889,8 +887,6 @@ void manage_calls() { // actually, we don't want to remove a recorder as soon as it is stopped because we want to drain everything from the gnuradio flowgraph if ((recorder->since_last_write() > config.call_timeout) && (call->since_last_update() > config.call_timeout)) { BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Stopping Call because of Recorder \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); - - call->set_state(COMPLETED); call->conclude_call(); // The State of the Recorders has changed, so lets send an update ended_call = true; @@ -910,8 +906,8 @@ void manage_calls() { BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36m Call UPDATEs has been inactive for more than " << config.call_timeout << " Sec \u001b[0m Rec last write: " << recorder->since_last_write() << " State: " << format_state(recorder->get_state()); // since the Call state is INACTIVE and the Recorder has been going on for a while, we can now - // set the Call state to COMPLETED - /* call->set_state(COMPLETED); + // + /* call->conclude_call(); // The State of the Recorders has changed, so lets send an update ended_call = true; @@ -995,12 +991,6 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { for (vector::iterator it = calls.begin(); it != calls.end();) { Call *call = *it; - /* This will skip all calls that are not currently acitve */ - if (call->get_state() == COMPLETED) { - ++it; - continue; - } - /* This is for Multi-Site support */ if (call->get_talkgroup() == message.talkgroup) { if ((call->get_phase2_tdma() == message.phase2_tdma) && (call->get_tdma_slot() == message.tdma_slot) ) { @@ -1074,7 +1064,6 @@ void handle_call_grant(TrunkMessage message, System *sys, bool grant_message) { } BOOST_LOG_TRIVIAL(trace) << "[" << call->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t\u001b[36mShould be Stopping RECORDING call, Recorder State: " << recorder_state << " RX overlapping TG message Freq, TG:" << message.talkgroup << "\u001b[0m"; /* - call->set_state(COMPLETED); call->conclude_call(); it = calls.erase(it); delete call; @@ -1143,11 +1132,6 @@ void handle_call_update(TrunkMessage message, System *sys) { for (vector::iterator it = calls.begin(); it != calls.end(); ++it) { Call *call = *it; - /* This will skip all calls that are not currently acitve */ - if (call->get_state() == COMPLETED) { - continue; - } - // BOOST_LOG_TRIVIAL(info) << "TG: " << call->get_talkgroup() << " | " << message.talkgroup << " sys num: " << call->get_sys_num() << " | " << message.sys_num << " freq: " << call->get_freq() << " | " << message.freq << " TDMA Slot" << call->get_tdma_slot() << " | " << message.tdma_slot << " TDMA: " << call->get_phase2_tdma() << " | " << message.phase2_tdma; if ((call->get_talkgroup() == message.talkgroup) && (call->get_sys_num() == message.sys_num) && (call->get_freq() == message.freq) && (call->get_tdma_slot() == message.tdma_slot) && (call->get_phase2_tdma() == message.phase2_tdma)) { call_found = true; @@ -1389,7 +1373,6 @@ void monitor_messages() { Call *call = *it; if (call->get_state() != MONITORING) { - call->set_state(COMPLETED); call->conclude_call(); } From ab3033f704ded1067c992d0fea34fe6fa5ba0e87 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 31 May 2023 21:03:27 -0400 Subject: [PATCH 11/22] MORE RESETS! --- trunk-recorder/formatter.cc | 4 ---- trunk-recorder/recorders/p25_recorder_decode.cc | 2 +- trunk-recorder/recorders/p25_recorder_fsk4_demod.cc | 8 ++++---- trunk-recorder/recorders/p25_recorder_impl.cc | 6 +++--- trunk-recorder/recorders/p25_recorder_qpsk_demod.cc | 4 ++-- trunk-recorder/state.h | 1 - 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/trunk-recorder/formatter.cc b/trunk-recorder/formatter.cc index bec3b0f6b..18322d8a9 100644 --- a/trunk-recorder/formatter.cc +++ b/trunk-recorder/formatter.cc @@ -42,8 +42,6 @@ std::string format_state(State state) { return "active"; else if (state == IDLE) return "idle"; - else if (state == COMPLETED) - return "completed"; else if (state == STOPPED) return "stopped"; else if (state == AVAILABLE) @@ -85,8 +83,6 @@ std::string format_state(State state, MonitoringState monitoringState) { return "active"; else if (state == IDLE) return "idle"; - else if (state == COMPLETED) - return "completed"; else if (state == STOPPED) return "stopped"; else if (state == AVAILABLE) diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index 148f178c7..8e685d3f5 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -123,7 +123,7 @@ void p25_recorder_decode::reset_block(gr::basic_block_sptr block) { gr::block_detail_sptr detail; gr::block_sptr grblock = cast_to_block_sptr(block); detail = grblock->detail(); - detail->reset_nitem_counters(); + //detail->reset_nitem_counters(); detail->clear_tags(); } diff --git a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc index adbfe1dbc..993d4642d 100644 --- a/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_fsk4_demod.cc @@ -22,16 +22,16 @@ void p25_recorder_fsk4_demod::reset_block(gr::basic_block_sptr block) { detail->reset_nitem_counters(); } void p25_recorder_fsk4_demod::reset() { - reset_block(pll_freq_lock); + /*reset_block(pll_freq_lock); reset_block(pll_amp); reset_block(noise_filter); reset_block(sym_filter); - reset_block(fsk4_demod); + reset_block(fsk4_demod);*/ /* pll_freq_lock->update_gains(); pll_freq_lock->frequency_limit(); - pll_freq_lock->phase_wrap(); - fsk4_demod->reset();*/ + pll_freq_lock->phase_wrap();*/ + fsk4_demod->reset(); // pll_demod->set_phase(0); } diff --git a/trunk-recorder/recorders/p25_recorder_impl.cc b/trunk-recorder/recorders/p25_recorder_impl.cc index bea6e4429..be4fed8d3 100644 --- a/trunk-recorder/recorders/p25_recorder_impl.cc +++ b/trunk-recorder/recorders/p25_recorder_impl.cc @@ -295,11 +295,11 @@ void p25_recorder_impl::clear() { //reset_block(fsk4_demod); // bad - Seg Faults //reset_block(fsk4_p25_decode); // bad - Seg Faults - + */ qpsk_demod->reset(); qpsk_p25_decode->reset(); fsk4_demod->reset(); - fsk4_p25_decode->reset();*/ + fsk4_p25_decode->reset(); } void p25_recorder_impl::autotune() { @@ -466,7 +466,7 @@ void p25_recorder_impl::stop() { state = INACTIVE; valve->set_enabled(false); - clear(); + clear(); if (qpsk_mod) { qpsk_p25_decode->stop(); } else { diff --git a/trunk-recorder/recorders/p25_recorder_qpsk_demod.cc b/trunk-recorder/recorders/p25_recorder_qpsk_demod.cc index 9bab015cf..5608644b9 100644 --- a/trunk-recorder/recorders/p25_recorder_qpsk_demod.cc +++ b/trunk-recorder/recorders/p25_recorder_qpsk_demod.cc @@ -31,12 +31,12 @@ void p25_recorder_qpsk_demod::reset() { costas->set_phase(0); costas->set_frequency(0); clock->reset(); - +/* reset_block(clock); reset_block(costas); reset_block(diffdec); reset_block(to_float); - reset_block(rescale); + reset_block(rescale);*/ } void p25_recorder_qpsk_demod::switch_tdma(bool phase2) { diff --git a/trunk-recorder/state.h b/trunk-recorder/state.h index ee497f4fc..4a1c38a5d 100644 --- a/trunk-recorder/state.h +++ b/trunk-recorder/state.h @@ -6,7 +6,6 @@ enum State { MONITORING = 0, INACTIVE = 2, ACTIVE = 3, IDLE = 4, - COMPLETED = 5, STOPPED = 6, AVAILABLE = 7, IGNORE = 8 }; From bf77b8c36ca86ca490889b439695387a4debb8c6 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 31 May 2023 21:19:22 -0400 Subject: [PATCH 12/22] Cleaned up setting GRP ID --- .../lib/p25_frame_assembler_impl.cc | 42 ++++++++++++------- trunk-recorder/gr_blocks/transmission_sink.cc | 15 +------ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index 21e490003..40c50bb58 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -110,7 +110,6 @@ static const int MAX_IN = 1; // maximum number of input streams output_queue(), op25audio(udp_host, port, debug), d_input_rate(4800), - d_tag_key(pmt::intern("src_id")), d_tag_src(pmt::intern(name())), d_silence_frames(silence_frames) { @@ -138,8 +137,10 @@ p25_frame_assembler_impl::general_work (int noutput_items, const uint8_t *in = (const uint8_t *) input_items[0]; bool terminate_call = false; - long p2_ptt_src_id = -1; - long p2_ptt_grp_id = -1; + long tdma_src_id = -1; + long tdma_grp_id = -1; + long fdma_src_id = -1; + long fdma_grp_id = -1; p1fdma.rx_sym(in, ninput_items[0]); if(d_do_phase2_tdma) { for (int i = 0; i < ninput_items[0]; i++) { @@ -150,8 +151,8 @@ p25_frame_assembler_impl::general_work (int noutput_items, p2tdma.reset_call_terminated(); } - p2_ptt_src_id = p2tdma.get_ptt_src_id(); - p2_ptt_grp_id = p2tdma.get_ptt_grp_id(); + tdma_src_id = p2tdma.get_ptt_src_id(); + tdma_grp_id = p2tdma.get_ptt_grp_id(); if (rc > -1) { p25p2_queue_msg(rc); @@ -164,6 +165,9 @@ p25_frame_assembler_impl::general_work (int noutput_items, terminate_call = true; p1fdma.reset_call_terminated(); } + + fdma_src_id = p1fdma.get_curr_src_id(); + fdma_grp_id = p1fdma.get_curr_grp_id(); } int amt_produce = 0; @@ -181,20 +185,30 @@ p25_frame_assembler_impl::general_work (int noutput_items, amt_produce = 32767; // buffer limit is 32768, see gnuradio/gnuradio-runtime/lib/../include/gnuradio/buffer.h:186 } - long src_id = p1fdma.get_curr_src_id(); - long grp_id = p1fdma.get_curr_grp_id(); + // If a SRC wasn't received on the voice channel since the last check, it will be -1 - if (src_id > 0) { - add_item_tag(0, nitems_written(0), d_tag_key, pmt::from_long(src_id), d_tag_src); + if (fdma_src_id > 0) { + add_item_tag(0, nitems_written(0), pmt::intern("src_id"), pmt::from_long(fdma_src_id), d_tag_src); + } + + if (tdma_src_id > 0) { + add_item_tag(0, nitems_written(0), pmt::intern("src_id"), pmt::from_long(tdma_src_id), d_tag_src); + } + + if ((tdma_src_id > 0) && (fdma_src_id > 0)) { + BOOST_LOG_TRIVIAL(info) << " Both TDMA and FDMA SRC IDs are set. TDMA: " << tdma_src_id << " FDMA: " << fdma_src_id; + } + + if (fdma_grp_id > 0) { + add_item_tag(0, nitems_written(0), pmt::intern("grp_id"), pmt::from_long(fdma_grp_id), d_tag_src); } - if (p2_ptt_src_id > 0) { - add_item_tag(0, nitems_written(0), pmt::intern("ptt_src_id"), pmt::from_long(p2_ptt_src_id), d_tag_src); - //BOOST_LOG_TRIVIAL(info) << "PTT Src: " << p2_ptt_src_id << " amt_produced: " << amt_produce << std::endl; + if (tdma_grp_id > 0) { + add_item_tag(0, nitems_written(0), pmt::intern("grp_id"), pmt::from_long(tdma_grp_id), d_tag_src); } - if (grp_id > 0) { - add_item_tag(0, nitems_written(0), pmt::intern("grp_id"), pmt::from_long(grp_id), d_tag_src); + if ((tdma_grp_id > 0) && (fdma_grp_id > 0)) { + BOOST_LOG_TRIVIAL(info) << " Both TDMA and FDMA GRP IDs are set. TDMA: " << tdma_grp_id << " FDMA: " << fdma_grp_id; } for (int i = 0; i < amt_produce; i++) { diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index d26519dfd..616e12a51 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -332,9 +332,8 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ } std::vector tags; - pmt::pmt_t src_id_key(pmt::intern("src_id")); // This is the src id from Phase 1 and DMR - pmt::pmt_t grp_id_key(pmt::intern("grp_id")); // This is the src id from Phase 1 and DMR - pmt::pmt_t ptt_src_id_key(pmt::intern("ptt_src_id")); // This is the src id from Phase 2 + pmt::pmt_t src_id_key(pmt::intern("src_id")); // This is the src id from Phase 1, Phase 2 and DMR + pmt::pmt_t grp_id_key(pmt::intern("grp_id")); // This is the src id from Phase 1, Phase 2 and DMR pmt::pmt_t terminate_key(pmt::intern("terminate")); pmt::pmt_t spike_count_key(pmt::intern("spike_count")); pmt::pmt_t error_count_key(pmt::intern("error_count")); @@ -404,16 +403,6 @@ int transmission_sink::work(int noutput_items, gr_vector_const_void_star &input_ // BOOST_LOG_TRIVIAL(info) << "TERMINATOR!!"; } - if (pmt::eq(ptt_src_id_key, tags[i].key)) { - long src_id = pmt::to_long(tags[i].value); - if (src_id != curr_src_id) { - d_termination_flag = true; - next_src_id = src_id; - pos = d_sample_count + (tags[i].offset - nitems_read(0)); - - //BOOST_LOG_TRIVIAL(info) << "[" << d_current_call_short_name << "]\t\033[0;34m" << d_current_call_num << "C\033[0m\tTG: " << d_current_call_talkgroup_display << "\tFreq: " << format_freq(d_current_call_freq) << "\tPTT Termination - rec sample count " << d_sample_count << " pos: " << pos << " offset: " << tags[i].offset; - } - } // Only process Spike and Error Count tags if the sink is currently recording if (state == RECORDING) { if (pmt::eq(spike_count_key, tags[i].key)) { From e76d0bc6ddd36f31dfab26ed9b4fe556c6e8a9d3 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Wed, 31 May 2023 21:27:14 -0400 Subject: [PATCH 13/22] Update p25_frame_assembler_impl.cc --- lib/op25_repeater/lib/p25_frame_assembler_impl.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index 40c50bb58..35e2d848d 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -125,6 +125,12 @@ static const int MAX_IN = 1; // maximum number of input streams void p25_frame_assembler_impl::clear() { + // clear out the SRC and GRP IDs + long clear; + clear = p1fdma.get_curr_src_id(); + clear = p1fdma.get_curr_grp_id(); + clear = p2tdma.get_ptt_src_id(); + clear = p2tdma.get_ptt_grp_id(); p1fdma.clear(); } From ac54d36783b7d8d24f2e2ecf9b8c76ffc133cbf0 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 1 Jun 2023 07:12:44 -0400 Subject: [PATCH 14/22] error messages --- .../lib/p25_frame_assembler_impl.cc | 27 ++++++++++--------- lib/op25_repeater/lib/p25p2_tdma.cc | 10 ++++++- .../recorders/p25_recorder_decode.cc | 1 + 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index 35e2d848d..80baff977 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -156,9 +156,6 @@ p25_frame_assembler_impl::general_work (int noutput_items, terminate_call = true; p2tdma.reset_call_terminated(); } - - tdma_src_id = p2tdma.get_ptt_src_id(); - tdma_grp_id = p2tdma.get_ptt_grp_id(); if (rc > -1) { p25p2_queue_msg(rc); @@ -171,9 +168,6 @@ p25_frame_assembler_impl::general_work (int noutput_items, terminate_call = true; p1fdma.reset_call_terminated(); } - - fdma_src_id = p1fdma.get_curr_src_id(); - fdma_grp_id = p1fdma.get_curr_grp_id(); } int amt_produce = 0; @@ -185,12 +179,12 @@ p25_frame_assembler_impl::general_work (int noutput_items, //BOOST_LOG_TRIVIAL(trace) << "P25 Frame Assembler - output_queue: " << output_queue.size() << " noutput_items: " << noutput_items << " ninput_items: " << ninput_items[0]; - if (amt_produce > 0) { - if (amt_produce >= 32768) { - BOOST_LOG_TRIVIAL(error) << "P25 Frame Assembler - output_queue size: " << output_queue.size() << " max size: " << output_queue.max_size() << " limiting amt_produce to 32767 "; - - amt_produce = 32767; // buffer limit is 32768, see gnuradio/gnuradio-runtime/lib/../include/gnuradio/buffer.h:186 - } + tdma_src_id = p2tdma.get_ptt_src_id(); + tdma_grp_id = p2tdma.get_ptt_grp_id(); + fdma_src_id = p1fdma.get_curr_src_id(); + fdma_grp_id = p1fdma.get_curr_grp_id(); + + BOOST_LOG_TRIVIAL(info) << "TDMA grp id: " << tdma_grp_id; // If a SRC wasn't received on the voice channel since the last check, it will be -1 if (fdma_src_id > 0) { @@ -217,6 +211,15 @@ p25_frame_assembler_impl::general_work (int noutput_items, BOOST_LOG_TRIVIAL(info) << " Both TDMA and FDMA GRP IDs are set. TDMA: " << tdma_grp_id << " FDMA: " << fdma_grp_id; } + + + if (amt_produce > 0) { + if (amt_produce >= 32768) { + BOOST_LOG_TRIVIAL(error) << "P25 Frame Assembler - output_queue size: " << output_queue.size() << " max size: " << output_queue.max_size() << " limiting amt_produce to 32767 "; + + amt_produce = 32767; // buffer limit is 32768, see gnuradio/gnuradio-runtime/lib/../include/gnuradio/buffer.h:186 + } + for (int i = 0; i < amt_produce; i++) { out[i] = output_queue[i]; } diff --git a/lib/op25_repeater/lib/p25p2_tdma.cc b/lib/op25_repeater/lib/p25p2_tdma.cc index 972ad4944..a78c25a18 100644 --- a/lib/op25_repeater/lib/p25p2_tdma.cc +++ b/lib/op25_repeater/lib/p25p2_tdma.cc @@ -128,6 +128,7 @@ bool p25p2_tdma::rx_sym(uint8_t sym) terminate_call = false; src_id = -1; grp_id = -1; + fprintf(stderr, "Setting GRP ID to -1\n"); return p2framer.rx_sym(sym); } @@ -160,7 +161,8 @@ long p25p2_tdma::get_ptt_src_id() { long p25p2_tdma::get_ptt_grp_id() { long addr = grp_id; grp_id = -1; - return grp_id; + fprintf(stderr, "Getting GRP ID %ld and setting it back to -1\n", addr); + return addr; } p25p2_tdma::~p25p2_tdma() // destructor @@ -261,6 +263,8 @@ void p25p2_tdma::handle_mac_ptt(const uint8_t byte_buf[], const unsigned int len src_id = srcaddr; grp_id = grpaddr; + + fprintf(stderr, "MAC PTT src_id=%u, grp_id=%u\n", src_id, grp_id); std::string s = "{\"srcaddr\" : " + std::to_string(srcaddr) + ", \"grpaddr\": " + std::to_string(grpaddr) + "}"; send_msg(s, -3); reset_vb(); @@ -280,6 +284,10 @@ void p25p2_tdma::handle_mac_end_ptt(const uint8_t byte_buf[], const unsigned int uint32_t srcaddr = (byte_buf[13] << 16) + (byte_buf[14] << 8) + byte_buf[15]; uint16_t grpaddr = (byte_buf[16] << 8) + byte_buf[17]; + src_id = srcaddr; + grp_id = grpaddr; + + fprintf(stderr, "MAC END PTT src_id=%u, grp_id=%u\n", src_id, grp_id); if (d_debug >= 10) fprintf(stderr, "%s MAC_END_PTT: colorcd=0x%03x, srcaddr=%u, grpaddr=%u, rs_errs=%d\n", logts.get(d_msgq_id), colorcd, srcaddr, grpaddr, rs_errs); diff --git a/trunk-recorder/recorders/p25_recorder_decode.cc b/trunk-recorder/recorders/p25_recorder_decode.cc index 8e685d3f5..1b99887ff 100644 --- a/trunk-recorder/recorders/p25_recorder_decode.cc +++ b/trunk-recorder/recorders/p25_recorder_decode.cc @@ -132,6 +132,7 @@ void p25_recorder_decode::reset() { reset_block(slicer); reset_block(levels); reset_block(wav_sink); + op25_frame_assembler->clear(); } gr::op25_repeater::p25_frame_assembler::sptr p25_recorder_decode::get_transmission_sink() { From 8e06f8ebd2653a7e9cf41039e406e2e8d1b92d17 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 1 Jun 2023 07:20:46 -0400 Subject: [PATCH 15/22] Update p25p2_tdma.cc --- lib/op25_repeater/lib/p25p2_tdma.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/op25_repeater/lib/p25p2_tdma.cc b/lib/op25_repeater/lib/p25p2_tdma.cc index a78c25a18..16b4e67e8 100644 --- a/lib/op25_repeater/lib/p25p2_tdma.cc +++ b/lib/op25_repeater/lib/p25p2_tdma.cc @@ -125,10 +125,6 @@ p25p2_tdma::p25p2_tdma(const op25_audio& udp, log_ts& logger, int slotid, int de bool p25p2_tdma::rx_sym(uint8_t sym) { symbols_received++; - terminate_call = false; - src_id = -1; - grp_id = -1; - fprintf(stderr, "Setting GRP ID to -1\n"); return p2framer.rx_sym(sym); } From 84f74f1faaadfef33bf59da9a8b3c5e06e9be39f Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 1 Jun 2023 07:34:13 -0400 Subject: [PATCH 16/22] streamline grp src ID --- lib/op25_repeater/lib/p25_frame_assembler_impl.cc | 2 -- lib/op25_repeater/lib/p25_frame_assembler_impl.h | 1 + lib/op25_repeater/lib/p25p2_tdma.cc | 3 --- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index 80baff977..19fbf23fb 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -184,8 +184,6 @@ p25_frame_assembler_impl::general_work (int noutput_items, fdma_src_id = p1fdma.get_curr_src_id(); fdma_grp_id = p1fdma.get_curr_grp_id(); - BOOST_LOG_TRIVIAL(info) << "TDMA grp id: " << tdma_grp_id; - // If a SRC wasn't received on the voice channel since the last check, it will be -1 if (fdma_src_id > 0) { add_item_tag(0, nitems_written(0), pmt::intern("src_id"), pmt::from_long(fdma_src_id), d_tag_src); diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.h b/lib/op25_repeater/lib/p25_frame_assembler_impl.h index d0914b78e..908b80c47 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.h +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.h @@ -62,6 +62,7 @@ namespace gr { pmt::pmt_t d_tag_src; // internal functions + void send_grp_src_id(); void set_xormask(const char*p) ; void set_nac(int nac) ; void set_slotid(int slotid) ; diff --git a/lib/op25_repeater/lib/p25p2_tdma.cc b/lib/op25_repeater/lib/p25p2_tdma.cc index 16b4e67e8..0ffa8de99 100644 --- a/lib/op25_repeater/lib/p25p2_tdma.cc +++ b/lib/op25_repeater/lib/p25p2_tdma.cc @@ -157,7 +157,6 @@ long p25p2_tdma::get_ptt_src_id() { long p25p2_tdma::get_ptt_grp_id() { long addr = grp_id; grp_id = -1; - fprintf(stderr, "Getting GRP ID %ld and setting it back to -1\n", addr); return addr; } @@ -260,7 +259,6 @@ void p25p2_tdma::handle_mac_ptt(const uint8_t byte_buf[], const unsigned int len src_id = srcaddr; grp_id = grpaddr; - fprintf(stderr, "MAC PTT src_id=%u, grp_id=%u\n", src_id, grp_id); std::string s = "{\"srcaddr\" : " + std::to_string(srcaddr) + ", \"grpaddr\": " + std::to_string(grpaddr) + "}"; send_msg(s, -3); reset_vb(); @@ -283,7 +281,6 @@ void p25p2_tdma::handle_mac_end_ptt(const uint8_t byte_buf[], const unsigned int src_id = srcaddr; grp_id = grpaddr; - fprintf(stderr, "MAC END PTT src_id=%u, grp_id=%u\n", src_id, grp_id); if (d_debug >= 10) fprintf(stderr, "%s MAC_END_PTT: colorcd=0x%03x, srcaddr=%u, grpaddr=%u, rs_errs=%d\n", logts.get(d_msgq_id), colorcd, srcaddr, grpaddr, rs_errs); From 6595aa6e725e7ee4886daec6a3e66af0314858b5 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 1 Jun 2023 10:08:24 -0400 Subject: [PATCH 17/22] add message back --- .../lib/p25_frame_assembler_impl.cc | 78 +++++++++-------- trunk-recorder/source.cc | 86 +++++++++---------- 2 files changed, 84 insertions(+), 80 deletions(-) diff --git a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc index 19fbf23fb..2024b97c8 100644 --- a/lib/op25_repeater/lib/p25_frame_assembler_impl.cc +++ b/lib/op25_repeater/lib/p25_frame_assembler_impl.cc @@ -134,6 +134,44 @@ static const int MAX_IN = 1; // maximum number of input streams p1fdma.clear(); } +void p25_frame_assembler_impl::send_grp_src_id() { + long tdma_src_id = -1; + long tdma_grp_id = -1; + long fdma_src_id = -1; + long fdma_grp_id = -1; + + tdma_src_id = p2tdma.get_ptt_src_id(); + tdma_grp_id = p2tdma.get_ptt_grp_id(); + fdma_src_id = p1fdma.get_curr_src_id(); + fdma_grp_id = p1fdma.get_curr_grp_id(); + + // If a SRC wasn't received on the voice channel since the last check, it will be -1 + if (fdma_src_id > 0) { + add_item_tag(0, nitems_written(0), pmt::intern("src_id"), pmt::from_long(fdma_src_id), d_tag_src); + } + + if (tdma_src_id > 0) { + add_item_tag(0, nitems_written(0), pmt::intern("src_id"), pmt::from_long(tdma_src_id), d_tag_src); + } + + if ((tdma_src_id > 0) && (fdma_src_id > 0)) { + BOOST_LOG_TRIVIAL(info) << " Both TDMA and FDMA SRC IDs are set. TDMA: " << tdma_src_id << " FDMA: " << fdma_src_id; + } + + if (fdma_grp_id > 0) { + add_item_tag(0, nitems_written(0), pmt::intern("grp_id"), pmt::from_long(fdma_grp_id), d_tag_src); + } + + if (tdma_grp_id > 0) { + add_item_tag(0, nitems_written(0), pmt::intern("grp_id"), pmt::from_long(tdma_grp_id), d_tag_src); + } + + if ((tdma_grp_id > 0) && (fdma_grp_id > 0)) { + BOOST_LOG_TRIVIAL(info) << " Both TDMA and FDMA GRP IDs are set. TDMA: " << tdma_grp_id << " FDMA: " << fdma_grp_id; + } +} + + int p25_frame_assembler_impl::general_work (int noutput_items, gr_vector_int &ninput_items, @@ -143,10 +181,7 @@ p25_frame_assembler_impl::general_work (int noutput_items, const uint8_t *in = (const uint8_t *) input_items[0]; bool terminate_call = false; - long tdma_src_id = -1; - long tdma_grp_id = -1; - long fdma_src_id = -1; - long fdma_grp_id = -1; + p1fdma.rx_sym(in, ninput_items[0]); if(d_do_phase2_tdma) { for (int i = 0; i < ninput_items[0]; i++) { @@ -179,38 +214,6 @@ p25_frame_assembler_impl::general_work (int noutput_items, //BOOST_LOG_TRIVIAL(trace) << "P25 Frame Assembler - output_queue: " << output_queue.size() << " noutput_items: " << noutput_items << " ninput_items: " << ninput_items[0]; - tdma_src_id = p2tdma.get_ptt_src_id(); - tdma_grp_id = p2tdma.get_ptt_grp_id(); - fdma_src_id = p1fdma.get_curr_src_id(); - fdma_grp_id = p1fdma.get_curr_grp_id(); - - // If a SRC wasn't received on the voice channel since the last check, it will be -1 - if (fdma_src_id > 0) { - add_item_tag(0, nitems_written(0), pmt::intern("src_id"), pmt::from_long(fdma_src_id), d_tag_src); - } - - if (tdma_src_id > 0) { - add_item_tag(0, nitems_written(0), pmt::intern("src_id"), pmt::from_long(tdma_src_id), d_tag_src); - } - - if ((tdma_src_id > 0) && (fdma_src_id > 0)) { - BOOST_LOG_TRIVIAL(info) << " Both TDMA and FDMA SRC IDs are set. TDMA: " << tdma_src_id << " FDMA: " << fdma_src_id; - } - - if (fdma_grp_id > 0) { - add_item_tag(0, nitems_written(0), pmt::intern("grp_id"), pmt::from_long(fdma_grp_id), d_tag_src); - } - - if (tdma_grp_id > 0) { - add_item_tag(0, nitems_written(0), pmt::intern("grp_id"), pmt::from_long(tdma_grp_id), d_tag_src); - } - - if ((tdma_grp_id > 0) && (fdma_grp_id > 0)) { - BOOST_LOG_TRIVIAL(info) << " Both TDMA and FDMA GRP IDs are set. TDMA: " << tdma_grp_id << " FDMA: " << fdma_grp_id; - } - - - if (amt_produce > 0) { if (amt_produce >= 32768) { BOOST_LOG_TRIVIAL(error) << "P25 Frame Assembler - output_queue size: " << output_queue.size() << " max size: " << output_queue.max_size() << " limiting amt_produce to 32767 "; @@ -223,6 +226,7 @@ p25_frame_assembler_impl::general_work (int noutput_items, } output_queue.erase(output_queue.begin(), output_queue.begin() + amt_produce); + send_grp_src_id(); BOOST_LOG_TRIVIAL(trace) << "setting silence_frame_count " << silence_frame_count << " to d_silence_frames: " << d_silence_frames << std::endl; silence_frame_count = d_silence_frames; @@ -239,6 +243,8 @@ p25_frame_assembler_impl::general_work (int noutput_items, p1fdma.reset_rx_status(); } + send_grp_src_id(); + std::fill(out, out + 1, 0); amt_produce = 1; } diff --git a/trunk-recorder/source.cc b/trunk-recorder/source.cc index ecf6a03ed..f7015539f 100644 --- a/trunk-recorder/source.cc +++ b/trunk-recorder/source.cc @@ -199,6 +199,48 @@ void Source::create_digital_recorders(gr::top_block_sptr tb, int r) { } } +Recorder *Source::get_digital_recorder(Talkgroup *talkgroup, int priority, Call *call) { + int num_available_recorders = get_num_available_digital_recorders(); + + if(talkgroup && (priority == -1)){ + call->set_state(MONITORING); + call->set_monitoring_state(IGNORED_TG); + BOOST_LOG_TRIVIAL(info) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\tNot recording talkgroup. Priority is -1."; + return NULL; + } + + if (talkgroup && priority > num_available_recorders) { // a high priority is bad. You need at least the number of availalbe recorders to your priority + call->set_state(MONITORING); + call->set_monitoring_state(NO_RECORDER); + BOOST_LOG_TRIVIAL(error) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\tNot recording talkgroup. Priority is " << priority << " but only " << num_available_recorders << " recorders are available."; + return NULL; + } + + return get_digital_recorder(call); +} + +Recorder *Source::get_digital_recorder(Call *call) { + for (std::vector::iterator it = digital_recorders.begin(); + it != digital_recorders.end(); it++) { + p25_recorder_sptr rx = *it; + + if (rx->get_state() == AVAILABLE) { + return (Recorder *)rx.get(); + + break; + } + } + + BOOST_LOG_TRIVIAL(error) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t[ " << device << " ] No Digital Recorders Available."; + + for (std::vector::iterator it = digital_recorders.begin(); + it != digital_recorders.end(); it++) { + p25_recorder_sptr rx = *it; + BOOST_LOG_TRIVIAL(info) << "[ " << rx->get_num() << " ] State: " << format_state(rx->get_state()) << " Freq: " << rx->get_freq(); + } + return NULL; +} + p25_recorder_sptr Source::create_digital_conventional_recorder(gr::top_block_sptr tb) { // Not adding it to the vector of digital_recorders. We don't want it to be available for trunk recording. // Conventional recorders are tracked seperately in digital_conv_recorders @@ -364,50 +406,6 @@ int Source::get_num_available_analog_recorders() { return num_available_recorders; } -Recorder *Source::get_digital_recorder(Talkgroup *talkgroup, int priority, Call *call) { - int num_available_recorders = get_num_available_digital_recorders(); - - if(talkgroup && (priority == -1)){ - call->set_state(MONITORING); - call->set_monitoring_state(IGNORED_TG); - BOOST_LOG_TRIVIAL(info) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\tNot recording talkgroup. Priority is -1."; - return NULL; - } - - if (talkgroup && priority > num_available_recorders) { // a high priority is bad. You need at least the number of availalbe recorders to your priority - call->set_state(MONITORING); - call->set_monitoring_state(NO_RECORDER); - BOOST_LOG_TRIVIAL(error) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\tNot recording talkgroup. Priority is " << priority << " but only " << num_available_recorders << " recorders are available."; - return NULL; - } - - return get_digital_recorder(call); -} - -Recorder *Source::get_digital_recorder(Call *call) { - for (std::vector::iterator it = digital_recorders.begin(); - it != digital_recorders.end(); it++) { - p25_recorder_sptr rx = *it; - - if (rx->get_state() == AVAILABLE) { - return (Recorder *)rx.get(); - - break; - } - } - - return NULL; - - BOOST_LOG_TRIVIAL(error) << "[" << call->get_system()->get_short_name() << "]\t\033[0;34m" << call->get_call_num() << "C\033[0m\tTG: " << call->get_talkgroup_display() << "\tFreq: " << format_freq(call->get_freq()) << "\t[ " << device << " ] No Digital Recorders Available."; - - for (std::vector::iterator it = digital_recorders.begin(); - it != digital_recorders.end(); it++) { - p25_recorder_sptr rx = *it; - BOOST_LOG_TRIVIAL(info) << "[ " << rx->get_num() << " ] State: " << format_state(rx->get_state()) << " Freq: " << rx->get_freq(); - } - return NULL; -} - gr::basic_block_sptr Source::get_src_block() { return source_block; } From f42e85e7226a409628f4afbd11d57b266fb22d3a Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 1 Jun 2023 10:41:36 -0400 Subject: [PATCH 18/22] Update p25p2_tdma.cc --- lib/op25_repeater/lib/p25p2_tdma.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/op25_repeater/lib/p25p2_tdma.cc b/lib/op25_repeater/lib/p25p2_tdma.cc index 0ffa8de99..2dbfc05c2 100644 --- a/lib/op25_repeater/lib/p25p2_tdma.cc +++ b/lib/op25_repeater/lib/p25p2_tdma.cc @@ -151,7 +151,9 @@ bool p25p2_tdma::get_call_terminated() { } long p25p2_tdma::get_ptt_src_id() { - return src_id; + long id = src_id; + src_id = -1; + return id; } long p25p2_tdma::get_ptt_grp_id() { From 5dcec7243c47d34ce9a6e67736887e9e4427aae1 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 1 Jun 2023 10:55:37 -0400 Subject: [PATCH 19/22] SRC ID from MAC_END_PTT appears to be broken --- lib/op25_repeater/lib/p25p2_tdma.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/op25_repeater/lib/p25p2_tdma.cc b/lib/op25_repeater/lib/p25p2_tdma.cc index 2dbfc05c2..4c4943ead 100644 --- a/lib/op25_repeater/lib/p25p2_tdma.cc +++ b/lib/op25_repeater/lib/p25p2_tdma.cc @@ -280,7 +280,7 @@ void p25p2_tdma::handle_mac_end_ptt(const uint8_t byte_buf[], const unsigned int uint32_t srcaddr = (byte_buf[13] << 16) + (byte_buf[14] << 8) + byte_buf[15]; uint16_t grpaddr = (byte_buf[16] << 8) + byte_buf[17]; - src_id = srcaddr; + //src_id = srcaddr; // the decode for Source Address is not correct grp_id = grpaddr; if (d_debug >= 10) From 46d41588aae378248570d2169001445d3d282c9f Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 1 Jun 2023 14:02:40 -0400 Subject: [PATCH 20/22] Trying some MUTEX in the Gardner to get rid of the SegFault --- lib/op25_repeater/lib/gardner_cc_impl.cc | 3 +++ lib/op25_repeater/lib/gardner_cc_impl.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/lib/op25_repeater/lib/gardner_cc_impl.cc b/lib/op25_repeater/lib/gardner_cc_impl.cc index 543b4daa8..c46cffeab 100644 --- a/lib/op25_repeater/lib/gardner_cc_impl.cc +++ b/lib/op25_repeater/lib/gardner_cc_impl.cc @@ -100,6 +100,7 @@ gardner_cc_impl::~gardner_cc_impl() void gardner_cc_impl::reset() { + gr::thread::scoped_lock lock(d_mutex); d_phase = 0; d_update_request = 0; d_last_sample = 0; @@ -109,6 +110,7 @@ gardner_cc_impl::reset() void gardner_cc_impl::set_omega (float omega) { + gr::thread::scoped_lock lock(d_mutex); assert (omega >= 2.0); d_omega = omega; d_min_omega = omega*(1.0 - d_omega_rel); @@ -136,6 +138,7 @@ gardner_cc_impl::general_work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { + gr::thread::scoped_lock lock(d_mutex); const gr_complex *in = (const gr_complex *) input_items[0]; gr_complex *out = (gr_complex *) output_items[0]; diff --git a/lib/op25_repeater/lib/gardner_cc_impl.h b/lib/op25_repeater/lib/gardner_cc_impl.h index beb8f316d..03ab517d2 100644 --- a/lib/op25_repeater/lib/gardner_cc_impl.h +++ b/lib/op25_repeater/lib/gardner_cc_impl.h @@ -31,6 +31,7 @@ #include #include +#include // class gr::filter::mmse_fir_interpolator_cc; namespace gr { @@ -101,6 +102,7 @@ class gardner_cc_impl : public gardner_cc float d_gain_mu; float d_lock_threshold; id_avg d_lock_accum; + boost::mutex d_mutex; gr_complex d_last_sample; gr::filter::mmse_fir_interpolator_cc *d_interp; From a56b80f7186e03dc62ef387061d30e110cbfb69f Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 1 Jun 2023 19:52:24 -0400 Subject: [PATCH 21/22] Update p25_parser.cc --- trunk-recorder/systems/p25_parser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk-recorder/systems/p25_parser.cc b/trunk-recorder/systems/p25_parser.cc index 0c8522597..55dfd2c43 100644 --- a/trunk-recorder/systems/p25_parser.cc +++ b/trunk-recorder/systems/p25_parser.cc @@ -343,7 +343,7 @@ std::vector P25Parser::decode_tsbk(boost::dynamic_bitset<> &tsbk, unsigned long sa = bitset_shift_mask(tsbk, 16, 0xffffff); unsigned long f = channel_id_to_frequency(ch, sys_num); - message.message_type = UPDATE; + message.message_type = GRANT; message.freq = f; message.talkgroup = sg; message.source = sa; From 31b491a99a8f668c5ab317f905988a6429504b03 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Thu, 1 Jun 2023 21:43:23 -0400 Subject: [PATCH 22/22] Bigger buffers for smoother writing Let's see if this helps network drive writes --- trunk-recorder/gr_blocks/transmission_sink.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trunk-recorder/gr_blocks/transmission_sink.cc b/trunk-recorder/gr_blocks/transmission_sink.cc index 616e12a51..a3855f2e1 100644 --- a/trunk-recorder/gr_blocks/transmission_sink.cc +++ b/trunk-recorder/gr_blocks/transmission_sink.cc @@ -181,7 +181,9 @@ bool transmission_sink::open_internal(const char *filename) { BOOST_LOG_TRIVIAL(error) << "wav open failed" << std::endl; return false; } - + if(std::setvbuf(d_fp, nullptr, _IOFBF, 1000000) != 0) { + BOOST_LOG_TRIVIAL(error) << "setvbuf failed"; // POSIX version sets errno + } d_sample_count = 0; if (!wavheader_write(d_fp, d_sample_rate, d_nchans, d_bytes_per_sample)) {