From ccaca7a604c812e4fb76eaf9fe24027e990f5d62 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 19 Sep 2021 16:08:07 +0930 Subject: [PATCH 1/6] typos, removed some TODOs, default number of bursts for frame repeater ping test --- README.md | 2 +- script/frame_repeater | 16 +++++++--------- script/ping | 8 +------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 77109f6..e11409f 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Service scripts have been written to wrap up the complex command lines. ## Service command lines -1. Loopback test is a good start, this checks each terminal is working stand alone. These tests send a burst from the Termnals Tx to it's Rx: +1. Loopback test is a good start, this checks each terminal is working stand alone. These tests send a burst from the Terminals Tx to it's Rx: ``` laptop$ sudo ./ping start_loopback ``` diff --git a/script/frame_repeater b/script/frame_repeater index 63b4ede..0a07864 100755 --- a/script/frame_repeater +++ b/script/frame_repeater @@ -1,11 +1,5 @@ #!/bin/bash -# frame repeater service - -# TODO -# [X] way to send stderr to log file -# [ ] way to set freq at start up -# [ ] way to set Rs and M at start up -# [ ] way to start as frame repeater or beacon +# Frame repeater service, runs on the Pi TERM_ADDR=0x2 RS=10000 @@ -60,8 +54,12 @@ case "$1" in echo "rtl_fsk failed to start!" rm ${PIDFILE} exit 1 - fi - tx_burst_rpitx $2 + fi + num_bursts=1 + if [ "$#" -eq 2 ]; then + num_bursts=$2 + fi + tx_burst_rpitx $num_bursts stop_service ;; stop) diff --git a/script/ping b/script/ping index 274b2b6..3ce51cc 100755 --- a/script/ping +++ b/script/ping @@ -1,12 +1,6 @@ #!/bin/bash # ping service script - sends bursts to the frame repeater and logs reply - -# TODO -# [X] receive it's own packets -# [X] log one one logfile -# [X] clean start up and shut down -# [X] send a sequence of packets -# [X] test with Pi running frame_repeater OTC +# Runs on a Host laptop with HackRF Tx and RTLSDR Rx TERM_ADDR=0x1 RS=10000 From e46605b21e926b38acd7da096a17737b2e874232 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 19 Sep 2021 16:35:48 +0930 Subject: [PATCH 2/6] README typo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 046cdd7..ad62b50 100644 --- a/README.md +++ b/README.md @@ -84,9 +84,9 @@ Service scripts have been written to wrap up the complex command lines. ``` Then start the Terminal 1 `ping` service: ``` - laptop$ sudo ./ping start_loopback 6 + laptop$ sudo ./ping start 6 ``` - ... will send 6 packets, 10 seconds apart (a 1 minute total run time). Look at /var/log/ping for results. + ... will send 6 packets, 10 seconds apart (a 1 minute total run time). Look at `/var/log/ping` for results. # Useful Command Lines From 0c169adcf73f258c8ecf6c034187f1b71df7e42b Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 6 Oct 2021 08:53:38 +1030 Subject: [PATCH 3/6] switch GPIO when sending test signals --- tx/rpitx_fsk.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tx/rpitx_fsk.cpp b/tx/rpitx_fsk.cpp index 809b98a..260b243 100644 --- a/tx/rpitx_fsk.cpp +++ b/tx/rpitx_fsk.cpp @@ -514,6 +514,7 @@ int main(int argc, char **argv) int count = 0; int cycles = 0; float VCOfreqHz = 0; + if (*ant_switch_gpio_path) sys_gpio(ant_switch_gpio_path, "1"); fmmod->clkgpio::enableclk(4); while(running) { //fmmod->SetFrequencySamples(&VCOfreqHz,1); @@ -527,11 +528,13 @@ int main(int argc, char **argv) fprintf(stderr,"\rcycles: %d", ++cycles); } } + if (*ant_switch_gpio_path) sys_gpio(ant_switch_gpio_path, "0"); } if (one_zero_test) { fprintf(stderr, "...010101... test mode, Ctrl-C to exit\n"); float VCOfreqHz = 0; + if (*ant_switch_gpio_path) sys_gpio(ant_switch_gpio_path, "1"); fmmod->clkgpio::enableclk(4); while(running) { if (VCOfreqHz == shiftHz) @@ -540,6 +543,7 @@ int main(int argc, char **argv) VCOfreqHz = shiftHz; while (SetFrequencySampleNonBlocking(fmmod, VCOfreqHz)) usleep(100); } + if (*ant_switch_gpio_path) sys_gpio(ant_switch_gpio_path, "0"); } finished: From d4f4c335af4084de702591fd2e016454d727b57c Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 27 Oct 2021 07:06:51 +1030 Subject: [PATCH 4/6] temporary work around for FSK demod strong/weak signal issue --- tx/frame_repeater.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tx/frame_repeater.c b/tx/frame_repeater.c index ae5a4d1..cf28a36 100644 --- a/tx/frame_repeater.c +++ b/tx/frame_repeater.c @@ -88,6 +88,7 @@ int main(int argc, char *argv[]) { if (!(rx_status & FREEDV_RX_SYNC)) { /* We've lost RX_SYNC so receive burst finished. So now we can Tx the frames we have buffered */ fprintf(stderr, "frame_repeater: Sending received %d frame burst of %d bytes\n", nframes, bytes_in); + sleep(1); bytes_out = 0; burst_control = 1; while(bytes_out != bytes_in) { fwrite(&burst_control, sizeof(uint8_t), 1, stdout); From be01b01d3644b1b288e6c21fe1d1dc28d57d3493 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 27 Oct 2021 07:07:46 +1030 Subject: [PATCH 5/6] continuous carrier test mode, more useful for setting levels --- tx/rpitx_fsk.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/tx/rpitx_fsk.cpp b/tx/rpitx_fsk.cpp index 260b243..7510634 100644 --- a/tx/rpitx_fsk.cpp +++ b/tx/rpitx_fsk.cpp @@ -510,24 +510,11 @@ int main(int argc, char **argv) } if (carrier_test) { - fprintf(stderr, "Carrier test mode 1 sec on/off , Ctrl-C to exit\n"); - int count = 0; - int cycles = 0; + fprintf(stderr, "Carrier test mode, Ctrl-C to exit\n"); float VCOfreqHz = 0; if (*ant_switch_gpio_path) sys_gpio(ant_switch_gpio_path, "1"); fmmod->clkgpio::enableclk(4); - while(running) { - //fmmod->SetFrequencySamples(&VCOfreqHz,1); - while (SetFrequencySampleNonBlocking(fmmod, VCOfreqHz)) usleep(100); - count++; - if (count == SymbolRate) - fmmod->clkgpio::disableclk(4); - if (count == 2*SymbolRate) { - fmmod->clkgpio::enableclk(4); - count = 0; - fprintf(stderr,"\rcycles: %d", ++cycles); - } - } + while(running) usleep(1000); if (*ant_switch_gpio_path) sys_gpio(ant_switch_gpio_path, "0"); } From a467f51fe983e0605b620c2bb020b5d300c39d3a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 27 Oct 2021 07:08:52 +1030 Subject: [PATCH 6/6] Fs=40000 Rs=1000 -g 40 for M9 OTA physical layer tests (blog post 5) --- script/frame_repeater | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/script/frame_repeater b/script/frame_repeater index 0a07864..5a70793 100755 --- a/script/frame_repeater +++ b/script/frame_repeater @@ -2,7 +2,7 @@ # Frame repeater service, runs on the Pi TERM_ADDR=0x2 -RS=10000 +RS=1000 DATA_BITS_PER_FRAME=256 CODE=H_${DATA_BITS_PER_FRAME}_512_4 TR_SWITCH_GPIO=21 @@ -11,7 +11,7 @@ NAME=frame_repeater PIDFILE=/var/run/${NAME}.pid LOGFILE=/var/log/${NAME}.log PATH=${PIRIP_PATH}/tx:${PIRIP_PATH}/librtlsdr/build_rtlsdr/src:${PATH} -GAIN="${GAIN:-49}" +GAIN="${GAIN:-40}" function tx_burst_rpitx { num_bursts=$1 @@ -20,7 +20,7 @@ function tx_burst_rpitx { } function start_rx { - rtl_fsk -g ${GAIN} -f 144490000 - -a 200000 -r ${RS} --code H_256_512_4 --mask ${RS} -L $1 > /dev/null & + rtl_fsk -g ${GAIN} -f 144490000 - -a 40000 -r ${RS} --code H_256_512_4 -L $1 > /dev/null & echo $!>${PIDFILE} } @@ -33,14 +33,14 @@ function stop_service { case "$1" in start) - ( rtl_fsk -g 49 -f 144490000 - -a 200000 -r ${RS} --code ${CODE} --mask ${RS} --filter ${TERM_ADDR} -q -b | \ + ( rtl_fsk -g ${GAIN} -f 144490000 - -a 40000 -r ${RS} --code ${CODE} --filter ${TERM_ADDR} -q -b | \ frame_repeater ${DATA_BITS_PER_FRAME} ${TERM_ADDR} | \ rpitx_fsk - --code ${CODE} -r ${RS} -s ${RS} -g ${TR_SWITCH_GPIO} --packed -- ) >>${LOGFILE} 2>&1 & echo $!>${PIDFILE} ;; start_verbose) # run in the foreground and log to stderr instead of a logfile - rtl_fsk -g 49 -f 144490000 - -a 200000 -r ${RS} --code ${CODE} --mask ${RS} --filter ${TERM_ADDR} -q -b -v | \ + rtl_fsk -g ${GAIN} -f 144490000 - -a 40000 -r ${RS} --code ${CODE} --filter ${TERM_ADDR} -q -b -v | \ frame_repeater ${DATA_BITS_PER_FRAME} ${TERM_ADDR} | \ rpitx_fsk - --code ${CODE} -r ${RS} -s ${RS} -g ${TR_SWITCH_GPIO} --packed -- ;;