def run(self, grfstate, devid, cmdline, remotetask=False): self.remotetask = remotetask self.system_mods = grfstate.system_mods devmod = self.system_mods['devices'] if self.worker: gammarf_util.console_message("module already running", MOD_NAME) return try: freq, thresh = cmdline.split() except (ValueError, AttributeError): gammarf_util.console_message(self.__doc__) return freq = gammarf_util.str_to_hz(freq) if not freq: gammarf_util.console_message(self.__doc__) return try: thresh = float(thresh) except ValueError: gammarf_util.console_message(self.__doc__) return opts = {'devid': devid, 'freq': freq, 'thresh': thresh} self.worker = Single(opts, self.system_mods, self.settings) self.worker.daemon = True self.worker.start() gammarf_util.console_message("{} added on device {}".format( self.description, devid)) return True
def run(self, grfstate, devid, cmdline, remotetask=False): self.remotetask = remotetask system_mods = grfstate.system_mods devmod = system_mods['devices'] try: lowfreq, highfreq = cmdline.split() except (ValueError, AttributeError): gammarf_util.console_message(self.__doc__) return lowfreq = gammarf_util.str_to_hz(lowfreq) highfreq = gammarf_util.str_to_hz(highfreq) if not lowfreq or not highfreq: gammarf_util.console_message(self.__doc__) return maxfreq = int(devmod.get_hackrf_maxfreq() * 1e6) minfreq = int(devmod.get_hackrf_minfreq() * 1e6) if lowfreq < minfreq or highfreq > maxfreq: gammarf_util.console_message("frequency out of range", MOD_NAME) return if highfreq < lowfreq: gammarf_util.console_message("invalid frequency range", MOD_NAME) return if highfreq - lowfreq > MAX_BW: gammarf_util.console_message( "range exceeds maximum bandwidth of {}".format(MAX_BW), MOD_NAME) return self.worker = Snapshot(int(lowfreq), int(highfreq), devid, system_mods, self.settings, self.remotetask) self.worker.daemon = True self.worker.start() gammarf_util.console_message( "{} added on device {}".format(self.description, devid), MOD_NAME) return True
def cmd_pwr(grfstate, args): """Show the power at the specified frequency""" system_mods = grfstate.system_mods if not args: cmd_pwr_usage() return freq = gammarf_util.str_to_hz(args.split()[0]) if not freq: cmd_pwr_usage() return pwr = system_mods['spectrum'].pwr(freq) if pwr: gammarf_util.console_message(pwr)
def cmd_interesting_del(grfstate, args): """Delete an interesting frequency from this node's set""" system_mods = grfstate.system_mods if not args: cmd_interesting_del_usage() return freq = gammarf_util.str_to_hz(args) if not freq: cmd_interesting_del_usage() return if system_mods['connector'].interesting_del(freq): return True return
def request(self, reqline, connector): if not reqline: self.request_help() return args = reqline.split(None) if len(args) != 4: self.request_help() return station1, station2, station3, tdoa_freq = args tdoa_freq = gammarf_util.str_to_hz(tdoa_freq) if not tdoa_freq: self.request_help() return data = {} data['request'] = REQ_TDOA_PUT data['station1'] = station1 data['station2'] = station2 data['station3'] = station3 data['tdoafreq'] = tdoa_freq data['protocol'] = PROTOCOL_VERSION resp = connector.sendcmd(data) if resp['reply'] == 'ok': gammarf_util.console_message("request sent", MOD_NAME) else: if resp['error'] == 'invalid station': gammarf_util.console_message( "invalid station: {}".format(resp['station']), MOD_NAME) elif resp['error'] == 'busy': gammarf_util.console_message( "station busy: {}".format(resp['station']), MOD_NAME) else: gammarf_util.console_message( "problem sending task: {}".format(resp['error']), MOD_NAME) return
def cmd_interesting_add(grfstate, args): """Add an interesting frequency to this node's set""" system_mods = grfstate.system_mods if not args: cmd_interesting_add_usage() return try: freq, name = args.split() except ValueError: cmd_interesting_add_usage() return freq = gammarf_util.str_to_hz(freq) if not freq: cmd_interesting_add_usage() return if system_mods['connector'].interesting_add(freq, name): gammarf_util.console_message("interesting freqs updated") else: gammarf_util.console_message("error updating interesting freqs")