Merge branch 'dr-ota'

master
drowe67 2021-10-27 07:26:46 +10:30 committed by David Rowe
commit 1a2ff2cf2d
5 changed files with 35 additions and 50 deletions

View File

@ -69,7 +69,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
```
@ -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

View File

@ -1,14 +1,8 @@
#!/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
RS=1000
DATA_BITS_PER_FRAME=256
CODE=H_${DATA_BITS_PER_FRAME}_512_4
TR_SWITCH_GPIO=21
@ -17,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
@ -26,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}
}
@ -39,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 --
;;
@ -61,7 +55,11 @@ case "$1" in
rm ${PIDFILE}
exit 1
fi
tx_burst_rpitx $2
num_bursts=1
if [ "$#" -eq 2 ]; then
num_bursts=$2
fi
tx_burst_rpitx $num_bursts
stop_service
;;
stop)

View File

@ -1,15 +1,10 @@
#!/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
RS=1000
TONE1=1000
DATA_BITS_PER_FRAME=256
CODE=H_${DATA_BITS_PER_FRAME}_512_4
PIRIP_PATH=${PWD}/..
@ -19,9 +14,9 @@ PIDFILE2=/var/run/${NAME}2.pid
LOGFILE=/var/log/${NAME}.log
PATH=${PIRIP_PATH}/tx:${PIRIP_PATH}/librtlsdr/build_rtlsdr/src:${PATH}
PATH=${PIRIP_PATH}/codec2/build_linux/misc:${PIRIP_PATH}/codec2/build_linux/src:${PATH}
PAUSE="${PAUSE:-10}"
GAIN="${GAIN:-49}"
HACKRF_TX_GAIN="${HACKRF_TX_GAIN:-40}"
PAUSE="${PAUSE:-5}"
GAIN="${GAIN:-40}"
HACKRF_TX_GAIN="${HACKRF_TX_GAIN:-47}"
function tx_burst_hackrf {
num_bursts=$1
@ -29,27 +24,27 @@ function tx_burst_hackrf {
tmp=$(mktemp)
if [ -z ${verbose+x} ]; then
# quiet version
freedv_data_raw_tx --source 0x1 -c --testframes 3 --burst 1 --Fs 100000 --Rs ${RS} --tone1 ${RS} --shift ${RS} -a 30000 FSK_LDPC /dev/zero - 2>/dev/null | tlininterp - - 40 -d -f > ${tmp}
freedv_data_raw_tx --source 0x1 -c --testframes 3 --burst 1 --Fs 100000 --Rs ${RS} --tone1 ${TONE1} --shift ${RS} -a 30000 FSK_LDPC /dev/zero - 2>/dev/null | tlininterp - - 40 -d -f > ${tmp}
for (( i=1; i<=$num_bursts; i++ ))
do
printf "%d Tx burst %d from HackRF...\n" `date +%s` ${i} 1>&2
hackrf_transfer -t ${tmp} -s 4E6 -f 143.5E6 -x ${HACKRF_TX_GAIN} 2>/dev/null 1>/dev/null
hackrf_transfer -t ${tmp} -s 4E6 -f 143.5E6 -x ${HACKRF_TX_GAIN} -a 1 2>/dev/null 1>/dev/null
sleep $pause_between_bursts
done
else
# verbose version
freedv_data_raw_tx --source 0x1 -c --testframes 3 --burst 1 --Fs 100000 --Rs ${RS} --tone1 ${RS} --shift ${RS} -a 30000 FSK_LDPC /dev/zero - | tlininterp - - 40 -d -f > ${tmp}
freedv_data_raw_tx --source 0x1 -c --testframes 3 --burst 1 --Fs 100000 --Rs ${RS} --tone1 ${TONE1} --shift ${RS} -a 30000 FSK_LDPC /dev/zero - | tlininterp - - 40 -d -f > ${tmp}
for (( i=1; i<=$num_bursts; i++ ))
do
printf "%d Tx burst %d from HackRF...\n" `date +%s` ${i} 1>&2
hackrf_transfer -t ${tmp} -s 4E6 -f 143.5E6 -x ${HACKRF_TX_GAIN}
hackrf_transfer -t ${tmp} -s 4E6 -f 143.5E6 -x ${HACKRF_TX_GAIN} -a 1
sleep $pause_between_bursts
done
fi
}
function start_rx {
rtl_fsk -g ${GAIN} -f 144490000 - -a 200000 -r 10000 --code H_256_512_4 --mask 10000 -L $1 > /dev/null &
rtl_fsk -g ${GAIN} -f 144490000 - -a 40000 -r ${RS} --code H_256_512_4 -L $1 -u localhost > /dev/null &
echo $!>${PIDFILE2}
}
@ -99,9 +94,9 @@ case "$1" in
;;
start_carrier)
# Send carrier from HackRF at same Tx power as FSK signal, much easier to measure on a spec-an
fsk_get_test_bits - 60000 | fsk_mod -t -c -a 30000 2 40000 1000 1000 2000 - - | \
fsk_get_test_bits - 60000 | fsk_mod -t -c -a 60000 2 40000 1000 1000 2000 - - | \
tlininterp - - 100 -d -f | \
hackrf_transfer -t - -s 4E6 -f 143.5E6 -x ${HACKRF_TX_GAIN}
hackrf_transfer -t - -s 4E6 -f 143.5E6 -x ${HACKRF_TX_GAIN} -a 1
;;
stop)
stop_service

View File

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

View File

@ -510,28 +510,18 @@ 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");
}
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 +530,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: