This commit is contained in:
gym487 2017-04-23 03:36:31 +08:00
parent 58048e9a8a
commit a66b2009b4
4 changed files with 279 additions and 24 deletions

View File

@ -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");

View File

@ -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;
}

231
tcp.grc
View File

@ -187,7 +187,7 @@
</param>
<param>
<key>if_gain0</key>
<value>40</value>
<value>20</value>
</param>
<param>
<key>gain0</key>
@ -1071,11 +1071,11 @@
</param>
<param>
<key>args</key>
<value>hackrf</value>
<value>hackrf=81320f</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
@ -1174,10 +1174,235 @@
<value></value>
</param>
</block>
<block>
<key>qtgui_waterfall_sink_x</key>
<param>
<key>bw</key>
<value>samp_rate</value>
</param>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>fc</key>
<value>0</value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>1</value>
</param>
<param>
<key>fftsize</key>
<value>1024</value>
</param>
<param>
<key>_coordinate</key>
<value>(576, 392)</value>
</param>
<param>
<key>gui_hint</key>
<value></value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>grid</key>
<value>False</value>
</param>
<param>
<key>id</key>
<value>qtgui_waterfall_sink_x_0</value>
</param>
<param>
<key>int_max</key>
<value>10</value>
</param>
<param>
<key>int_min</key>
<value>-140</value>
</param>
<param>
<key>legend</key>
<value>True</value>
</param>
<param>
<key>alpha1</key>
<value>1.0</value>
</param>
<param>
<key>color1</key>
<value>0</value>
</param>
<param>
<key>label1</key>
<value></value>
</param>
<param>
<key>alpha10</key>
<value>1.0</value>
</param>
<param>
<key>color10</key>
<value>0</value>
</param>
<param>
<key>label10</key>
<value></value>
</param>
<param>
<key>alpha2</key>
<value>1.0</value>
</param>
<param>
<key>color2</key>
<value>0</value>
</param>
<param>
<key>label2</key>
<value></value>
</param>
<param>
<key>alpha3</key>
<value>1.0</value>
</param>
<param>
<key>color3</key>
<value>0</value>
</param>
<param>
<key>label3</key>
<value></value>
</param>
<param>
<key>alpha4</key>
<value>1.0</value>
</param>
<param>
<key>color4</key>
<value>0</value>
</param>
<param>
<key>label4</key>
<value></value>
</param>
<param>
<key>alpha5</key>
<value>1.0</value>
</param>
<param>
<key>color5</key>
<value>0</value>
</param>
<param>
<key>label5</key>
<value></value>
</param>
<param>
<key>alpha6</key>
<value>1.0</value>
</param>
<param>
<key>color6</key>
<value>0</value>
</param>
<param>
<key>label6</key>
<value></value>
</param>
<param>
<key>alpha7</key>
<value>1.0</value>
</param>
<param>
<key>color7</key>
<value>0</value>
</param>
<param>
<key>label7</key>
<value></value>
</param>
<param>
<key>alpha8</key>
<value>1.0</value>
</param>
<param>
<key>color8</key>
<value>0</value>
</param>
<param>
<key>label8</key>
<value></value>
</param>
<param>
<key>alpha9</key>
<value>1.0</value>
</param>
<param>
<key>color9</key>
<value>0</value>
</param>
<param>
<key>label9</key>
<value></value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>name</key>
<value>""</value>
</param>
<param>
<key>nconnections</key>
<value>1</value>
</param>
<param>
<key>showports</key>
<value>True</value>
</param>
<param>
<key>freqhalf</key>
<value>True</value>
</param>
<param>
<key>type</key>
<value>complex</value>
</param>
<param>
<key>update_time</key>
<value>0.10</value>
</param>
<param>
<key>wintype</key>
<value>firdes.WIN_BLACKMAN_hARRIS</value>
</param>
</block>
<connection>
<source_block_id>blks2_tcp_source_0</source_block_id>
<sink_block_id>osmosdr_sink_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>blks2_tcp_source_0</source_block_id>
<sink_block_id>qtgui_waterfall_sink_x_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
</flow_graph>

View File

@ -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__':