kopia lustrzana https://github.com/F5OEO/rpitx
Porównaj commity
12 Commity
cce1fe6acf
...
1f8e80dfa5
Autor | SHA1 | Data |
---|---|---|
F5OEO | 1f8e80dfa5 | |
F5OEO | b60ca7e4db | |
F5OEO | a39734c843 | |
F5OEO | 39c8d9ade5 | |
Eric Urban | ccebd4daf5 | |
Alberto Morato | aaefebc8ee | |
Alberto Morato | 5fce7fc94a | |
Kristijan Gjoshev | d86308ec0d | |
IgrikXD | e418726190 | |
IgrikXD | fd710a24cb | |
IgrikXD | 91a6aa6933 | |
IgrikXD | 1c4b4a3bf6 |
200
easytest.sh
200
easytest.sh
|
@ -1,13 +1,78 @@
|
|||
#!/bin/sh
|
||||
abort_action=0
|
||||
|
||||
status="0"
|
||||
OUTPUT_FREQ=434.0
|
||||
DEFAUL_JPG_PICTURE_LOC=src/resources/SAMPLE_IMAGE.jpg
|
||||
DEFAULT_WAV_FILE_MONO_LOC=src/resources/SAMPLE_MONO_AUDIO.wav
|
||||
DEFAULT_WAV_FILE_STEREO_LOC=src/resources/SAMPLE_STEREO_AUDIO.wav
|
||||
DEFAULT_RF_FREEDV_FILE_LOC=src/resources/SAMPLE_FREEDV.rf
|
||||
DEFAULT_POCSAG_MESSAGE="1:YOURCALL\n2: Hello world"
|
||||
DEFAULT_OPERA_CALLSIGN="F5OEO"
|
||||
DEFAULT_RTTY_MESSAGE="HELLO WORLD FROM RPITX"
|
||||
LAST_ITEM="0 Tune"
|
||||
|
||||
do_check_file_existance()
|
||||
{
|
||||
|
||||
readlink -e $1 > /dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
whiptail --title "Error!" --msgbox "The file does not exist!" 8 78
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
do_freq_setup()
|
||||
{
|
||||
|
||||
if FREQ=$(whiptail --inputbox "Choose output Frequency (in MHz) Default is 434 MHz" 8 78 $OUTPUT_FREQ --title "Rpitx transmit Frequency" 3>&1 1>&2 2>&3); then
|
||||
OUTPUT_FREQ=$FREQ
|
||||
if FREQ=$(whiptail --inputbox "Enter output Frequency (in MHz). Current is $OUTPUT_FREQ MHz" 8 78 $OUTPUT_FREQ --title "Rpitx transmit Frequency" 3>&1 1>&2 2>&3); then
|
||||
OUTPUT_FREQ=$FREQ
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
do_file_choose()
|
||||
{
|
||||
|
||||
LAST_ITEM="$menuchoice"
|
||||
if FILE_LOC=$(whiptail --inputbox "Enter $1 file location. Default is $2" 8 78 $2 --title "Select a file to transmit" 3>&1 1>&2 2>&3); then
|
||||
do_check_file_existance "$FILE_LOC"
|
||||
abort_action=$?
|
||||
else
|
||||
abort_action=1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
do_enter_message()
|
||||
{
|
||||
|
||||
LAST_ITEM="$menuchoice"
|
||||
if MESSAGE=$(whiptail --inputbox "Type custom $1 message:" 8 78 "$2" --title "Enter message to transmit" 3>&1 1>&2 2>&3); then
|
||||
abort_action=0
|
||||
if [ -z "$MESSAGE" ]; then
|
||||
whiptail --title "Error!" --msgbox "Empty message!" 8 78
|
||||
abort_action=1
|
||||
fi
|
||||
else
|
||||
abort_action=1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
do_enter_callsign()
|
||||
{
|
||||
|
||||
LAST_ITEM="$menuchoice"
|
||||
if CALLSIGN=$(whiptail --inputbox "Type callsign:" 8 78 "$DEFAULT_OPERA_CALLSIGN" --title "Enter callsign to transmit" 3>&1 1>&2 2>&3); then
|
||||
abort_action=0
|
||||
if [ -z "$CALLSIGN" ]; then
|
||||
whiptail --title "Error!" --msgbox "Empty callsign!" 8 78
|
||||
abort_action=1
|
||||
fi
|
||||
else
|
||||
abort_action=1
|
||||
fi
|
||||
|
||||
}
|
||||
|
@ -33,7 +98,7 @@ do_stop_transmit()
|
|||
1\ *) sudo killall testvfo.sh >/dev/null 2>/dev/null ;;
|
||||
2\ *) sudo killall testspectrum.sh >/dev/null 2>/dev/null ;;
|
||||
3\ *) sudo killall snap2spectrum.sh >/dev/null 2>/dev/null ;;
|
||||
4\ *) sudo killall testfmrds.sh >/dev/null 2>/dev/null ;;
|
||||
4\ *) sudo killall testfmrds.sh >/dev/null 2>/dev/null ;;
|
||||
5\ *) sudo killall testnfm.sh >/dev/null 2>/dev/null ;;
|
||||
6\ *) sudo killall testssb.sh >/dev/null 2>/dev/null ;;
|
||||
7\ *) sudo killall testam.sh >/dev/null 2>/dev/null ;;
|
||||
|
@ -48,18 +113,21 @@ do_stop_transmit()
|
|||
|
||||
do_status()
|
||||
{
|
||||
LAST_ITEM="$menuchoice"
|
||||
LAST_ITEM="$menuchoice"
|
||||
whiptail --title "Transmit ""$LAST_ITEM"" on ""$OUTPUT_FREQ"" MHz" --msgbox "Transmitting" 8 78
|
||||
do_stop_transmit
|
||||
}
|
||||
|
||||
#********************************
|
||||
# User interface initialization *
|
||||
#********************************
|
||||
|
||||
do_freq_setup
|
||||
|
||||
while [ "$status" -eq 0 ]
|
||||
while [ true ]
|
||||
do
|
||||
|
||||
menuchoice=$(whiptail --default-item "$LAST_ITEM" --title "Rpitx on ""$OUTPUT_FREQ"" MHz" --menu "Range frequency : 50kHz-1GHz. Choose your test" 20 82 12 \
|
||||
menuchoice=$(whiptail --default-item "$LAST_ITEM" --title "Rpitx on ""$OUTPUT_FREQ"" MHz" --menu "Range frequency : 50kHz-1GHz. Choose your test:" 20 82 12 \
|
||||
"F Set frequency" "Modify frequency (actual $OUTPUT_FREQ MHz)" \
|
||||
"0 Tune" "Carrier" \
|
||||
"1 Chirp" "Moving carrier" \
|
||||
|
@ -77,43 +145,99 @@ do_freq_setup
|
|||
3>&2 2>&1 1>&3)
|
||||
RET=$?
|
||||
if [ $RET -eq 1 ]; then
|
||||
whiptail --title "Bye bye" --msgbox "Thx for using rpitx" 8 78
|
||||
exit 0
|
||||
elif [ $RET -eq 0 ]; then
|
||||
case "$menuchoice" in
|
||||
F\ *) do_freq_setup ;;
|
||||
0\ *) "./testvfo.sh" "$OUTPUT_FREQ""e6" >/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
1\ *) "./testchirp.sh" "$OUTPUT_FREQ""e6" >/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
2\ *) "./testspectrum.sh" "$OUTPUT_FREQ""e6" >/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
3\ *) "./snap2spectrum.sh" "$OUTPUT_FREQ""e6" >/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
4\ *) "./testfmrds.sh" "$OUTPUT_FREQ" >/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
5\ *) "./testnfm.sh" "$OUTPUT_FREQ""e3" >/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
6\ *) "./testssb.sh" "$OUTPUT_FREQ""e6" >/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
7\ *) "./testam.sh" "$OUTPUT_FREQ""e3" >/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
8\ *) "./testfreedv.sh" "$OUTPUT_FREQ""e6" >/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
9\ *) "./testsstv.sh" "$OUTPUT_FREQ""e6">/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
10\ *) "./testpocsag.sh" "$OUTPUT_FREQ""e6">/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
11\ *) "./testopera.sh" "$OUTPUT_FREQ""e6">/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
12\ *) "./testrtty.sh" "$OUTPUT_FREQ""e6">/dev/null 2>/dev/null &
|
||||
do_status;;
|
||||
*) status=1
|
||||
whiptail --title "Bye bye" --msgbox "Thx for using rpitx" 8 78
|
||||
|
||||
F\ *) do_freq_setup
|
||||
;;
|
||||
|
||||
0\ *) "./testvfo.sh" "$OUTPUT_FREQ""e6" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
;;
|
||||
|
||||
1\ *) "./testchirp.sh" "$OUTPUT_FREQ""e6" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
;;
|
||||
|
||||
2\ *) do_file_choose "320x256 .jpg" "$DEFAUL_JPG_PICTURE_LOC"
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testspectrum.sh" "$OUTPUT_FREQ""e6" "$FILE_LOC" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
3\ *) "./snap2spectrum.sh" "$OUTPUT_FREQ""e6" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
;;
|
||||
|
||||
4\ *) do_file_choose ".wav" "$DEFAULT_WAV_FILE_STEREO_LOC"
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testfmrds.sh" "$OUTPUT_FREQ" "$FILE_LOC" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
5\ *) do_file_choose ".wav (16 bit per sample, 48000 sample rate, mono)" "$DEFAULT_WAV_FILE_MONO_LOC"
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testnfm.sh" "$OUTPUT_FREQ""e3" "$FILE_LOC" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
6\ *) do_file_choose ".wav (16 bit per sample, 48000 sample rate, mono)" "$DEFAULT_WAV_FILE_MONO_LOC"
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testssb.sh" "$OUTPUT_FREQ""e6" "$FILE_LOC" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
7\ *) do_file_choose ".wav (16 bit per sample, 48000 sample rate, mono)" "$DEFAULT_WAV_FILE_MONO_LOC"
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testam.sh" "$OUTPUT_FREQ""e3" "$FILE_LOC" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
8\ *) do_file_choose "FreeDV .rf" "$DEFAULT_RF_FREEDV_FILE_LOC"
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testfreedv.sh" "$OUTPUT_FREQ""e6" "$FILE_LOC" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
9\ *) do_file_choose "320x256 .jpg" "$DEFAUL_JPG_PICTURE_LOC"
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testsstv.sh" "$OUTPUT_FREQ""e6" "$FILE_LOC" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
10\ *) do_enter_message "POCSAG (ADDR:MESSAGE_BODY)" "$DEFAULT_POCSAG_MESSAGE"
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testpocsag.sh" "$OUTPUT_FREQ""e6" "$MESSAGE" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
11\ *) do_enter_callsign
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testopera.sh" "$OUTPUT_FREQ""e6" "$CALLSIGN" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
12\ *) do_enter_message "RTTY" "$DEFAULT_RTTY_MESSAGE"
|
||||
if [ $abort_action -eq 0 ]; then
|
||||
"./testrtty.sh" "$OUTPUT_FREQ""e6" "$MESSAGE" >/dev/null 2>/dev/null &
|
||||
do_status
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
|
||||
exit 0
|
25
src/Makefile
25
src/Makefile
|
@ -6,6 +6,7 @@ LDFLAGS ?= -L/opt/vc/lib
|
|||
LDFLAGS += -lrpitx -lm -lrt -lpthread
|
||||
CXX ?= c++
|
||||
CC ?= cc
|
||||
INTSTALL_DIR ?= /usr/local/bin
|
||||
|
||||
CFLAGS_Pissb = -Wall -g -O2 -Wno-unused-variable
|
||||
LDFLAGS_Pissb = $(LDFLAGS) -lsndfile -lliquid
|
||||
|
@ -94,15 +95,15 @@ clean:
|
|||
rm -f ../dvbrf ../sendiq ../pissb ../pisstv ../pifsq ../pifm ../piam ../pidcf77 ../pichirp ../tune ../freedv ../piopera ../spectrumpaint ../pocsag ../pifmrds ../rpitx ../sendook
|
||||
|
||||
install: all
|
||||
install -m 0755 ../pisstv /usr/bin
|
||||
install -m 0755 ../foxhunt /usr/bin
|
||||
install -m 0755 ../pirtty /usr/bin
|
||||
install -m 0755 ../piopera /usr/bin
|
||||
install -m 0755 ../pifsq /usr/bin
|
||||
install -m 0755 ../pichirp /usr/bin
|
||||
install -m 0755 ../sendiq /usr/bin
|
||||
install -m 0755 ../tune /usr/bin
|
||||
install -m 0755 ../freedv /usr/bin
|
||||
install -m 0755 ../rpitx /usr/bin
|
||||
install -m 0755 ../pift8 /usr/bin
|
||||
install -m 0755 ../sendook /usr/bin
|
||||
install -m 0755 ../pisstv $(INSTALL_DIR)
|
||||
install -m 0755 ../foxhunt $(INSTALL_DIR)
|
||||
install -m 0755 ../pirtty $(INSTALL_DIR)
|
||||
install -m 0755 ../piopera $(INSTALL_DIR)
|
||||
install -m 0755 ../pifsq $(INSTALL_DIR)
|
||||
install -m 0755 ../pichirp $(INSTALL_DIR)
|
||||
install -m 0755 ../sendiq $(INSTALL_DIR)
|
||||
install -m 0755 ../tune $(INSTALL_DIR)
|
||||
install -m 0755 ../freedv $(INSTALL_DIR)
|
||||
install -m 0755 ../rpitx $(INSTALL_DIR)
|
||||
install -m 0755 ../pift8 $(INSTALL_DIR)
|
||||
install -m 0755 ../sendook $(INSTALL_DIR)
|
||||
|
|
|
@ -10,6 +10,13 @@
|
|||
|
||||
bool running = true;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double active;
|
||||
uint32_t duration; //nano seconds
|
||||
uint32_t padding;
|
||||
} Bitdata;
|
||||
|
||||
void print_usage(void)
|
||||
{
|
||||
/** Future options :
|
||||
|
@ -26,8 +33,11 @@ Options:\n\
|
|||
-f freq : frequency in Hz (default : 433.92MHz)\n\
|
||||
-0 nb : duration in microsecond of 0 bit (by default : 500us). Use integer only.\n\
|
||||
-1 nb : duration in microsecond of 1 bit (by default : 250us)\n\
|
||||
-g nb : bit gap (by default : 500us)\n\
|
||||
-r nb : repeat nb times the message (default : 3)\n\
|
||||
-p nb : pause between each message (default : 1000us=1ms)\n\
|
||||
-m nb : modulation type 0=OOK, 1=OOK_PWM, 2=OOK_PPM (default : 0=OOK)\n\
|
||||
-i : filemode : read from file\n\
|
||||
\n\
|
||||
\"binary code\":\n\
|
||||
a serie of 0 or 1 char (space allowed and ignored)\n\
|
||||
|
@ -67,10 +77,16 @@ int main(int argc, char *argv[])
|
|||
uint64_t Freq = 433920000;
|
||||
uint64_t bit0duration = 500; // in microsecond
|
||||
uint64_t bit1duration = 500;
|
||||
uint64_t bitgap = 500;
|
||||
int nbrepeat = 3;
|
||||
int pause = 1000; // in us
|
||||
int dryrun = 0; // if 1 : hte message is not really transmitted
|
||||
int modulation = 0; // 0=OOK, 1=OOK_PWM, 2=OOK_PPM
|
||||
char *bits = NULL;
|
||||
int filemode = 0;
|
||||
char *filename = NULL;
|
||||
uint8_t *data = NULL;
|
||||
int size;
|
||||
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
|
@ -81,7 +97,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
while(1)
|
||||
{
|
||||
a = getopt(argc, argv, "f:0:1:r:p:hvd");
|
||||
a = getopt(argc, argv, "f:0:1:g:r:p:m:hvdi");
|
||||
if(a == -1)
|
||||
{
|
||||
if(anyargs) break;
|
||||
|
@ -99,12 +115,18 @@ int main(int argc, char *argv[])
|
|||
case '1': // bit 0 duration
|
||||
bit1duration = atouint32_metric(optarg, "Error with -1 : ");
|
||||
break;
|
||||
case 'g': // bit gap
|
||||
bitgap = atouint32_metric(optarg, "Error with -g : ");
|
||||
break;
|
||||
case 'r':
|
||||
nbrepeat = atoi(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
pause = atoi(optarg);
|
||||
break;
|
||||
case 'm':
|
||||
modulation = atoi(optarg);
|
||||
break;
|
||||
case 'h' :
|
||||
print_usage();
|
||||
exit(0);
|
||||
|
@ -115,6 +137,9 @@ int main(int argc, char *argv[])
|
|||
case 'd': // Dry run
|
||||
dryrun = 1;
|
||||
break;
|
||||
case 'i': // filemode
|
||||
filemode = 1;
|
||||
break;
|
||||
case -1:
|
||||
break;
|
||||
default:
|
||||
|
@ -126,10 +151,26 @@ int main(int argc, char *argv[])
|
|||
if (optind >= argc) {
|
||||
FATAL_ERROR(-2, "Missing bit message.\n");
|
||||
}
|
||||
bits = argv[optind];
|
||||
if (filemode)
|
||||
{
|
||||
filename = argv[optind];
|
||||
}
|
||||
else
|
||||
{
|
||||
bits = argv[optind];
|
||||
}
|
||||
printf("Frequency set to : %" PRIu64 "Hz \n", Freq);
|
||||
printf("Bit duration 0 : %" PRIu64 "us ; 1 : %" PRIu64 "us\n",
|
||||
bit0duration, bit1duration);
|
||||
if(!filemode)
|
||||
{
|
||||
printf("Modulation: %d \n", modulation);
|
||||
printf("Bit duration 0 : %" PRIu64 "us ; 1 : %" PRIu64 "us\n",
|
||||
bit0duration, bit1duration);
|
||||
printf("Bit gap = %" PRIu64 "us \n", bitgap);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Reading data from file %s.\n", filename);
|
||||
}
|
||||
printf("Send message %d times with a pause of %dus\n", nbrepeat, pause);
|
||||
if (dryrun)
|
||||
printf("Dry run mode enabled : no message will be sent\n");
|
||||
|
@ -137,21 +178,54 @@ int main(int argc, char *argv[])
|
|||
// Simplify the message to send
|
||||
int computed_duration = 0; // in us
|
||||
int nbbits = 0;
|
||||
for(size_t i = 0; i < strlen(bits); i++)
|
||||
if(!filemode)
|
||||
{
|
||||
char c = bits[i];
|
||||
if (c == '0')
|
||||
for(size_t i = 0; i < strlen(bits); i++)
|
||||
{
|
||||
nbbits ++;
|
||||
computed_duration += bit0duration;
|
||||
} else if (c == '1')
|
||||
{
|
||||
nbbits ++;
|
||||
computed_duration += bit1duration;
|
||||
char c = bits[i];
|
||||
if (c == '0')
|
||||
{
|
||||
nbbits ++;
|
||||
computed_duration += bit0duration;
|
||||
} else if (c == '1')
|
||||
{
|
||||
nbbits ++;
|
||||
computed_duration += bit1duration;
|
||||
}
|
||||
|
||||
/* OOK_PWM and OOK_PPM requires extra bit */
|
||||
if((modulation == 1) || (modulation == 2))
|
||||
{
|
||||
computed_duration += bitgap;
|
||||
nbbits ++;
|
||||
}
|
||||
// any other char is ignored (it allows to speparate nibble with a space for example)
|
||||
// improvement : allow "." and "-" or "i" and "a" to create a MORSE sender
|
||||
}
|
||||
// any other char is ignored (it allows to speparate nibble with a space for example)
|
||||
// improvement : allow "." and "-" or "i" and "a" to create a MORSE sender
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE *p_file = NULL;
|
||||
p_file = fopen(filename,"rb");
|
||||
if(p_file == NULL)
|
||||
{
|
||||
FATAL_ERROR(-2, "Can't open file %s.\n", filename);
|
||||
}
|
||||
fseek(p_file,0,SEEK_END);
|
||||
size = ftell(p_file);
|
||||
data = (uint8_t *)malloc(size);
|
||||
rewind(p_file);
|
||||
fread(data,sizeof(uint8_t),size,p_file);
|
||||
Bitdata *p_bitdata = (Bitdata *)data;
|
||||
|
||||
nbbits = size/sizeof(Bitdata);
|
||||
for(int i = 0; i < nbbits; i++)
|
||||
{
|
||||
computed_duration += p_bitdata[i].duration/1000; //nano to us
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dbg_printf(1, "Send %d bits, with a total duration of %d us.\n", nbbits, computed_duration);
|
||||
if (computed_duration == 0 || nbbits == 0)
|
||||
{
|
||||
|
@ -165,17 +239,71 @@ int main(int argc, char *argv[])
|
|||
// Prepare the message
|
||||
ookbursttiming ooksender(Freq, computed_duration);
|
||||
ookbursttiming::SampleOOKTiming Message[nbbits];
|
||||
for(size_t i = 0; i < strlen(bits); i++)
|
||||
if(!filemode)
|
||||
{
|
||||
char c = bits[i];
|
||||
if (c == '0')
|
||||
for(size_t i = 0; i < strlen(bits); i++)
|
||||
{
|
||||
Message[i].value = 0;
|
||||
Message[i].duration = bit0duration;
|
||||
} else if (c == '1')
|
||||
char c = bits[i];
|
||||
switch (modulation)
|
||||
{
|
||||
case 0: // OOK:
|
||||
if (c == '0')
|
||||
{
|
||||
Message[i].value = 0;
|
||||
Message[i].duration = bit0duration;
|
||||
|
||||
} else if (c == '1')
|
||||
{
|
||||
Message[i].value = 1;
|
||||
Message[i].duration = bit1duration;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // OOK_PWM:
|
||||
if (c == '0')
|
||||
{
|
||||
Message[i*2].value = 1;
|
||||
Message[i*2].duration = bit0duration;
|
||||
|
||||
} else if (c == '1')
|
||||
{
|
||||
Message[i*2].value = 1;
|
||||
Message[i*2].duration = bit1duration;
|
||||
}
|
||||
Message[(i*2)+1].value = 0;
|
||||
Message[(i*2)+1].duration = bitgap;
|
||||
break;
|
||||
|
||||
case 2: // OOK_PPM:
|
||||
Message[i*2].value = 1;
|
||||
Message[i*2].duration = bitgap;
|
||||
if (c == '0')
|
||||
{
|
||||
Message[(i*2)+1].value = 0;
|
||||
Message[(i*2)+1].duration = bit0duration;
|
||||
|
||||
} else if (c == '1')
|
||||
{
|
||||
Message[(i*2)+1].value = 0;
|
||||
Message[(i*2)+1].duration = bit1duration;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bitdata *p_bitdata = (Bitdata *)data;
|
||||
for(int i = 0; i < nbbits; i++)
|
||||
{
|
||||
Message[i].value = 1;
|
||||
Message[i].duration = bit1duration;
|
||||
Message[i].value = p_bitdata[i].active;
|
||||
Message[i].duration = p_bitdata[i].duration/1000; //nano to us
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,16 +128,16 @@ int fm_mpx_open(char *filename, size_t len) {
|
|||
|
||||
// IIR pre-emphasis filter
|
||||
// Reference material: http://jontio.zapto.org/hda1/preempiir.pdf
|
||||
double tau=75e-6;
|
||||
double delta=1.96e-6;
|
||||
double tau=50e-6; // 50us default pre-emphasis, TODO: make it adjustable for the US to 75us
|
||||
double delta=1/(2*PI*20000); // 20KHz frequency max for the emphasis function
|
||||
double taup, deltap, bp, ap, a0, a1, b1;
|
||||
taup=1.0/(2.0*(in_samplerate*FIR_PHASES))/tan( 1.0/(2*tau*(in_samplerate*FIR_PHASES) ));
|
||||
deltap=1.0/(2.0*(in_samplerate*FIR_PHASES))/tan( 1.0/(2*delta*(in_samplerate*FIR_PHASES) ));
|
||||
bp=sqrt( -taup*taup + sqrt(taup*taup*taup*taup + 8.0*taup*taup*deltap*deltap) ) / 2.0 ;
|
||||
ap=sqrt( 2*bp*bp + taup*taup );
|
||||
a0=( 2.0*ap + 1/(in_samplerate*FIR_PHASES) )/(2.0*bp + 1/(in_samplerate*FIR_PHASES) );
|
||||
a1=(-2.0*ap + 1/(in_samplerate*FIR_PHASES) )/(2.0*bp + 1/(in_samplerate*FIR_PHASES) );
|
||||
b1=( 2.0*bp + 1/(in_samplerate*FIR_PHASES) )/(2.0*bp + 1/(in_samplerate*FIR_PHASES) );
|
||||
a0=( 2.0*ap + 1.0/(in_samplerate*FIR_PHASES) )/(2.0*bp + 1.0/(in_samplerate*FIR_PHASES) );
|
||||
a1=(-2.0*ap + 1.0/(in_samplerate*FIR_PHASES) )/(2.0*bp + 1.0/(in_samplerate*FIR_PHASES) );
|
||||
b1=( 2.0*bp - 1.0/(in_samplerate*FIR_PHASES) )/(2.0*bp + 1.0/(in_samplerate*FIR_PHASES) );
|
||||
double x=0,y=0;
|
||||
|
||||
for(int i=0; i<FIR_TAPS; i++) {
|
||||
|
|
Przed Szerokość: | Wysokość: | Rozmiar: 17 KiB Po Szerokość: | Wysokość: | Rozmiar: 17 KiB |
|
@ -48,7 +48,9 @@ Usage:\nrpitx [-i File Input][-m ModeInput] [-f frequency output] [-s Samplerate
|
|||
-f float frequency to output on GPIO_4 pin 7 in khz : (130 kHz to 750 MHz),\n\
|
||||
-l loop mode for file input\n\
|
||||
-p float frequency correction in parts per million (ppm), positive or negative, for calibration, default 0.\n\
|
||||
-q Use harmonic number n\n\
|
||||
-h help (this help).\n\
|
||||
-s SampleRate input file sample rate (only in IEQ mode) \n\
|
||||
\n",\
|
||||
PROGRAM_VERSION);
|
||||
|
||||
|
@ -87,6 +89,7 @@ int main(int argc, char* argv[])
|
|||
bool loop_mode_flag=false;
|
||||
bool useStdin;
|
||||
int Harmonic=1;
|
||||
char * endptr;
|
||||
while(1)
|
||||
{
|
||||
a = getopt(argc, argv, "i:f:m:s:p:hld:w:c:ra:");
|
||||
|
@ -104,7 +107,11 @@ int main(int argc, char* argv[])
|
|||
FileName = optarg;
|
||||
break;
|
||||
case 'f': // Frequency
|
||||
SetFrequency = atof(optarg)*1e3;
|
||||
SetFrequency = strtof(optarg, &endptr);
|
||||
if (endptr == optarg || SetFrequency <= 0.0f || SetFrequency == HUGE_VALF) {
|
||||
fprintf(stderr, "tune: not a valid frequency - '%s'", optarg)
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'm': // Mode (IQ,IQFLOAT,RF,RFA)
|
||||
if(strcmp("IQ",optarg)==0) Mode=MODE_RPITX_IQ;
|
||||
|
@ -117,8 +124,11 @@ int main(int argc, char* argv[])
|
|||
SampleRate = atoi(optarg);
|
||||
break;
|
||||
case 'p': // ppmcorrection
|
||||
ppmpll = atof(optarg);
|
||||
|
||||
ppmpll = strtof(optarg, &endptr);
|
||||
if (endptr == optarg || ppmpll <= 0.0f || ppmpll == HUGE_VALF) {
|
||||
fprintf(stderr, "tune: not a valid ppm - '%s'", optarg)
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'h': // help
|
||||
print_usage();
|
||||
|
@ -136,14 +146,18 @@ int main(int argc, char* argv[])
|
|||
fprintf(stderr,"Warning : 'w' parameter not used in this version\n");
|
||||
break;
|
||||
case 'r': // Randomize PWM frequency
|
||||
fprintf(stderr,"Warning : 'r' parameter not used in this version\n");
|
||||
|
||||
fprintf(stderr,"Warning : 'r' parameter not used in this version\n");
|
||||
break;
|
||||
case 'a': // DMA Channel 1-14
|
||||
fprintf(stderr,"Warning : 'a' parameter not used in this version\n");
|
||||
case 'q': // Harmonic number
|
||||
Harmonic=atoi(optarg);
|
||||
break;
|
||||
|
||||
break;
|
||||
case -1:
|
||||
break;
|
||||
|
||||
case '?':
|
||||
if (isprint(optopt) )
|
||||
{
|
||||
|
|
|
@ -101,7 +101,7 @@ int main(int argc, char* argv[])
|
|||
enum {typeiq_i16,typeiq_u8,typeiq_float,typeiq_double};
|
||||
int InputType=typeiq_i16;
|
||||
int Decimation=1;
|
||||
|
||||
char * endptr = NULL;
|
||||
while(1)
|
||||
{
|
||||
a = getopt(argc, argv, "i:f:s:m:p:h:ldt:");
|
||||
|
@ -127,11 +127,15 @@ int main(int argc, char* argv[])
|
|||
if (drivedds>7.0) {drivedds=7.0;}
|
||||
break;
|
||||
case 'f': // Frequency
|
||||
SetFrequency = atof(optarg);
|
||||
break;
|
||||
case 'm': // Shared memory token
|
||||
sharedmem_token = atoi(optarg);
|
||||
InputType=typeiq_float; //if using shared memory force float pipe
|
||||
SetFrequency = strtof(optarg, &endptr);
|
||||
if (endptr == optarg || SetFrequency <= 0.0f || SetFrequency == HUGE_VALF) {
|
||||
fprintf(stderr, "tune: not a valid frequency - '%s'", optarg)
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'm': // Shared memory token
|
||||
sharedmem_token = atoi(optarg);
|
||||
InputType=typeiq_float; //if using shared memory force float pipe
|
||||
break;
|
||||
case 's': // SampleRate (Only needeed in IQ mode)
|
||||
SampleRate = atoi(optarg);
|
||||
|
@ -157,7 +161,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
};
|
||||
break;
|
||||
case 'h': // help
|
||||
case 'h': // Harmonic numebr
|
||||
Harmonic=atoi(optarg);
|
||||
break;
|
||||
case 'l': // loop mode
|
||||
|
|
21
src/tune.cpp
21
src/tune.cpp
|
@ -37,10 +37,12 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
int a;
|
||||
int anyargs = 0;
|
||||
float SetFrequency=434e6;
|
||||
float SetFrequency = 434e6;
|
||||
dbg_setlevel(1);
|
||||
bool NotKill=false;
|
||||
float ppm=1000.0;
|
||||
bool ppmSet = false;
|
||||
float ppm = 0.0f;
|
||||
char * endptr = NULL;
|
||||
while(1)
|
||||
{
|
||||
a = getopt(argc, argv, "f:ehp:");
|
||||
|
@ -55,13 +57,22 @@ int main(int argc, char* argv[])
|
|||
switch(a)
|
||||
{
|
||||
case 'f': // Frequency
|
||||
SetFrequency = atof(optarg);
|
||||
SetFrequency = strtof(optarg, &endptr);
|
||||
if (endptr == optarg || SetFrequency <= 0.0f || SetFrequency == HUGE_VALF) {
|
||||
fprintf(stderr, "tune: not a valid frequency - '%s'", optarg)
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'e': //End immediately
|
||||
NotKill=true;
|
||||
break;
|
||||
case 'p': //ppm
|
||||
ppm=atof(optarg);
|
||||
ppm = strtof(optarg, &endptr);
|
||||
if (endptr == optarg || ppm <= 0.0f || ppm == HUGE_VALF) {
|
||||
fprintf(stderr, "tune: not a valid ppm - '%s'", optarg)
|
||||
exit(1);
|
||||
}
|
||||
ppmSet = true;
|
||||
break;
|
||||
case 'h': // help
|
||||
print_usage();
|
||||
|
@ -105,7 +116,7 @@ int main(int argc, char* argv[])
|
|||
pad.setlevel(7);
|
||||
clkgpio *clk=new clkgpio;
|
||||
clk->SetAdvancedPllMode(true);
|
||||
if(ppm!=1000) //ppm is set else use ntp
|
||||
if(ppmSet) //ppm is set else use ntp
|
||||
clk->Setppm(ppm);
|
||||
clk->SetCenterFrequency(SetFrequency,10);
|
||||
clk->SetFrequency(000);
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
#TODO using the AM mode from librpitx
|
||||
echo Need to implement
|
||||
(while true; do cat sampleaudio.wav; done) | csdr convert_i16_f \
|
||||
(while true; do cat "$2"; done) | csdr convert_i16_f \
|
||||
| csdr gain_ff 4.0 | csdr dsb_fc \
|
||||
| sudo ./rpitx -i - -m IQFLOAT -f "$1" -s 48000
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
sudo ./pifmrds -freq "$1" -audio src/pifmrds/stereo_44100.wav
|
||||
sudo ./pifmrds -freq "$1" -audio "$2"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
sudo ./freedv src/freedv/VCO800XA.rf "$1" 400
|
||||
sudo ./freedv "$2" "$1" 400
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Need to use a direct FM modulation with librpitx and not using IQ : TODO
|
||||
echo "If you need to test broadcast FM, use PiFMRDS"
|
||||
#(while true; do cat sampleaudio.wav; done) | csdr convert_i16_f | csdr gain_ff 2500 | sudo ./sendiq -i /dev/stdin -s 24000 -f 434e6 -t float 1
|
||||
(while true; do cat sampleaudio.wav; done) | csdr convert_i16_f \
|
||||
(while true; do cat "$2"; done) | csdr convert_i16_f \
|
||||
| csdr gain_ff 7000 | csdr convert_f_samplerf 20833 \
|
||||
| sudo ./rpitx -i- -m RF -f "$1"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
sudo ./piopera F5OEO 0.5 "$1"
|
||||
sudo ./piopera "$2" 0.5 "$1"
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
printf "1:YOURCALL\n2: Hello world" | sudo ./pocsag -f "$1"
|
||||
printf "$2" | sudo ./pocsag -f "$1"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#!/bin/bash
|
||||
sudo ./pirtty "$1" 1000 "the quick brown fox jumps over the lazy dog"
|
||||
sudo ./pirtty "$1" 1000 "$2"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
convert BBC.jpg -flip -quantize YUV -dither FloydSteinberg -colors 4 \
|
||||
convert "$2" -flip -quantize YUV -dither FloydSteinberg -colors 4 \
|
||||
-interlace partition picture.yuv
|
||||
sudo ./spectrumpaint picture.Y "$1" 100000
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
(while true; do cat sampleaudio.wav; done) | csdr convert_i16_f \
|
||||
(while true; do cat "$2"; done) | csdr convert_i16_f \
|
||||
| csdr fir_interpolate_cc 2 | csdr dsb_fc \
|
||||
| csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff \
|
||||
| sudo ./sendiq -i /dev/stdin -s 96000 -f "$1" -t float
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
convert -depth 8 BBC.jpg picture.rgb
|
||||
convert -depth 8 "$2" picture.rgb
|
||||
sudo ./pisstv picture.rgb "$1"
|
||||
|
|
Ładowanie…
Reference in New Issue