Skip to content

Commit

Permalink
merge to upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
gym committed Jan 12, 2022
1 parent 986ebf0 commit 243ec72
Show file tree
Hide file tree
Showing 17 changed files with 1,950 additions and 550 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ gps-sdr-sim-lut

# Temporary files
*.swp

*~
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down Expand Up @@ -177,3 +178,10 @@ dmypy.json

# Cython debug symbols
cython_debug/


# Netbeans project folder
nbproject/*

# Last used USER_MOTION_SIZE variable
.user-motion-size
28 changes: 26 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,40 @@ all: gps-sdr-sim

SHELL=/bin/bash
CC=gcc
CFLAGS=-O3 -Wall
LDFLAGS=-lm -lpthread
CFLAGS=-O3 -Wall -D_FILE_OFFSET_BITS=64
ifdef USER_MOTION_SIZE
CFLAGS+=-DUSER_MOTION_SIZE=$(USER_MOTION_SIZE)
endif


gps-sdr-sim: gpssim.o
${CC} $< ${LDFLAGS} -o $@

gpssim.o: .user-motion-size gpssim.h

.user-motion-size: .FORCE
@if [ -f .user-motion-size ]; then \
if [ "`cat .user-motion-size`" != "$(USER_MOTION_SIZE)" ]; then \
echo "Updating .user-motion-size"; \
echo "$(USER_MOTION_SIZE)" >| .user-motion-size; \
fi; \
else \
echo "$(USER_MOTION_SIZE)" > .user-motion-size; \
fi;

clean:
rm -f gpssim.o gps-sdr-sim *.bin
rm -f gpssim.o gps-sdr-sim *.bin .user-motion-size

time: gps-sdr-sim
time ./gps-sdr-sim -e brdc3540.14n -u circle.csv -b 1
time ./gps-sdr-sim -e brdc3540.14n -u circle.csv -b 8
time ./gps-sdr-sim -e brdc3540.14n -u circle.csv -b 16

.FORCE:

YEAR?=$(shell date +"%Y")
Y=$(patsubst 20%,%,$(YEAR))
%.$(Y)n:
wget -q ftp://cddis.gsfc.nasa.gov/gnss/data/daily/$(YEAR)/brdc/$@.Z -O $@.Z
uncompress $@.Z
76 changes: 59 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

GPS-SDR-SIM generates GPS baseband signal data streams, which can be converted
to RF using software-defined radio (SDR) platforms, such as
[bladeRF](http://nuand.com/), [HackRF](https://github.com/mossmann/hackrf/wiki), and [USRP](http://www.ettus.com/).
[ADALM-Pluto](https://wiki.analog.com/university/tools/pluto), [bladeRF](http://nuand.com/), [HackRF](https://github.com/mossmann/hackrf/wiki), and [USRP](http://www.ettus.com/).

### Windows build instructions

Expand All @@ -18,6 +18,7 @@ to RF using software-defined radio (SDR) platforms, such as
$ gcc gpssim.c -lm -lpthread -O3 -o gps-sdr-sim
```


### Realtime by Gnuradio

Use -n option can connect to a TCP source in Gnuradio for realtime simulation.
Expand All @@ -36,19 +37,32 @@ cd into /mapserver, and run
python mapper.py
```

Then visit http://127.0.0.1:8080/static/baidumap.html to use the baidu Online map.
Then visit http://127.0.0.1:8080/static/baidumap.html to use the Online map.

You can write an map which can POST data to http://127.0.0.1:8080/post like this

```
lon=116&lat=39&hgt=10
```



Actually I don't want to use BaiduMap.. But because of the GFW, I can't access Google..
### Using bigger user motion files

You can write an map which can POST data to http://127.0.0.1:8080/post like this
In order to use user motion files with more than 30000 samples (at 10Hz), the `USER_MOTION_SIZE`
variable can be set to the maximum time of the user motion file in seconds. It is advisable to do
this using make so gps-sdr-bin can update the size when needed. e.g:

```
lon=116&lat=39&hgt=10
$ make USER_MOTION_SIZE=4000
```

This variable can also be set when compiling directly with GCC:

```
$ gcc gpssim.c -lm -O3 -o gps-sdr-sim -DUSER_MOTION_SIZE=4000
```

to replace Baidumap.

### Generating the GPS signal file

Expand All @@ -58,20 +72,20 @@ The sampling rate of the user motion has to be 10Hz.
The user is also able to assign a static location directly through the command line.

The user specifies the GPS satellite constellation through a GPS broadcast
ephemeris file. The daily GPS broadcast ephemers file (brdc) is a merge of the
individual site navigation files into one. The archive for the daily file is:

[ftp://cddis.gsfc.nasa.gov/gnss/data/daily/](ftp://cddis.gsfc.nasa.gov/gnss/data/daily/)
ephemeris file. The daily GPS broadcast ephemeris file (brdc) is a merge of the
individual site navigation files into one. The archive for the daily file can
be downloaded from: https://cddis.nasa.gov/archive/gnss/data/daily/. Access
to this site requires registration, which is free.

These files are then used to generate the simulated pseudorange and
Doppler for the GPS satellites in view. This simulated range data is
then used to generate the digitized I/Q samples for the GPS signal.

The bladeRF command line interface requires I/Q pairs stored as signed
The bladeRF and ADALM-Pluto command line interface requires I/Q pairs stored as signed
16-bit integers, while the hackrf_transfer and gps-sdr-sim-uhd.py
support signed bytes.

HackRF and bladeRF require 2.6 MHz sample rate, while the USRP2 requires
HackRF, bladeRF and ADALM-Pluto require 2.6 MHz sample rate, while the USRP2 requires
2.5 MHz (an even integral decimator of 100 MHz).

The simulation start time can be specified if the corresponding set of ephemerides
Expand All @@ -92,11 +106,12 @@ Options:
-e <gps_nav> RINEX navigation file for GPS ephemerides (required)
-u <user_motion> User motion file (dynamic mode)
-g <nmea_gga> NMEA GGA stream (dynamic mode)
-c <location> ECEF X,Y,Z in meters (static mode) e.g. 3967283.15,1022538.18,4872414.48
-l <location> Lat,Lon,Hgt (static mode) e.g. 30.286502,120.032669,100
-t <date,time> Scenario start time YYYY/MM/DD,hh:mm:ss
-T <date,time> Overwrite TOC and TOE to scenario start time
-d <duration> Duration [sec] (dynamic mode max: 300 static mode max: 86400)
-o <output> I/Q sampling data file (default: gpssim.bin)
-o <output> I/Q sampling data file (default: gpssim.bin ; use - for stdout)
-s <frequency> Sampling frequency [Hz] (default: 2600000)
-b <iq_bits> I/Q data format [1/8/16] (default: 16)
-i Disable ionospheric delay for spacecraft scenario
Expand Down Expand Up @@ -130,6 +145,8 @@ Use Gnuradio to realtime simulate 3000s:
The TX port of a particular SDR platform is connected to the GPS receiver
under test through a DC block and a fixed 50-60dB attenuator.

#### BladeRF:

The simulated GPS signal file, named "gpssim.bin", can be loaded
into the bladeRF for playback as shown below:

Expand All @@ -145,25 +162,50 @@ tx start
```

You can also execute these commands via the `bladeRF-cli` script option as below:

```
> bladeRF-cli -s bladerf.script
```

For the HackRF:
#### HackRF:

```
> hackrf_transfer -t gpssim.bin -f 1575420000 -s 2600000 -a 1 -x 0
```

For UHD supported devices (tested with USRP2 only):
#### UHD supported devices (tested with USRP2 only):

```
> gps-sdr-sim-uhd.py -t gpssim.bin -s 2500000 -x 0
```

#### LimeSDR (in case of 1 Msps 1-bit file, to get full BaseBand dynamic and low RF power):

```
> limeplayer -s 1000000 -b 1 -d 2047 -g 0.1 < ../circle.1b.1M.bin
```

#### ADALM-Pluto (PlutoSDR):

The ADALM-Pluto device is expected to have its network interface up and running and is accessible
via "pluto.local" by default.

Default settings:
```
> plutoplayer -t gpssim.bin
```
Set TX attenuation:
```
> plutoplayer -t gpssim.bin -a -30.0
```
Default -20.0dB. Applicable range 0.0dB to -80.0dB in 0.25dB steps.

Set RF bandwidth:
```
> plutoplayer -t gpssim.bin -b 3.0
```
Default 3.0MHz. Applicable range 1.0MHz to 5.0MHz.

### License

Copyright &copy; 2015 Takuji Ebinuma
Copyright &copy; 2015-2018 Takuji Ebinuma
Distributed under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
28 changes: 17 additions & 11 deletions gps-sdr-sim-uhd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# a small script to transmit simulated GPS samples via UHD
# (C) 2015 by Harald Welte <[email protected]>
# Licensed under the MIT License (see LICENSE)
Expand All @@ -20,16 +20,11 @@ def __init__(self, options):
##################################################
# Blocks
##################################################
self.uhd_usrp_sink = uhd.usrp_sink(
",".join(("", "")),
uhd.stream_args(
cpu_format="fc32",
channels=range(1),
),
)
self.uhd_usrp_sink = uhd.usrp_sink(options.args, uhd.stream_args(cpu_format="fc32"))
self.uhd_usrp_sink.set_samp_rate(options.sample_rate)
self.uhd_usrp_sink.set_center_freq(options.frequency, 0)
self.uhd_usrp_sink.set_gain(options.gain, 0)
self.uhd_usrp_sink.set_clock_source(options.clock_source)

if options.bits == 16:
# a file source for the file generated by the gps-sdr-sim
Expand All @@ -55,7 +50,13 @@ def __init__(self, options):
self.connect((self.blocks_file_source, 0), (self.blocks_char_to_short, 0))
self.connect((self.blocks_char_to_short, 0), (self.blocks_interleaved_short_to_complex, 0))

self.connect((self.blocks_interleaved_short_to_complex, 0), (self.uhd_usrp_sink, 0))
# scale complex values to within +/- 1.0 so don't overflow USRP DAC
# scale of 1.0/2**11 will scale it to +/- 0.5
self.blocks_multiply_const = blocks.multiply_const_vcc((1.0/2**11, ))

# establish the connections
self.connect((self.blocks_interleaved_short_to_complex, 0), (self.blocks_multiply_const, 0))
self.connect((self.blocks_multiply_const, 0), (self.uhd_usrp_sink, 0))

def get_options():
parser = OptionParser(option_class=eng_option)
Expand All @@ -71,18 +72,23 @@ def get_options():
help="set output file name [default=gpssim.bin]")
parser.add_option("-b", "--bits", type="eng_float", default=16,
help="set size of every sample [default=16]")
parser.add_option("-a", "--args", type="string", default="",
help="set UHD arguments [default='']")
parser.add_option("-c", "--clock_source", type="string", default="internal",
help="set clock source [default='internal']")


(options, args) = parser.parse_args()
if len(args) != 0:
parser.print_help()
raise SystemExit, 1
raise SystemExit(1)

return (options)

if __name__ == '__main__':
(options) = get_options()
tb = top_block(options)
tb.start()
raw_input('Press Enter to quit: ')
input('Press Enter to quit: ')
tb.stop()
tb.wait()
Loading

0 comments on commit 243ec72

Please sign in to comment.