Commit c5e95933 authored by Mohd Bilal's avatar Mohd Bilal
Browse files

added gr-timgsn updates

parent ed448601
......@@ -19,61 +19,45 @@ import signal
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
from app.gnuradio.flowgraphs.doppler_correct import doppler_correct
from app.gnuradio.flowgraphs.packet_sender import TIM_packet_submit
#from gnuradio import zeromq
import osmosdr
import timgsn
import time
import satellites.core
import json
import config
def loadParameters(context, file, kwargs):
j = None
with open(file, 'r') as f:
j = json.load(f)
paramDict = j['client']['users'][0]
commonVariables = list(set(paramDict.keys()) & set(context.__dict__.keys()))
for var in commonVariables:
context.__dict__[var] = paramDict[var]
class GSN_RX(gr.top_block):
commonVariables = list(set(kwargs.keys()) & set(context.__dict__.keys()))
for var in commonVariables:
context.__dict__[var] = kwargs[var]
class Receiver(gr.top_block):
def __init__(self, **kwarg):
def __init__(self, file = "", **kwarg):
gr.top_block.__init__(self, "dd")
##################################################
# Variables
##################################################
self.username_env = kwarg["username"]
self.station_long = kwarg["station_long"]
self.station_lat = kwarg["station_lat"]
self.sat_freq = kwarg["sat_freq"]
self.samp_rate = kwarg["samp_rate"] if "samp_rate" in kwarg else 200000
self.rf_gain = kwarg["rf_gain"] if "rf_gain" in kwarg else 10
self.password_env = kwarg["password"]
self.overpass_uid = kwarg["overpass_uid"]
self.norad_id = kwarg["norad_id"]
self.if_gain = kwarg["if_gain"] if "if_gain" in kwarg else 20
self.gsn_name = kwarg["gsn_name"]
self.device_arg = kwarg["device_arg"]
self.bb_gain = kwarg["bb_gain"] if "bb_gain" in kwarg else 20
self.timezone = "Berlin/Europe"
self.settings_fpath = config.settings_file
self.username_env = username = "JMUW"
self.station_long = station_long = 9.974
self.station_lat = station_lat = 49.7813
self.sat_freq = sat_freq = 435.6e6
self.samp_rate = samp_rate = 200000
self.rf_gain = rf_gain = 10
self.password_env = password = "test1234"
self.overpass_uid = overpass_uid = "jmuw_uhf-39446--2021-04-22--12"
self.norad_id = norad_id = 46505#39446
self.if_gain = if_gain = 20
self.gsn_name = gsn_name = "TIMGSNTEST"
self.device_arg = device_arg = "hackrf=0"
self.bb_gain = bb_gain = 20
self.timezone = "Europe/Berlin"
self.gsn_url = "http://132.187.9.168:5000"
##################################################
# Blocks
##################################################
loadParameters(self, self.settings_fpath, kwarg)
timgsn.loadParameters(self, file , kwarg)
self.satellites_satellite_decoder_0 = satellites.core.gr_satellites_flowgraph(file = f'app/gnuradio/satellite_decoders/{self.norad_id}.yml', samp_rate = self.samp_rate/2, grc_block = True, iq = True, options = "")
self.osmosdr_source_0 = osmosdr.source(
args="numchan=" + str(1) + " " + self.device_arg
)
#elf.zeromq_sub_source_1 = zeromq.sub_source(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:50004', 100, False, -1)
self.satellites_satellite_decoder_0 = satellites.core.gr_satellites_flowgraph(norad = 39446, samp_rate = self.samp_rate/2, grc_block = True, iq = True, options = "")
self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + self.device_arg)
self.osmosdr_source_0.set_sample_rate(self.samp_rate)
self.osmosdr_source_0.set_center_freq(self.sat_freq - 50e3, 0)
self.osmosdr_source_0.set_freq_corr(0, 0)
......@@ -82,18 +66,23 @@ class Receiver(gr.top_block):
self.osmosdr_source_0.set_bb_gain(self.bb_gain, 0)
self.osmosdr_source_0.set_antenna('', 0)
self.osmosdr_source_0.set_bandwidth(0, 0)
self.osmosdr_source_0.set_dc_offset_mode(0, 0)
self.osmosdr_source_0.set_iq_balance_mode(0, 0)
self.osmosdr_source_0.set_gain_mode(False, 0)
self.low_pass_filter_0 = filter.fir_filter_ccf(
2,
firdes.low_pass(
1,
100e3,
8e3,
200e3,
10e3,
1e3,
firdes.WIN_HAMMING,
6.76))
self.timgsn_doppler_correct_0 = doppler_correct(self.norad_id, self.station_long, self.station_lat, self.sat_freq, self.timezone)
self.timgsn_TIM_packet_submit_0 = TIM_packet_submit(self.station_long, self.station_lat, self.norad_id, self.gsn_name, self.username_env, self.password_env, self.overpass_uid)
#self.timgsn_doppler_correct_0 = timgsn.doppler_correct(self.norad_id, self.station_lat, self.station_long, self.sat_freq, self.timezone)
self.timgsn_TIM_packet_submit_0 = timgsn.TIM_packet_submit(self.station_long, self.station_lat, self.norad_id, self.gsn_name, self.username_env, self.password_env, self.overpass_uid, self.gsn_url)
self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1)
self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
self.analog_sig_source_x_0_0_0 = analog.sig_source_c(self.samp_rate, analog.GR_COS_WAVE, -50e3, 1, 0, 0)
......@@ -106,13 +95,15 @@ class Receiver(gr.top_block):
##################################################
# Connections
##################################################
self.msg_connect((self.timgsn_doppler_correct_0, 'Freq_Offset'), (self.analog_sig_source_x_0_0, 'freq'))
#self.msg_connect((self.timgsn_doppler_correct_0, 'Freq_Offset'), (self.analog_sig_source_x_0_0, 'freq'))
self.msg_connect((self.satellites_satellite_decoder_0, 'out'), (self.timgsn_TIM_packet_submit_0, 'pckt'))
self.connect((self.analog_agc3_xx_0, 0), (self.satellites_satellite_decoder_0, 0))
self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0))
self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0))
self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_multiply_xx_0_0_0, 1))
self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.low_pass_filter_0, 0))
#self.connect((self.zeromq_sub_source_1, 0), (self.blocks_multiply_xx_0_0, 1))
self.connect((self.low_pass_filter_0, 0), (self.analog_agc3_xx_0, 0))
self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0_0, 1))
......@@ -169,7 +160,6 @@ class Receiver(gr.top_block):
def set_overpass_uid(self, overpass_uid):
self.overpass_uid = overpass_uid
self.timgsn_TIM_packet_submit_0.set_overpass_uid(overpass_uid)
def get_norad_id(self):
return self.norad_id
......@@ -204,7 +194,10 @@ class Receiver(gr.top_block):
self.osmosdr_source_0.set_bb_gain(self.bb_gain, 0)
def main(top_block_cls=Receiver, options=None):
def main(top_block_cls=GSN_RX, options=None):
if gr.enable_realtime_scheduling() != gr.RT_OK:
print("Error: failed to enable real-time scheduling.")
tb = top_block_cls()
......
......@@ -3,7 +3,7 @@ from utils.threading import ThreadedModule
from utils.helpers import setup_required
from utils.threading import ThreadedModule
from app.client import create_response
from app.gnuradio.flowgraphs.gsn_receiver import Receiver
from app.gnuradio.flowgraphs.gsn_receiver import GSN_RX as Receiver
import concurrent.futures
import threading
import config
......@@ -136,7 +136,8 @@ class Station(ThreadedModule):
"if_gain": 20,
"bb_gain": 20,
"gsn_name": self.name,
"device_arg": self.current_device.get("args")
"device_arg": self.current_device.get("args"),
"gsn_url": config.domain
}
local_op = ops.get("local")
timgsn_op = ops.get("timgsn")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment