Skip to content

Commit

Permalink
Merge pull request boatbod#180 from roysjosh/call_end
Browse files Browse the repository at this point in the history
Properly init & clear "missing frame tracking" variable across calls
  • Loading branch information
boatbod authored May 9, 2023
2 parents ee9e6b0 + f847645 commit c2f7d43
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 52 deletions.
10 changes: 5 additions & 5 deletions op25/gr-op25_repeater/apps/multi_rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,8 @@ def set_rate(self, rate):
def set_nac(self, nac):
self.decoder.set_nac(nac)
def ess_reset(self):
self.decoder.ess_reset()
def call_end(self):
self.decoder.call_end()
def set_slot(self, slot):
self.chan_idle = True if (slot == 4) else False
Expand Down Expand Up @@ -698,7 +698,7 @@ def configure_trunking(self, config):
self.trunking = None
if self.trunking is not None:
self.trunk_rx = self.trunking.rx_ctl(frequency_set = self.change_freq, nac_set = self.set_nac, slot_set = self.set_slot, nbfm_ctrl = self.nbfm_control, reset_ess = self.ess_reset, debug = self.verbosity, chans = config['chans'])
self.trunk_rx = self.trunking.rx_ctl(frequency_set = self.change_freq, nac_set = self.set_nac, slot_set = self.set_slot, nbfm_ctrl = self.nbfm_control, on_call_end = self.call_end, debug = self.verbosity, chans = config['chans'])
self.du_watcher = du_queue_watcher(self.rx_q, self.trunk_rx.process_qmsg)
sys.stderr.write("Enabled trunking module: %s\n" % config['module'])
Expand Down Expand Up @@ -852,9 +852,9 @@ def set_slot(self, params):
if 'slot' in params:
chan.set_slot(params['slot'])
def ess_reset(self, msgq_id):
def call_end(self, msgq_id):
if (msgq_id >= 0 and msgq_id < len(self.channels)):
self.channels[msgq_id].ess_reset()
self.channels[msgq_id].call_end()
def nbfm_control(self, msgq_id, action):
if (msgq_id >= 0 and msgq_id < len(self.channels)) and self.channels[msgq_id].nbfm is not None:
Expand Down
4 changes: 2 additions & 2 deletions op25/gr-op25_repeater/apps/p25_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def crypt_key(self, keyid, algid, keyval):
for decoder in self.p25_decoders:
decoder.crypt_key(keyid, algid, keyval)

def ess_reset(self):
def call_end(self):
for decoder in self.p25_decoders:
decoder.ess_reset()
decoder.call_end()

