def checkTimeout(): #global args, active, scanner now = datetime.today() active.duration = (now - active.startTime).total_seconds() if active.duration > args.timeout: if args.debug >= D_INFO: print('Timeout') if active.frqTGID in timeouts: thisTO = timeouts[active.frqTGID] if args.debug >= D_FULL: print('Found previous timeout') else: thisTO = Timeout(active.frqTGID, now) timeouts[active.frqTGID] = thisTO if args.debug >= D_FULL: print('New Timeout') # decay the timeouts decay = int((now - thisTO.lastTimeout).total_seconds() / args.decay) thisTO.timeoutCount = thisTO.timeoutCount - decay if thisTO.timeoutCount - decay > 0 else 0 thisTO.timeoutCount += 1 thisTO.lastTimeout = now if args.debug >= D_DEBUG: print('Decay={}, count={}'.format(decay, thisTO.timeoutCount)) if thisTO.timeoutCount >= args.lockout: active.action = 'Lockout' scanner.cmd('KEY,L,P') # lockout else: active.action = 'Skip' scanner.cmd('KEY,>,P') # skip if args.debug >= D_INFO: print(active.action)
def checkTimeout(): #global args, active, scanner now = datetime.today() active.duration = (now - active.startTime).total_seconds() if active.duration > args.timeout: if args.debug >= D_INFO: print('Timeout') if active.frqTGID in timeouts: thisTO = timeouts[active.frqTGID] if args.debug >= D_FULL: print('Found previous timeout') else: thisTO = Timeout(active.frqTGID, now) timeouts[active.frqTGID] = thisTO if args.debug >= D_FULL: print('New Timeout') # decay the timeouts decay = int((now - thisTO.lastTimeout).total_seconds() / args.decay) thisTO.timeoutCount = thisTO.timeoutCount - decay if thisTO.timeoutCount - decay > 0 else 0; thisTO.timeoutCount += 1 thisTO.lastTimeout = now if args.debug >= D_DEBUG: print('Decay={}, count={}'.format(decay, thisTO.timeoutCount)) if thisTO.timeoutCount >= args.lockout: active.action = 'Lockout' scanner.cmd('KEY,L,P') # lockout else: active.action = 'Skip' scanner.cmd('KEY,>,P') # skip if args.debug >= D_INFO: print(active.action)
def hitChannel(resp): global active active = Hit(resp) resp = scanner.cmd('SQL', cooked=Scanner.DECODED) if not resp['iserror']: active.squelch = resp['LEVEL'] if args.debug >= D_INFO: print('Hit:', active.frqTGID)
def hitChannel(resp): global active active = Hit(resp) resp = scanner.cmd('SQL', cooked = Scanner.DECODED) if not resp['iserror']: active.squelch = resp['LEVEL'] if args.debug >= D_INFO: print('Hit:', active.frqTGID)
if args.debug >= D_DEBUG: print('ARGS=', pp_str(args)) timeoutDelta = timedelta(seconds=args.timeout) scanner = Scanner() if not scanner.isOpen(): scanner.discover() if not scanner.isOpen(): print('Scanner did not initialize!') raise RuntimeError if args.scanmode != scanmode: cmd = 'JPM,SVC_MODE,' + Scanner.ServiceModes[args.scanmode] if args.debug >= D_DEBUG: print('Sending:', cmd) resp = scanner.cmd(cmd, cooked=Scanner.DECODED) if args.debug >= D_FULL: print(pp_str(resp)) if not resp['isOK']: print('Unable to set scan mode!') print('Response = ', pp_str(resp)) raise RuntimeError # Scanner should be scanning one way or the other ... try: # Wrap the scan so we can catch the interrupt while True: resp = scanner.cmd('GLG', cooked=Scanner.DECODED) if resp['iserror'] or resp['CMD'] != 'GLG': print('Unable to get scan status!') print('Response = ', pp_str(resp))
if args.debug >= D_DEBUG: print('ARGS=', pp_str(args)) timeoutDelta = timedelta(seconds = args.timeout) scanner = Scanner() if not scanner.isOpen(): scanner.discover() if not scanner.isOpen(): print('Scanner did not initialize!') raise RuntimeError if args.scanmode != scanmode: cmd = 'JPM,SVC_MODE,' + Scanner.ServiceModes[args.scanmode] if args.debug >= D_DEBUG: print('Sending:', cmd) resp = scanner.cmd(cmd, cooked = Scanner.DECODED) if args.debug >= D_FULL: print(pp_str(resp)) if not resp['isOK']: print('Unable to set scan mode!') print('Response = ', pp_str(resp)) raise RuntimeError # Scanner should be scanning one way or the other ... try: # Wrap the scan so we can catch the interrupt while True: resp = scanner.cmd('GLG', cooked = Scanner.DECODED) if resp['iserror'] or resp['CMD'] != 'GLG': print('Unable to get scan status!') print('Response = ', pp_str(resp))