aboutsummaryrefslogtreecommitdiffstats
path: root/src/rtl_fm.c
diff options
context:
space:
mode:
authorKyle Keen <keenerd@gmail.com>2013-01-29 23:05:09 -0500
committerSteve Markgraf <steve@steve-m.de>2013-01-30 20:24:24 +0100
commite8e735caf4786d55e65cff4bcff7b34c71b6d552 (patch)
tree5bdbb8af01673cc846221550dc1fd391e0aedca9 /src/rtl_fm.c
parentc85cab2dae0ed59e244a2160fa632596c9707eb9 (diff)
rtl_fm: bugfixes from TonberryKing
Signed-off-by: Steve Markgraf <steve@steve-m.de>
Diffstat (limited to 'src/rtl_fm.c')
-rw-r--r--src/rtl_fm.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/rtl_fm.c b/src/rtl_fm.c
index 8009876..4bf7eef 100644
--- a/src/rtl_fm.c
+++ b/src/rtl_fm.c
@@ -672,6 +672,32 @@ void frequency_range(struct fm_state *fm, char *arg)
step[-1] = ':';
}
+void fm_init(struct fm_state *fm)
+{
+ fm->freqs[0] = 100000000;
+ fm->sample_rate = DEFAULT_SAMPLE_RATE;
+ fm->squelch_level = 0;
+ fm->conseq_squelch = 20;
+ fm->terminate_on_squelch = 0;
+ fm->squelch_hits = 0;
+ fm->freq_len = 0;
+ fm->edge = 0;
+ fm->fir_enable = 0;
+ fm->prev_index = 0;
+ fm->post_downsample = 1; // once this works, default = 4
+ fm->custom_atan = 0;
+ fm->deemph = 0;
+ fm->output_rate = -1; // flag for disabled
+ fm->mode_demod = &fm_demod;
+ fm->pre_j = 0;
+ fm->pre_r = 0;
+ fm->now_r = 0;
+ fm->now_j = 0;
+ fm->prev_lpr_index = 0;
+ fm->deemph_a = 0;
+ fm->now_lpr = 0;
+}
+
int main(int argc, char **argv)
{
#ifndef _WIN32
@@ -686,20 +712,7 @@ int main(int argc, char **argv)
int device_count;
int ppm_error = 0;
char vendor[256], product[256], serial[256];
- fm.freqs[0] = 100000000;
- fm.sample_rate = DEFAULT_SAMPLE_RATE;
- fm.squelch_level = 0;
- fm.conseq_squelch = 20;
- fm.terminate_on_squelch = 0;
- fm.freq_len = 0;
- fm.edge = 0;
- fm.fir_enable = 0;
- fm.prev_index = 0;
- fm.post_downsample = 1; // once this works, default = 4
- fm.custom_atan = 0;
- fm.deemph = 0;
- fm.output_rate = -1; // flag for disabled
- fm.mode_demod = &fm_demod;
+ fm_init(&fm);
sem_init(&data_ready, 0, 0);
while ((opt = getopt(argc, argv, "d:f:g:s:b:l:o:t:r:p:EFA:NWMULRD")) != -1) {
@@ -794,6 +807,11 @@ int main(int argc, char **argv)
/* quadruple sample_rate to limit to Δθ to ±π/2 */
fm.sample_rate *= fm.post_downsample;
+ if (fm.freq_len == 0) {
+ fprintf(stderr, "Please specify a frequency.\n");
+ exit(1);
+ }
+
if (fm.freq_len > 1) {
fm.terminate_on_squelch = 0;
}