def crypt_reset(self):
for decoder in self.p25_decoders:
Expand Down
12 changes: 6 additions & 6 deletions op25/gr-op25_repeater/apps/tk_p25.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ def get_tgid(tgid):
#################
# Main trunking class
class rx_ctl(object):
def __init__(self, debug=0, frequency_set=None, nac_set=None, slot_set=None, nbfm_ctrl=None, reset_ess=None, chans={}):
def __init__(self, debug=0, frequency_set=None, nac_set=None, slot_set=None, nbfm_ctrl=None, on_call_end=None, chans={}):
self.frequency_set = frequency_set
self.nac_set = nac_set
self.slot_set = slot_set
self.nbfm_ctrl = nbfm_ctrl
self.reset_ess = reset_ess
self.on_call_end = on_call_end
self.debug = debug
self.receivers = {}
self.systems = {}
Expand Down Expand Up @@ -133,7 +133,7 @@ def add_receiver(self, msgq_id, config, meta_q = None, freq = 0):
frequency_set = self.frequency_set,
nac_set = self.nac_set,
slot_set = self.slot_set,
reset_ess = self.reset_ess,
on_call_end = self.on_call_end,
system = rx_sys,
config = config,
meta_q = meta_q,
Expand Down Expand Up @@ -1509,14 +1509,14 @@ def dump(self):
#################
# P25 receiver class
class p25_receiver(object):
def __init__(self, debug, msgq_id, frequency_set, nac_set, slot_set, reset_ess, system, config, meta_q = None, freq = 0):
def __init__(self, debug, msgq_id, frequency_set, nac_set, slot_set, on_call_end, system, config, meta_q = None, freq = 0):
self.debug = debug
self.msgq_id = msgq_id
self.config = config
self.frequency_set = frequency_set
self.nac_set = nac_set
self.slot_set = slot_set
self.reset_ess = reset_ess
self.on_call_end = on_call_end
self.system = system
self.meta_q = meta_q
self.meta_stream = from_dict(self.config, 'meta_stream_name', "")
Expand Down Expand Up @@ -1923,7 +1923,7 @@ def expire_talkgroup(self, tgid=None, update_meta = True, reason="unk", auto_hol
self.hold_until = time.time()
self.current_tgid = None
self.current_slot = None
self.reset_ess(self.msgq_id) # Drop any persistent ESS data held in the receiver
self.on_call_end(self.msgq_id) # Drop any persistent ESS data held in the receiver

if reason == "preempt": # Do not retune or update metadata if in middle of tuning to a different tgid
return
Expand Down
4 changes: 2 additions & 2 deletions op25/gr-op25_repeater/apps/tk_smartnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def meta_update(meta_q, tgid = None, tag = None):
#################
# Main trunking class
class rx_ctl(object):
def __init__(self, debug=0, frequency_set=None, nac_set=None, slot_set=None, nbfm_ctrl=None, reset_ess=None, chans={}):
def __init__(self, debug=0, frequency_set=None, nac_set=None, slot_set=None, nbfm_ctrl=None, on_call_end=None, chans={}):
self.frequency_set = frequency_set
self.nac_set = nac_set
self.slot_set = slot_set
self.nbfm_ctrl = nbfm_ctrl
self.reset_ess = reset_ess
self.on_call_end = on_call_end
self.debug = debug
self.receivers = {}
self.systems = {}
Expand Down
4 changes: 2 additions & 2 deletions op25/gr-op25_repeater/apps/tk_trbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,10 @@ def get_status(self):


class rx_ctl(object):
def __init__(self, debug=0, frequency_set=None, nac_set=None, slot_set=None, nbfm_ctrl=None, reset_ess=None, chans={}):
def __init__(self, debug=0, frequency_set=None, nac_set=None, slot_set=None, nbfm_ctrl=None, on_call_end=None, chans={}):
self.frequency_set = frequency_set
self.slot_set = slot_set
self.reset_ess = reset_ess
self.on_call_end = on_call_end
self.nac_set = nac_set
self.debug = debug
self.receivers = {}
Expand Down
2 changes: 1 addition & 1 deletion op25/gr-op25_repeater/apps/trunking.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ def get_int_dict(s):
return dict.fromkeys(d)

class rx_ctl (object):
def __init__(self, debug=0, frequency_set=None, conf_file=None, logfile_workers=None, meta_update=None, crypt_behavior=0, nac_set=None, slot_set=None, nbfm_ctrl=None, reset_ess=None, chans={}):
def __init__(self, debug=0, frequency_set=None, conf_file=None, logfile_workers=None, meta_update=None, crypt_behavior=0, nac_set=None, slot_set=None, nbfm_ctrl=None, on_call_end=None, chans={}):
class _states(object):
ACQ = 0
CC = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace gr {
virtual void set_slotkey(int key) {}
virtual void set_debug(int debug) {}
virtual void sync_reset(void) {}
virtual void ess_reset(void) {}
virtual void call_end(void) {}
virtual void crypt_reset(void) {}
virtual void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key) {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace gr {
virtual void set_slotkey(int key) {}
virtual void set_debug(int debug) {}
virtual void reset_timer() {}
virtual void ess_reset(void) {}
virtual void call_end(void) {}
virtual void crypt_reset(void) {}
virtual void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key) {}
};
Expand Down
4 changes: 2 additions & 2 deletions op25/gr-op25_repeater/lib/frame_assembler_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ namespace gr {
d_sync->sync_reset();
}

void frame_assembler_impl::ess_reset() {
void frame_assembler_impl::call_end() {
if (d_sync)
d_sync->ess_reset();
d_sync->call_end();
}

void frame_assembler_impl::crypt_reset() {
Expand Down
2 changes: 1 addition & 1 deletion op25/gr-op25_repeater/lib/frame_assembler_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace gr {
void set_slotkey(int key);
void set_debug(int debug);
void sync_reset();
void ess_reset();
void call_end();
void crypt_reset();
void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key);

Expand Down
6 changes: 3 additions & 3 deletions op25/gr-op25_repeater/lib/p25_frame_assembler_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ namespace gr {
p2tdma.set_debug(debug);
}

void p25_frame_assembler_impl::ess_reset() {
p1fdma.ess_reset();
p2tdma.ess_reset();
void p25_frame_assembler_impl::call_end() {
p1fdma.call_end();
p2tdma.call_end();
}

void p25_frame_assembler_impl::crypt_reset() {
Expand Down
2 changes: 1 addition & 1 deletion op25/gr-op25_repeater/lib/p25_frame_assembler_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace gr {
void set_slotkey(int key) ;
void set_debug(int debug) ;
void reset_timer() ;
void ess_reset();
void call_end();
void crypt_reset();
void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key);

Expand Down
2 changes: 1 addition & 1 deletion op25/gr-op25_repeater/lib/p25p1_fdma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ namespace gr {
qtimer.reset();
}

void p25p1_fdma::ess_reset() {
void p25p1_fdma::call_end() {
reset_ess();
}

Expand Down
2 changes: 1 addition & 1 deletion op25/gr-op25_repeater/lib/p25p1_fdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace gr {
void set_debug(int debug);
void set_nac(int nac);
void reset_timer();
void ess_reset();
void call_end();
void crypt_reset();
void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key);
void rx_sym (const uint8_t *syms, int nsyms);
Expand Down
31 changes: 17 additions & 14 deletions op25/gr-op25_repeater/lib/p25p2_tdma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ p25p2_tdma::p25p2_tdma(const op25_audio& udp, log_ts& logger, int slotid, int de
packets(0),
write_bufp(0),
d_slotid(slotid),
d_tdma_slot_first_4v(0),
d_tdma_slot_first_4v(-1),
mbe_err_cnt(0),
tone_frame(false),
d_msg_queue(queue),
Expand Down Expand Up @@ -135,8 +135,9 @@ void p25p2_tdma::set_slotid(int slotid)
d_slotid = slotid;
}

void p25p2_tdma::ess_reset() {
void p25p2_tdma::call_end() {
reset_ess();
d_tdma_slot_first_4v = -1;
}

void p25p2_tdma::crypt_reset() {
Expand Down Expand Up @@ -649,21 +650,23 @@ int p25p2_tdma::handle_packet(uint8_t dibits[], const uint64_t fs)
if (burst_type == 6)
d_tdma_slot_first_4v = (current_slot + 1) % 5;

// now let's see if the voice frame received is the one we expected to get.
// shift the range from [0, 4] to [first_4V, first_4V+4]
if (current_slot < (int) d_tdma_slot_first_4v)
current_slot += 5;
if (d_tdma_slot_first_4v >= 0) {
// now let's see if the voice frame received is the one we expected to get.
// shift the range from [0, 4] to [first_4V, first_4V+4]
if (current_slot < (int) d_tdma_slot_first_4v)
current_slot += 5;

// translate [first_4V, first_4V+1] to the burst_id we would expect to be in this slot
current_slot -= d_tdma_slot_first_4v;
// translate [first_4V, first_4V+1] to the burst_id we would expect to be in this slot
current_slot -= d_tdma_slot_first_4v;

if (current_slot != burst_id && current_slot > burst_id) {
int need_to_skip = current_slot - burst_id;
// XXX determine if the 2V frame was missed?
if (d_debug >= 10) {
fprintf(stderr, "%i voice frame(s) missing; expecting %uV_%u but got %uV_%u. ISCH rc=%d\n", need_to_skip, (burst_id == 4 ? 2 : 4), burst_id, (current_slot == 4 ? 2 : 4), current_slot, sync.last_rc());
if (current_slot != burst_id && current_slot > burst_id) {
int need_to_skip = current_slot - burst_id;
// XXX determine if the 2V frame was missed?
if (d_debug >= 10) {
fprintf(stderr, "%i voice frame(s) missing; expecting %uV_%u but got %uV_%u. ISCH rc=%d\n", need_to_skip, (burst_id == 4 ? 2 : 4), burst_id, (current_slot == 4 ? 2 : 4), current_slot, sync.last_rc());
}
burst_id = current_slot;
}
burst_id = current_slot;
}

handle_4V2V_ess(&xored_burst[84]);
Expand Down
4 changes: 2 additions & 2 deletions op25/gr-op25_repeater/lib/p25p2_tdma.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class p25p2_tdma
p25p2_tdma(const op25_audio& udp, log_ts& logger, int slotid, int debug, bool do_msgq, gr::msg_queue::sptr queue, std::deque<int16_t> &qptr, bool do_audio_output, int msgq_id = 0) ; // constructor
int handle_packet(uint8_t dibits[], const uint64_t fs) ;
void set_slotid(int slotid);
void ess_reset();
void call_end();
void crypt_reset();
void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key);
uint8_t* tdma_xormask;
Expand All @@ -64,7 +64,7 @@ class p25p2_tdma
int write_bufp;
char write_buf[512];
int d_slotid;
uint32_t d_tdma_slot_first_4v;
int d_tdma_slot_first_4v;
mbe_parms cur_mp;
mbe_parms prev_mp;
mbe_parms enh_mp;
Expand Down
2 changes: 1 addition & 1 deletion op25/gr-op25_repeater/lib/rx_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace gr{
public:
virtual void rx_sym(const uint8_t sym) = 0;
virtual void sync_reset(void) = 0;
virtual void ess_reset(void) = 0;
virtual void call_end(void) = 0;
virtual void crypt_reset(void) = 0;
virtual void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key) = 0;
virtual void reset_timer(void) = 0;
Expand Down
2 changes: 1 addition & 1 deletion op25/gr-op25_repeater/lib/rx_smartnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace gr{
void rx_sym(const uint8_t sym);
void sync_reset(void);
void reset_timer(void);
void ess_reset(void) { };
void call_end(void) { };
void crypt_reset(void) { };
void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key) { };
void set_nac(int nac) { };
Expand Down
2 changes: 1 addition & 1 deletion op25/gr-op25_repeater/lib/rx_subchannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace gr{
void rx_sym(const uint8_t sym);
void sync_reset(void);
void reset_timer(void) { };
void ess_reset(void) { };
void call_end(void) { };
void crypt_reset(void) { };
void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key) { };
void set_nac(int nac) { };
Expand Down
6 changes: 3 additions & 3 deletions op25/gr-op25_repeater/lib/rx_sync.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ void rx_sync::sync_reset(void) {
reset_timer();
}

void rx_sync::ess_reset(void) {
p25fdma.ess_reset();
p25tdma.ess_reset();
void rx_sync::call_end(void) {
p25fdma.call_end();
p25tdma.call_end();
}

void rx_sync::crypt_reset(void) {
Expand Down
2 changes: 1 addition & 1 deletion op25/gr-op25_repeater/lib/rx_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class rx_sync : public rx_base {
void rx_sym(const uint8_t sym);
void sync_reset(void);
void reset_timer(void);
void ess_reset(void);
void call_end(void);
void crypt_reset(void);
void crypt_key(uint16_t keyid, uint8_t algid, const std::vector<uint8_t> &key);
void set_slot_mask(int mask);
Expand Down

0 comments on commit c2f7d43

Please sign in to comment.