From c4848ac358ce1a8916caf4cea8c393af24850da8 Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Sat, 2 Sep 2017 21:10:04 +0200 Subject: Updated changelog for Ubuntu's PPA --- dists/debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dists/debian/changelog b/dists/debian/changelog index a8596b0..9047074 100644 --- a/dists/debian/changelog +++ b/dists/debian/changelog @@ -1,3 +1,10 @@ +gr-gsm (0.41.1-0ppa0) xenial; urgency=low + + * First packaged release of gr-gsm (for Debian). + + -- Piotr Krysik Sun, 2 Sep 2017 21:00:00 +0100 + + gr-gsm (0.40-0ppa0) xenial; urgency=low * Initial upload (Closes: #871055). -- cgit v1.2.3 From a63ba0e4cc58f71d242f83981ef392398bc2eb92 Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Wed, 6 Sep 2017 17:45:37 +0200 Subject: Removing *livemon_headless.py script that shouldn't be in the repository. --- apps/grgsm_livemon_headless.py | 230 ----------------------------------------- 1 file changed, 230 deletions(-) delete mode 100755 apps/grgsm_livemon_headless.py diff --git a/apps/grgsm_livemon_headless.py b/apps/grgsm_livemon_headless.py deleted file mode 100755 index bcf3f8e..0000000 --- a/apps/grgsm_livemon_headless.py +++ /dev/null @@ -1,230 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -################################################## -# GNU Radio Python Flow Graph -# Title: Gr-gsm Livemon -# Author: Piotr Krysik -# Description: Interactive monitor of a single C0 channel with analysis performed by Wireshark (command to run wireshark: sudo wireshark -k -f udp -Y gsmtap -i lo) -# Generated: Wed Aug 30 10:38:50 2017 -################################################## - -from gnuradio import blocks -from gnuradio import eng_notation -from gnuradio import gr -from gnuradio.eng_option import eng_option -from gnuradio.filter import firdes -from math import pi -from optparse import OptionParser -import grgsm -import osmosdr -import pmt -import time - - -class grgsm_livemon_headless(gr.top_block): - - def __init__(self, rec_len=1000000, samp_rate=2000000.052982, fc=941.8e6, shiftoff=400e3, args="", osr=4, collector="localhost", collectorport="4729", serverport="4729", gain=30, ppm=0): - gr.top_block.__init__(self, "Gr-gsm Livemon") - - ################################################## - # Parameters - ################################################## - self.rec_len = rec_len - self.samp_rate = samp_rate - self.fc = fc - self.shiftoff = shiftoff - self.args = args - self.osr = osr - self.collector = collector - self.collectorport = collectorport - self.serverport = serverport - self.gain = gain - self.ppm = ppm - - ################################################## - # Blocks - ################################################## - self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + args ) - self.rtlsdr_source_0.set_sample_rate(samp_rate) - self.rtlsdr_source_0.set_center_freq(fc-shiftoff, 0) - self.rtlsdr_source_0.set_freq_corr(ppm, 0) - self.rtlsdr_source_0.set_dc_offset_mode(2, 0) - self.rtlsdr_source_0.set_iq_balance_mode(2, 0) - self.rtlsdr_source_0.set_gain_mode(False, 0) - self.rtlsdr_source_0.set_gain(gain, 0) - self.rtlsdr_source_0.set_if_gain(20, 0) - self.rtlsdr_source_0.set_bb_gain(20, 0) - self.rtlsdr_source_0.set_antenna("", 0) - self.rtlsdr_source_0.set_bandwidth(250e3+abs(shiftoff), 0) - - self.gsm_sdcch8_demapper_0 = grgsm.gsm_sdcch8_demapper( - timeslot_nr=1, - ) - self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([]), False) - self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, - False, False) - self.gsm_input_0 = grgsm.gsm_input( - ppm=ppm-int(ppm), - osr=4, - fc=fc, - samp_rate_in=samp_rate, - ) - self.gsm_decryption_0 = grgsm.decryption(([]), 1) - self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() - self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() - self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff, samp_rate, osr) - self.gsm_bcch_ccch_sdcch4_demapper_0 = grgsm.gsm_bcch_ccch_sdcch4_demapper( - timeslot_nr=0, - ) - self.blocks_socket_pdu_0_1 = blocks.socket_pdu("UDP_CLIENT", collector, collectorport, 1500, False) - self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", serverport, 10000, False) - self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) - self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, int(rec_len*samp_rate)) - - ################################################## - # Connections - ################################################## - self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.gsm_message_printer_1, 'msgs')) - self.msg_connect((self.gsm_bcch_ccch_sdcch4_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) - self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_input_0, 'ctrl_in')) - self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0_1, 'pdus')) - self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0_1, 'pdus')) - self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) - self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_sdcch4_demapper_0, 'bursts')) - self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) - self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) - self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) - self.connect((self.blocks_head_0, 0), (self.blocks_rotator_cc_0, 0)) - self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) - self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) - self.connect((self.rtlsdr_source_0, 0), (self.blocks_head_0, 0)) - - def get_rec_len(self): - return self.rec_len - - def set_rec_len(self, rec_len): - self.rec_len = rec_len - self.blocks_head_0.set_length(int(self.rec_len*self.samp_rate)) - - def get_samp_rate(self): - return self.samp_rate - - def set_samp_rate(self, samp_rate): - self.samp_rate = samp_rate - self.rtlsdr_source_0.set_sample_rate(self.samp_rate) - self.blocks_head_0.set_length(int(self.rec_len*self.samp_rate)) - self.blocks_rotator_cc_0.set_phase_inc(-2*pi*self.shiftoff/self.samp_rate) - self.gsm_input_0.set_samp_rate_in(self.samp_rate) - - def get_fc(self): - return self.fc - - def set_fc(self, fc): - self.fc = fc - self.rtlsdr_source_0.set_center_freq(self.fc-self.shiftoff, 0) - self.gsm_input_0.set_fc(self.fc) - - def get_shiftoff(self): - return self.shiftoff - - def set_shiftoff(self, shiftoff): - self.shiftoff = shiftoff - self.rtlsdr_source_0.set_center_freq(self.fc-self.shiftoff, 0) - self.rtlsdr_source_0.set_bandwidth(250e3+abs(self.shiftoff), 0) - self.blocks_rotator_cc_0.set_phase_inc(-2*pi*self.shiftoff/self.samp_rate) - - def get_args(self): - return self.args - - def set_args(self, args): - self.args = args - - def get_osr(self): - return self.osr - - def set_osr(self, osr): - self.osr = osr - - def get_collector(self): - return self.collector - - def set_collector(self, collector): - self.collector = collector - - def get_collectorport(self): - return self.collectorport - - def set_collectorport(self, collectorport): - self.collectorport = collectorport - - def get_serverport(self): - return self.serverport - - def set_serverport(self, serverport): - self.serverport = serverport - - def get_gain(self): - return self.gain - - def set_gain(self, gain): - self.gain = gain - self.rtlsdr_source_0.set_gain(self.gain, 0) - - def get_ppm(self): - return self.ppm - - def set_ppm(self, ppm): - self.ppm = ppm - self.rtlsdr_source_0.set_freq_corr(self.ppm, 0) - self.gsm_input_0.set_ppm(self.ppm-int(self.ppm)) - - -def argument_parser(): - parser = OptionParser(option_class=eng_option, usage="%prog: [options]") - parser.add_option( - "-T", "--rec-len", dest="rec_len", type="eng_float", default=eng_notation.num_to_str(1000000), - help="Set Recording length in seconds [default=%default]") - parser.add_option( - "-s", "--samp-rate", dest="samp_rate", type="eng_float", default=eng_notation.num_to_str(2000000.052982), - help="Set samp_rate [default=%default]") - parser.add_option( - "-f", "--fc", dest="fc", type="eng_float", default=eng_notation.num_to_str(941.8e6), - help="Set GSM channel's central frequency [default=%default]") - parser.add_option( - "-o", "--shiftoff", dest="shiftoff", type="eng_float", default=eng_notation.num_to_str(400e3), - help="Set Frequency Shiftoff [default=%default]") - parser.add_option( - "", "--args", dest="args", type="string", default="", - help="Set Device Arguments [default=%default]") - parser.add_option( - "", "--osr", dest="osr", type="intx", default=4, - help="Set OverSampling Ratio [default=%default]") - parser.add_option( - "", "--collector", dest="collector", type="string", default="localhost", - help="Set IP or DNS name of collector point [default=%default]") - parser.add_option( - "", "--collectorport", dest="collectorport", type="string", default="4729", - help="Set UDP port number of collector [default=%default]") - parser.add_option( - "", "--serverport", dest="serverport", type="string", default="4729", - help="Set UDP server listening port [default=%default]") - parser.add_option( - "-g", "--gain", dest="gain", type="eng_float", default=eng_notation.num_to_str(30), - help="Set RF Gain [default=%default]") - parser.add_option( - "-p", "--ppm", dest="ppm", type="eng_float", default=eng_notation.num_to_str(0), - help="Set Clock frequency offset in ppms (1/1e6 parts) [default=%default]") - return parser - - -def main(top_block_cls=grgsm_livemon_headless, options=None): - if options is None: - options, _ = argument_parser().parse_args() - - tb = top_block_cls(rec_len=options.rec_len, samp_rate=options.samp_rate, fc=options.fc, shiftoff=options.shiftoff, args=options.args, osr=options.osr, collector=options.collector, collectorport=options.collectorport, serverport=options.serverport, gain=options.gain, ppm=options.ppm) - tb.start() - tb.wait() - - -if __name__ == '__main__': - main() -- cgit v1.2.3 From 1a35cb973fba5c770f7c14a769c0b1b9d329e764 Mon Sep 17 00:00:00 2001 From: leommxj Date: Sun, 10 Sep 2017 00:49:06 +0800 Subject: fix bug after commit 3dfa11b89e6a74e6857c11e3029b372c746d535f .change is_valid_arfcn grgsm(a,b) to one argument in grgsm_decode and grgsm_capture --- apps/grgsm_decode | 4 ++-- apps/helpers/grgsm_capture | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/grgsm_decode b/apps/grgsm_decode index 222d67e..66ecae2 100755 --- a/apps/grgsm_decode +++ b/apps/grgsm_decode @@ -350,7 +350,7 @@ if __name__ == '__main__': if options.band: if options.band not in grgsm.arfcn.get_bands(): parser.error("Invalid GSM band\n") - elif not grgsm.arfcn.is_valid_arfcn(options.arfcn, options.band): + elif not grgsm.arfcn.is_valid_arfcn(options.arfcn): parser.error("ARFCN is not valid in the specified band\n") else: arfcn = options.arfcn @@ -358,7 +358,7 @@ if __name__ == '__main__': else: arfcn = options.arfcn for band in grgsm.arfcn.get_bands(): - if grgsm.arfcn.is_valid_arfcn(arfcn, band): + if grgsm.arfcn.is_valid_arfcn(arfcn): fc = grgsm.arfcn.arfcn2downlink(arfcn, band) break elif options.fc: diff --git a/apps/helpers/grgsm_capture b/apps/helpers/grgsm_capture index add42d3..d14d1e8 100755 --- a/apps/helpers/grgsm_capture +++ b/apps/helpers/grgsm_capture @@ -142,7 +142,7 @@ class grgsm_capture(gr.top_block): new_freq = grgsm.arfcn.arfcn2downlink(self.arfcn, self.band) else: for band in grgsm.arfcn.get_bands(): - if grgsm.arfcn.is_valid_arfcn(arfcn, band): + if grgsm.arfcn.is_valid_arfcn(arfcn): new_freq = grgsm.arfcn.arfcn2downlink(arfcn, band) break self.set_fc(new_freq) @@ -232,7 +232,7 @@ if __name__ == '__main__': if options.band: if options.band not in grgsm.arfcn.get_bands(): parser.error("Invalid GSM band\n") - elif not grgsm.arfcn.is_valid_arfcn(options.arfcn, options.band): + elif not grgsm.arfcn.is_valid_arfcn(options.arfcn): parser.error("ARFCN is not valid in the specified band\n") else: arfcn = options.arfcn @@ -240,7 +240,7 @@ if __name__ == '__main__': else: arfcn = options.arfcn for band in grgsm.arfcn.get_bands(): - if grgsm.arfcn.is_valid_arfcn(arfcn, band): + if grgsm.arfcn.is_valid_arfcn(arfcn): fc = grgsm.arfcn.arfcn2downlink(arfcn, band) break elif options.fc: -- cgit v1.2.3 From ece9fd7f39a96484aee027eda3bc38b17fb2fa17 Mon Sep 17 00:00:00 2001 From: leommxj Date: Sun, 10 Sep 2017 01:02:53 +0800 Subject: fix bug after commit 3dfa11b89e6a74e6857c11e3029b372c746d535f .change arfcn2downlink(a,b) to one argument in grgsm_decode and grgsm_capture and grgsm_channelize --- apps/grgsm_decode | 4 ++-- apps/helpers/grgsm_capture | 8 ++++---- apps/helpers/grgsm_channelize | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/grgsm_decode b/apps/grgsm_decode index 66ecae2..70cd284 100755 --- a/apps/grgsm_decode +++ b/apps/grgsm_decode @@ -354,12 +354,12 @@ if __name__ == '__main__': parser.error("ARFCN is not valid in the specified band\n") else: arfcn = options.arfcn - fc = grgsm.arfcn.arfcn2downlink(arfcn, options.band) + fc = grgsm.arfcn.arfcn2downlink(arfcn) else: arfcn = options.arfcn for band in grgsm.arfcn.get_bands(): if grgsm.arfcn.is_valid_arfcn(arfcn): - fc = grgsm.arfcn.arfcn2downlink(arfcn, band) + fc = grgsm.arfcn.arfcn2downlink(arfcn) break elif options.fc: fc = options.fc diff --git a/apps/helpers/grgsm_capture b/apps/helpers/grgsm_capture index d14d1e8..8b10c61 100755 --- a/apps/helpers/grgsm_capture +++ b/apps/helpers/grgsm_capture @@ -139,11 +139,11 @@ class grgsm_capture(gr.top_block): if self.verbose or self.burst_file: self.gsm_receiver.set_cell_allocation([self.arfcn]) if options.band: - new_freq = grgsm.arfcn.arfcn2downlink(self.arfcn, self.band) + new_freq = grgsm.arfcn.arfcn2downlink(self.arfcn) else: for band in grgsm.arfcn.get_bands(): if grgsm.arfcn.is_valid_arfcn(arfcn): - new_freq = grgsm.arfcn.arfcn2downlink(arfcn, band) + new_freq = grgsm.arfcn.arfcn2downlink(arfcn) break self.set_fc(new_freq) @@ -236,12 +236,12 @@ if __name__ == '__main__': parser.error("ARFCN is not valid in the specified band\n") else: arfcn = options.arfcn - fc = grgsm.arfcn.arfcn2downlink(arfcn, options.band) + fc = grgsm.arfcn.arfcn2downlink(arfcn) else: arfcn = options.arfcn for band in grgsm.arfcn.get_bands(): if grgsm.arfcn.is_valid_arfcn(arfcn): - fc = grgsm.arfcn.arfcn2downlink(arfcn, band) + fc = grgsm.arfcn.arfcn2downlink(arfcn) break elif options.fc: fc = options.fc diff --git a/apps/helpers/grgsm_channelize b/apps/helpers/grgsm_channelize index fb30334..5735a1a 100755 --- a/apps/helpers/grgsm_channelize +++ b/apps/helpers/grgsm_channelize @@ -94,7 +94,7 @@ class grgsm_channelize(gr.top_block): print("Extracting channels %s, given that the center frequency is at %s" % (str(channels), eng_notation.num_to_str(fc))) for channel in channels: - channel_freq = arfcn.arfcn2downlink(channel, band) + channel_freq = arfcn.arfcn2downlink(channel) if channel_freq is None: print("Warning: invalid ARFCN %d for band %s" % (channel, band)) continue -- cgit v1.2.3 From caa7741d0907a00701e54446f61fae13679956ce Mon Sep 17 00:00:00 2001 From: leommxj Date: Sun, 10 Sep 2017 14:49:03 +0800 Subject: delete some useless code after the change of is_valid_arfcn(...) and arfcn2downlink(...) --- apps/grgsm_decode | 7 ++----- apps/helpers/grgsm_capture | 15 +++------------ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/apps/grgsm_decode b/apps/grgsm_decode index 70cd284..dbac386 100755 --- a/apps/grgsm_decode +++ b/apps/grgsm_decode @@ -351,16 +351,13 @@ if __name__ == '__main__': if options.band not in grgsm.arfcn.get_bands(): parser.error("Invalid GSM band\n") elif not grgsm.arfcn.is_valid_arfcn(options.arfcn): - parser.error("ARFCN is not valid in the specified band\n") + parser.error("ARFCN is not valid\n") else: arfcn = options.arfcn fc = grgsm.arfcn.arfcn2downlink(arfcn) else: arfcn = options.arfcn - for band in grgsm.arfcn.get_bands(): - if grgsm.arfcn.is_valid_arfcn(arfcn): - fc = grgsm.arfcn.arfcn2downlink(arfcn) - break + grgsm.arfcn.arfcn2downlink(arfcn) elif options.fc: fc = options.fc if options.band: diff --git a/apps/helpers/grgsm_capture b/apps/helpers/grgsm_capture index 8b10c61..0c96df1 100755 --- a/apps/helpers/grgsm_capture +++ b/apps/helpers/grgsm_capture @@ -138,13 +138,7 @@ class grgsm_capture(gr.top_block): self.arfcn = arfcn if self.verbose or self.burst_file: self.gsm_receiver.set_cell_allocation([self.arfcn]) - if options.band: - new_freq = grgsm.arfcn.arfcn2downlink(self.arfcn) - else: - for band in grgsm.arfcn.get_bands(): - if grgsm.arfcn.is_valid_arfcn(arfcn): - new_freq = grgsm.arfcn.arfcn2downlink(arfcn) - break + new_freq = grgsm.arfcn.arfcn2downlink(self.arfcn) self.set_fc(new_freq) def get_gain(self): @@ -233,16 +227,13 @@ if __name__ == '__main__': if options.band not in grgsm.arfcn.get_bands(): parser.error("Invalid GSM band\n") elif not grgsm.arfcn.is_valid_arfcn(options.arfcn): - parser.error("ARFCN is not valid in the specified band\n") + parser.error("ARFCN is not valid\n") else: arfcn = options.arfcn fc = grgsm.arfcn.arfcn2downlink(arfcn) else: arfcn = options.arfcn - for band in grgsm.arfcn.get_bands(): - if grgsm.arfcn.is_valid_arfcn(arfcn): - fc = grgsm.arfcn.arfcn2downlink(arfcn) - break + fc = grgsm.arfcn.arfcn2downlink(arfcn) elif options.fc: fc = options.fc if options.band: -- cgit v1.2.3 From df0adf3d86f0ae38ac81ec7c4052be2a2032b4c5 Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Mon, 11 Sep 2017 09:35:56 +0200 Subject: Remove band from grgsm_capture altogether --- apps/helpers/grgsm_capture | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/apps/helpers/grgsm_capture b/apps/helpers/grgsm_capture index 0c96df1..a5133bc 100755 --- a/apps/helpers/grgsm_capture +++ b/apps/helpers/grgsm_capture @@ -38,7 +38,7 @@ import sys class grgsm_capture(gr.top_block): - def __init__(self, fc, gain, samp_rate, ppm, arfcn, cfile=None, burst_file=None, band=None, verbose=False, rec_length=None, args=""): + def __init__(self, fc, gain, samp_rate, ppm, arfcn, cfile=None, burst_file=None, verbose=False, rec_length=None, args=""): gr.top_block.__init__(self, "Gr-gsm Capture") @@ -52,7 +52,6 @@ class grgsm_capture(gr.top_block): self.arfcn = arfcn self.cfile = cfile self.burst_file = burst_file - self.band = band self.verbose = verbose self.shiftoff = shiftoff = 400e3 self.rec_length = rec_length @@ -180,7 +179,7 @@ if __name__ == '__main__': help="Set frequency [default=%default]") parser.add_option("-a", "--arfcn", dest="arfcn", type="intx", - help="Set ARFCN instead of frequency. In some cases you may have to provide the GSM band also") + help="Set ARFCN instead of frequency (for PCS1900 add 0x8000 (2**15) to the ARFCN number)") parser.add_option("-g", "--gain", dest="gain", type="eng_float", default=eng_notation.num_to_str(30), @@ -199,10 +198,6 @@ if __name__ == '__main__': parser.add_option("-c", "--cfile", dest="cfile", help="File where the captured data are saved") - bands_list = ", ".join(grgsm.arfcn.get_bands()) - parser.add_option("--band", dest="band", - help="Specify the GSM band for the frequency.\nAvailable bands are: " + bands_list + ".\nIf no band is specified, it will be determined automatically, defaulting to 0." ) - parser.add_option("", "--args", dest="args", type="string", default="", help="Set device arguments [default=%default]") @@ -223,31 +218,11 @@ if __name__ == '__main__': arfcn = 0 fc = 939.4e6 if options.arfcn: - if options.band: - if options.band not in grgsm.arfcn.get_bands(): - parser.error("Invalid GSM band\n") - elif not grgsm.arfcn.is_valid_arfcn(options.arfcn): - parser.error("ARFCN is not valid\n") - else: - arfcn = options.arfcn - fc = grgsm.arfcn.arfcn2downlink(arfcn) - else: - arfcn = options.arfcn - fc = grgsm.arfcn.arfcn2downlink(arfcn) + arfcn = options.arfcn + fc = grgsm.arfcn.arfcn2downlink(arfcn) elif options.fc: fc = options.fc - if options.band: - if options.band not in grgsm.arfcn.get_bands(): - parser.error("Invalid GSM band\n") - elif not grgsm.arfcn.is_valid_downlink(options.fc, options.band): - parser.error("Frequency is not valid in the specified band\n") - else: - arfcn = grgsm.arfcn.downlink2arfcn(options.fc, options.band) - else: - for band in grgsm.arfcn.get_bands(): - if grgsm.arfcn.is_valid_downlink(options.fc, band): - arfcn = grgsm.arfcn.downlink2arfcn(options.fc, band) - break + arfcn = grgsm.arfcn.downlink2arfcn(options.fc) tb = grgsm_capture(fc=fc, gain=options.gain, samp_rate=options.samp_rate, ppm=options.ppm, arfcn=arfcn, cfile=options.cfile, -- cgit v1.2.3 From a80567f0132bdad08cf3b6ec38328779f7f60845 Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Mon, 11 Sep 2017 10:01:12 +0200 Subject: Bring back parameter checking, correct creation of grgsm_capture object --- apps/helpers/grgsm_capture | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/helpers/grgsm_capture b/apps/helpers/grgsm_capture index a5133bc..b1b85a7 100755 --- a/apps/helpers/grgsm_capture +++ b/apps/helpers/grgsm_capture @@ -218,15 +218,18 @@ if __name__ == '__main__': arfcn = 0 fc = 939.4e6 if options.arfcn: - arfcn = options.arfcn - fc = grgsm.arfcn.arfcn2downlink(arfcn) + if not grgsm.arfcn.is_valid_arfcn(options.arfcn): + parser.error("ARFCN is not valid\n") + else: + arfcn = options.arfcn + fc = grgsm.arfcn.arfcn2downlink(arfcn) elif options.fc: fc = options.fc arfcn = grgsm.arfcn.downlink2arfcn(options.fc) tb = grgsm_capture(fc=fc, gain=options.gain, samp_rate=options.samp_rate, ppm=options.ppm, arfcn=arfcn, cfile=options.cfile, - burst_file=options.burst_file, band=options.band, verbose=options.verbose, + burst_file=options.burst_file, verbose=options.verbose, rec_length=options.rec_length, args=options.args) def signal_handler(signal, frame): -- cgit v1.2.3 From fcb45b021a1634ef097f16f1bcae79dba7f506db Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Mon, 11 Sep 2017 10:07:25 +0200 Subject: Remove 'band' option from grgsm_decode altogether --- apps/grgsm_decode | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/apps/grgsm_decode b/apps/grgsm_decode index dbac386..9c01e66 100755 --- a/apps/grgsm_decode +++ b/apps/grgsm_decode @@ -284,12 +284,7 @@ if __name__ == '__main__': cfile_options.add_option("-f", "--fc", dest="fc", type="eng_float", help="Frequency of cfile capture") cfile_options.add_option("-a", "--arfcn", dest="arfcn", type="intx", - help="Set ARFCN instead of frequency. " - "In some cases you may have to provide the GSM band also") - cfile_options.add_option("--band", dest="band", - help="Specify the GSM band for the frequency.\nAvailable bands are: " - + ", ".join(grgsm.arfcn.get_bands()) + "." - + "If no band is specified, it will be determined automatically, defaulting to 0.") + help="Set ARFCN instead of frequency (for PCS1900 add 0x8000 (2**15) to the ARFCN number).") cfile_options.add_option("-s", "--samp-rate", dest="samp_rate", type="eng_float", default=eng_notation.num_to_str(1e6), help="Sample rate of cfile capture [default=%default]") @@ -347,31 +342,14 @@ if __name__ == '__main__': arfcn = None fc = None if options.arfcn: - if options.band: - if options.band not in grgsm.arfcn.get_bands(): - parser.error("Invalid GSM band\n") - elif not grgsm.arfcn.is_valid_arfcn(options.arfcn): - parser.error("ARFCN is not valid\n") - else: - arfcn = options.arfcn - fc = grgsm.arfcn.arfcn2downlink(arfcn) + if not grgsm.arfcn.is_valid_arfcn(options.arfcn): + parser.error("ARFCN is not valid\n") else: arfcn = options.arfcn - grgsm.arfcn.arfcn2downlink(arfcn) + fc = grgsm.arfcn.arfcn2downlink(arfcn) elif options.fc: fc = options.fc - if options.band: - if options.band not in grgsm.arfcn.get_bands(): - parser.error("Invalid GSM band\n") - elif not grgsm.arfcn.is_valid_downlink(options.fc, options.band): - parser.error("Frequency is not valid in the specified band\n") - else: - arfcn = grgsm.arfcn.downlink2arfcn(options.fc, options.band) - else: - for band in grgsm.arfcn.get_bands(): - if grgsm.arfcn.is_valid_downlink(options.fc, band): - arfcn = grgsm.arfcn.downlink2arfcn(options.fc, band) - break + arfcn = grgsm.arfcn.downlink2arfcn(options.fc) # instanciate decoder tb = grgsm_decoder(timeslot=options.timeslot, subslot=options.subslot, chan_mode=options.chan_mode, @@ -386,4 +364,3 @@ if __name__ == '__main__': # run tb.start() tb.wait() - -- cgit v1.2.3 From 45b87000728ac61c086e70f78fb1f638f026fd4b Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Mon, 11 Sep 2017 10:32:23 +0200 Subject: Removed all references to 'band' --- apps/helpers/grgsm_channelize | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/apps/helpers/grgsm_channelize b/apps/helpers/grgsm_channelize index 5735a1a..9b00bd7 100755 --- a/apps/helpers/grgsm_channelize +++ b/apps/helpers/grgsm_channelize @@ -56,24 +56,16 @@ def eng_float(value): except: raise ArgumentTypeError("invalid engineering notation value: {0}".format(value)) -def gsm_band(value): - choices = arfcn.get_bands() - if value in choices: - return value - else: - raise ArgumentTypeError("invalid GSM band: {0}. Possible choices are: {1}".format(value, choices)) - class grgsm_channelize(gr.top_block): - def __init__(self, channels, resamp_rate, fc, band, samp_rate, input_file, dest_dir, data_type="complex"): + def __init__(self, arfcns, resamp_rate, fc, samp_rate, input_file, dest_dir, data_type="complex"): gr.top_block.__init__(self, "grgsm_channelize") ################################################## # Parameters ################################################## - self.channels = channels + self.arfcns = arfcns self.resamp_rate = resamp_rate self.fc = fc - self.band = band self.samp_rate = samp_rate self.blocks_resamplers = {} self.blocks_rotators = {} @@ -91,13 +83,10 @@ class grgsm_channelize(gr.top_block): self.source = blocks.file_source(gr.sizeof_gr_complex, input_file, False) fc_str = eng_notation.num_to_str(fc) - print("Extracting channels %s, given that the center frequency is at %s" % (str(channels), eng_notation.num_to_str(fc))) + print("Extracting channels %s, given that the center frequency is at %s" % (str(arfcns), eng_notation.num_to_str(fc))) - for channel in channels: + for channel in self.arfcns: channel_freq = arfcn.arfcn2downlink(channel) - if channel_freq is None: - print("Warning: invalid ARFCN %d for band %s" % (channel, band)) - continue freq_diff = channel_freq - fc freq_diff_str = "+" if 0 <= freq_diff else "" freq_diff_str += eng_notation.num_to_str(freq_diff) @@ -115,14 +104,12 @@ class grgsm_channelize(gr.top_block): if __name__ == '__main__': parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter, description='Split wideband a GSM capture into seperate files per ARFCN.', add_help=True, epilog=EXTRA_HELP) - parser.add_argument(dest="channel", type=int, nargs='+', - help="List of ARFCNs") + parser.add_argument(dest="arfcns", type=int, nargs='+', + help="List of ARFCNs (for PCS1900 add 0x8000 (2**15) to the ARFCN number)") parser.add_argument("-s", "--samp-rate", dest="samp_rate", type=eng_float, default=eng_notation.num_to_str(2e6), help="Sample rate of the wideband capture file [default=%(default)s]") parser.add_argument("-f", "--fc", dest="fc", type=eng_float, default=eng_notation.num_to_str(935e6), required=True, help="Carrier frequency in Hz [default=%(default)s]") - parser.add_argument("-b", "--band", dest="band", type=gsm_band, default='E-GSM', - help="GSM band [default=%(default)s]") #TODO: add automatic discovery based on fc parser.add_argument("-o", "--out-samp-rate", dest="out_samp_rate", type=eng_float, default=eng_notation.num_to_str(1e6), help="Sample rate of the output capture files [default=%(default)s]") parser.add_argument("-i", "--input_file", dest="input_file", type=str, required=True, @@ -133,7 +120,11 @@ if __name__ == '__main__': help="Destination directory - if not given defaults to input file name without extension") args = parser.parse_args() - + + for ch in args.arfcns: + if not arfcn.is_valid_arfcn(ch): + parser.error("ARFCN "+str(ch)+" is not valid\n") + if not os.path.exists(args.input_file): raise IOError(args.input_file + " does not exist") @@ -154,10 +145,9 @@ if __name__ == '__main__': print("Output sample rate: " + eng_notation.num_to_str(args.out_samp_rate)) print("==> using resample rate of " + str(resamp_rate)) - tb = grgsm_channelize(channels=args.channel, + tb = grgsm_channelize(arfcns=args.arfcns, resamp_rate=resamp_rate, fc=args.fc, - band=args.band, samp_rate=args.samp_rate, input_file=args.input_file, dest_dir=args.dest_dir, -- cgit v1.2.3