Merge branch 'dr-ota' of github.com:drowe67/pirip into dr-ota

dr-ota
drowe67 2021-10-27 07:24:43 +10:30 committed by David Rowe
commit 63c7d2504c
5 changed files with 23 additions and 39 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 --
;;
@ -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)

View File

@ -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=1000

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: