diff --git a/gpssim.c b/gpssim.c index 2444e54..ee9bf5a 100644 --- a/gpssim.c +++ b/gpssim.c @@ -13,6 +13,7 @@ #include "gpssim.h" #include "socket.c" + int sinTable512[] = { 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 91, 94, @@ -1867,7 +1868,7 @@ int main(int argc, char *argv[]) llh[2] = 10.0; } - if (duration<0.0 || (duration>((double)USER_MOTION_SIZE)/10.0 && !staticLocationMode) || (duration>STATIC_MAX_DURATION && staticLocationMode)&&usesocket==false) + if (duration<0.0 || (duration>((double)USER_MOTION_SIZE)/10.0 && !staticLocationMode) || (duration>STATIC_MAX_DURATION && staticLocationMode&&usesocket==false)) { printf("ERROR: Invalid duration.\n"); exit(1); @@ -2131,7 +2132,7 @@ int main(int argc, char *argv[]) //////////////////////////////////////////////////////////// tstart = clock(); - + long int timestart=timem(); // Update receiver time grx = incGpsTime(grx, 0.1); @@ -2323,8 +2324,8 @@ int main(int argc, char *argv[]) } } } - if(subGpsTime(grx, g0)-(double)(clock()-tstart)/CLOCKS_PER_SEC>0.2&&usesocket==true){ - sleep(0.2); + if(subGpsTime(grx, g0)-(float)(timem()-timestart)/1000>0.1&&usesocket==true){ + usleep(100000); } // Update receiver time grx = incGpsTime(grx, 0.1); @@ -2333,7 +2334,7 @@ int main(int argc, char *argv[]) printf("\rTime into run = %4.1f", subGpsTime(grx, g0)); fflush(stdout); } - + tend = clock(); printf("\nDone!\n"); diff --git a/socket.c b/socket.c index ff11d77..e54f54c 100644 --- a/socket.c +++ b/socket.c @@ -35,4 +35,8 @@ void socksend(int s,void *dataa,int siz){ send(s,dataa,siz,0); } - +long int timem(){ + struct timeval t; + gettimeofday(&t, NULL); + return t.tv_sec*1000+t.tv_usec/1000; +} diff --git a/tcp.grc b/tcp.grc index 48a84ff..fafae56 100644 --- a/tcp.grc +++ b/tcp.grc @@ -187,7 +187,7 @@ if_gain0 - 40 + 20 gain0 @@ -1071,11 +1071,11 @@ args - hackrf + hackrf=81320f _enabled - True + 0 _coordinate @@ -1174,10 +1174,235 @@ + + qtgui_waterfall_sink_x + + bw + samp_rate + + + alias + + + + fc + 0 + + + comment + + + + affinity + + + + _enabled + 1 + + + fftsize + 1024 + + + _coordinate + (576, 392) + + + gui_hint + + + + _rotation + 0 + + + grid + False + + + id + qtgui_waterfall_sink_x_0 + + + int_max + 10 + + + int_min + -140 + + + legend + True + + + alpha1 + 1.0 + + + color1 + 0 + + + label1 + + + + alpha10 + 1.0 + + + color10 + 0 + + + label10 + + + + alpha2 + 1.0 + + + color2 + 0 + + + label2 + + + + alpha3 + 1.0 + + + color3 + 0 + + + label3 + + + + alpha4 + 1.0 + + + color4 + 0 + + + label4 + + + + alpha5 + 1.0 + + + color5 + 0 + + + label5 + + + + alpha6 + 1.0 + + + color6 + 0 + + + label6 + + + + alpha7 + 1.0 + + + color7 + 0 + + + label7 + + + + alpha8 + 1.0 + + + color8 + 0 + + + label8 + + + + alpha9 + 1.0 + + + color9 + 0 + + + label9 + + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + name + "" + + + nconnections + 1 + + + showports + True + + + freqhalf + True + + + type + complex + + + update_time + 0.10 + + + wintype + firdes.WIN_BLACKMAN_hARRIS + + blks2_tcp_source_0 osmosdr_sink_0 0 0 + + blks2_tcp_source_0 + qtgui_waterfall_sink_x_0 + 0 + 0 + diff --git a/top_block.py b/top_block.py index 6c86442..41ea3b1 100644 --- a/top_block.py +++ b/top_block.py @@ -2,7 +2,7 @@ ################################################## # GNU Radio Python Flow Graph # Title: Top Block -# Generated: Sun Apr 23 02:23:32 2017 +# Generated: Sun Apr 23 03:36:05 2017 ################################################## if __name__ == '__main__': @@ -18,13 +18,13 @@ if __name__ == '__main__': from PyQt4 import Qt from gnuradio import eng_notation from gnuradio import gr +from gnuradio import qtgui from gnuradio.eng_option import eng_option from gnuradio.filter import firdes from grc_gnuradio import blks2 as grc_blks2 from optparse import OptionParser -import osmosdr +import sip import sys -import time class top_block(gr.top_block, Qt.QWidget): @@ -60,16 +60,41 @@ class top_block(gr.top_block, Qt.QWidget): ################################################## # Blocks ################################################## - self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "hackrf" ) - self.osmosdr_sink_0.set_sample_rate(samp_rate) - self.osmosdr_sink_0.set_center_freq(1575420000, 0) - self.osmosdr_sink_0.set_freq_corr(0, 0) - self.osmosdr_sink_0.set_gain(14, 0) - self.osmosdr_sink_0.set_if_gain(40, 0) - self.osmosdr_sink_0.set_bb_gain(20, 0) - self.osmosdr_sink_0.set_antenna("1", 0) - self.osmosdr_sink_0.set_bandwidth(0, 0) - + self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( + 1024, #size + firdes.WIN_BLACKMAN_hARRIS, #wintype + 0, #fc + samp_rate, #bw + "", #name + 1 #number of inputs + ) + self.qtgui_waterfall_sink_x_0.set_update_time(0.10) + self.qtgui_waterfall_sink_x_0.enable_grid(False) + + if not True: + self.qtgui_waterfall_sink_x_0.disable_legend() + + if complex == type(float()): + self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) + + labels = ["", "", "", "", "", + "", "", "", "", ""] + colors = [0, 0, 0, 0, 0, + 0, 0, 0, 0, 0] + alphas = [1.0, 1.0, 1.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.0, 1.0] + for i in xrange(1): + if len(labels[i]) == 0: + self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) + else: + self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) + self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) + self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) + + self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) + + self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) + self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", @@ -81,7 +106,7 @@ class top_block(gr.top_block, Qt.QWidget): ################################################## # Connections ################################################## - self.connect((self.blks2_tcp_source_0, 0), (self.osmosdr_sink_0, 0)) + self.connect((self.blks2_tcp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) def closeEvent(self, event): self.settings = Qt.QSettings("GNU Radio", "top_block") @@ -93,7 +118,7 @@ class top_block(gr.top_block, Qt.QWidget): def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate - self.osmosdr_sink_0.set_sample_rate(self.samp_rate) + self.qtgui_waterfall_sink_x_0.set_frequency_range(0, self.samp_rate) if __name__ == '__main__':