aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-12-03 09:30:54 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-12-09 20:46:13 +0100
commitc49ee3b2a8c545ce6582b414b55ed9f610bd4b94 (patch)
treefed4b4edb4317ba02d05fb2dc38da3c061d7139f
parentb3866de24250fbc40618d3776af777b6b2b0d6b2 (diff)
Remove dependencies between debug, displays and mncc-console
Test functions are cleaned up, due to removed dependencies.
-rw-r--r--src/libdebug/debug.c34
-rw-r--r--src/libdebug/debug.h5
-rw-r--r--src/libdisplay/display.h5
-rw-r--r--src/libdisplay/display_iq.c18
-rw-r--r--src/libdisplay/display_measurements.c17
-rw-r--r--src/libdisplay/display_spectrum.c18
-rw-r--r--src/libdisplay/display_status.c20
-rw-r--r--src/libdisplay/display_wave.c18
-rw-r--r--src/libemphasis/emphasis.c3
-rw-r--r--src/libmncc/mncc_console.c51
-rw-r--r--src/libmncc/mncc_console.h2
-rw-r--r--src/libmobile/main_mobile.c9
-rw-r--r--src/test/Makefile.am39
-rw-r--r--src/test/test_emphasis.c9
-rw-r--r--src/test/test_filter.c8
-rw-r--r--src/tv/main.c2
16 files changed, 86 insertions, 172 deletions
diff --git a/src/libdebug/debug.c b/src/libdebug/debug.c
index f64478e..ffd2861 100644
--- a/src/libdebug/debug.c
+++ b/src/libdebug/debug.c
@@ -27,7 +27,6 @@
#include "../libsample/sample.h"
#include "debug.h"
#include "../libdisplay/display.h"
-#include "../libmncc/mncc_console.h"
const char *debug_level[] = {
"debug ",
@@ -67,12 +66,18 @@ int debuglevel = DEBUG_INFO;
uint64_t debug_mask = ~0;
extern int num_kanal;
+void (*clear_console_text)(void) = NULL;
+void (*print_console_text)(void) = NULL;
+
+int debug_limit_scroll = 0;
+
void _printdebug(const char *file, const char __attribute__((unused)) *function, int line, int cat, int level, int chan, const char *fmt, ...)
{
char buffer[4096], *b = buffer;
int s = sizeof(buffer) - 1;
const char *p;
va_list args;
+ int w, h;
if (debuglevel > level)
return;
@@ -96,24 +101,17 @@ void _printdebug(const char *file, const char __attribute__((unused)) *function,
while ((p = strchr(file, '/')))
file = p + 1;
- clear_console_text();
-// printf("%s%s:%d %s() %s: %s\033[0;39m", debug_cat[cat].color, file, line, function, debug_level[level], buffer);
- display_wave_limit_scroll(1);
- display_status_limit_scroll(1);
- display_measurements_limit_scroll(1);
-#ifdef HAVE_SDR
- display_iq_limit_scroll(1);
- display_spectrum_limit_scroll(1);
-#endif
+ if (clear_console_text)
+ clear_console_text();
+ if (debug_limit_scroll) {
+ get_win_size(&w, &h);
+ printf("\0337\033[%d;%dr\0338", debug_limit_scroll + 1, h);
+ }
printf("%s%s:%d %s: %s\033[0;39m", debug_cat[cat].color, file, line, debug_level[level], buffer);
- display_wave_limit_scroll(0);
- display_status_limit_scroll(0);
- display_measurements_limit_scroll(0);
-#ifdef HAVE_SDR
- display_iq_limit_scroll(0);
- display_spectrum_limit_scroll(0);
-#endif
- print_console_text();
+ if (debug_limit_scroll)
+ printf("\0337\033[%d;%dr\0338", 1, h);
+ if (print_console_text)
+ print_console_text();
fflush(stdout);
}
diff --git a/src/libdebug/debug.h b/src/libdebug/debug.h
index bb72c62..879dad0 100644
--- a/src/libdebug/debug.h
+++ b/src/libdebug/debug.h
@@ -36,3 +36,8 @@ int parse_debug_opt(const char *opt);
extern int debuglevel;
+extern void (*clear_console_text)(void);
+extern void (*print_console_text)(void);
+
+extern int debug_limit_scroll;
+
diff --git a/src/libdisplay/display.h b/src/libdisplay/display.h
index 386a2d7..634e74f 100644
--- a/src/libdisplay/display.h
+++ b/src/libdisplay/display.h
@@ -69,11 +69,9 @@ void get_win_size(int *w, int *h);
void display_wave_init(sender_t *sender, int samplerate);
void display_wave_on(int on);
-void display_wave_limit_scroll(int on);
void display_wave(sender_t *sender, sample_t *samples, int length, double range);
void display_status_on(int on);
-void display_status_limit_scroll(int on);
void display_status_start(void);
void display_status_channel(int channel, const char *type, const char *state);
void display_status_subscriber(const char *number, const char *state);
@@ -82,18 +80,15 @@ void display_status_end(void);
void display_measurements_init(sender_t *sender, int samplerate);
void display_measurements_exit(sender_t *sender);
void display_measurements_on(int on);
-void display_measurements_limit_scroll(int on);
dispmeasparam_t *display_measurements_add(sender_t *sender, char *name, char *format, enum display_measurements_type type, enum display_measurements_bar bar, double min, double max, double mark);
void display_measurements_update(dispmeasparam_t *param, double value, double value2);
void display_measurements(double elapsed);
void display_iq_init(int samplerate);
void display_iq_on(int on);
-void display_iq_limit_scroll(int on);
void display_iq(float *samples, int length);
void display_spectrum_init(int samplerate, double center_frequency);
void display_spectrum_on(int on);
-void display_spectrum_limit_scroll(int on);
void display_spectrum(float *samples, int length);
diff --git a/src/libdisplay/display_iq.c b/src/libdisplay/display_iq.c
index c6ab910..c99833b 100644
--- a/src/libdisplay/display_iq.c
+++ b/src/libdisplay/display_iq.c
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include "../libsample/sample.h"
#include "../libmobile/sender.h"
+#include "../libdebug/debug.h"
/* must be odd value! */
#define SIZE 23
@@ -70,20 +71,11 @@ void display_iq_on(int on)
iq_on = 0;
} else
iq_on = on;
-}
-
-void display_iq_limit_scroll(int on)
-{
- int w, h;
-
- if (!iq_on)
- return;
-
- get_win_size(&w, &h);
- printf("\0337");
- printf("\033[%d;%dr", (on) ? SIZE + 1 : 1, h);
- printf("\0338");
+ if (iq_on)
+ debug_limit_scroll = SIZE;
+ else
+ debug_limit_scroll = 0;
}
/*
diff --git a/src/libdisplay/display_measurements.c b/src/libdisplay/display_measurements.c
index eb8618e..9dc06ae 100644
--- a/src/libdisplay/display_measurements.c
+++ b/src/libdisplay/display_measurements.c
@@ -26,6 +26,7 @@
#include <math.h>
#include "../libsample/sample.h"
#include "../libmobile/sender.h"
+#include "../libdebug/debug.h"
#define MAX_NAME_LEN 16
#define MAX_UNIT_LEN 16
@@ -240,6 +241,8 @@ static void print_measurements(int on)
}
/* reset color and position */
printf("\033[0;39m\0338"); fflush(stdout);
+
+ debug_limit_scroll = lines_total;
}
void display_measurements_on(int on)
@@ -251,20 +254,8 @@ void display_measurements_on(int on)
measurements_on = 1 - measurements_on;
else
measurements_on = on;
-}
-
-void display_measurements_limit_scroll(int on)
-{
- int w, h;
-
- if (!measurements_on)
- return;
-
- get_win_size(&w, &h);
- printf("\0337");
- printf("\033[%d;%dr", (on) ? lines_total + 1 : 1, h);
- printf("\0338");
+ debug_limit_scroll = 0;
}
/* add new parameter on startup to the list of measurements */
diff --git a/src/libdisplay/display_spectrum.c b/src/libdisplay/display_spectrum.c
index 098f413..2e2f167 100644
--- a/src/libdisplay/display_spectrum.c
+++ b/src/libdisplay/display_spectrum.c
@@ -25,6 +25,7 @@
#include "../libsample/sample.h"
#include "../libmobile/sender.h"
#include "../libfft/fft.h"
+#include "../libdebug/debug.h"
#define HEIGHT 20
@@ -74,20 +75,11 @@ void display_spectrum_on(int on)
spectrum_on = 0;
} else
spectrum_on = on;
-}
-
-void display_spectrum_limit_scroll(int on)
-{
- int w, h;
-
- if (!spectrum_on)
- return;
-
- get_win_size(&w, &h);
- printf("\0337");
- printf("\033[%d;%dr", (on) ? HEIGHT + 1 : 1, h);
- printf("\0338");
+ if (spectrum_on)
+ debug_limit_scroll = HEIGHT;
+ else
+ debug_limit_scroll = 0;
}
/*
diff --git a/src/libdisplay/display_status.c b/src/libdisplay/display_status.c
index d49ddb6..681c217 100644
--- a/src/libdisplay/display_status.c
+++ b/src/libdisplay/display_status.c
@@ -24,6 +24,7 @@
#include <sys/ioctl.h>
#include "../libsample/sample.h"
#include "../libmobile/sender.h"
+#include "../libdebug/debug.h"
static int status_on = 0;
static int line_count = 0;
@@ -70,20 +71,11 @@ void display_status_on(int on)
if (status_on)
print_status(1);
-}
-
-void display_status_limit_scroll(int on)
-{
- int w, h;
-
- if (!status_on)
- return;
- get_win_size(&w, &h);
-
- printf("\0337");
- printf("\033[%d;%dr", (on) ? lines_total + 1 : 1, h);
- printf("\0338");
+ if (status_on)
+ debug_limit_scroll = lines_total;
+ else
+ debug_limit_scroll = 0;
}
/* start status display */
@@ -142,6 +134,8 @@ void display_status_end(void)
print_status(1);
/* set new total lines */
lines_total = line_count;
+ if (status_on)
+ debug_limit_scroll = lines_total;
}
diff --git a/src/libdisplay/display_wave.c b/src/libdisplay/display_wave.c
index b4005f9..dcb1dfb 100644
--- a/src/libdisplay/display_wave.c
+++ b/src/libdisplay/display_wave.c
@@ -25,6 +25,7 @@
#include <sys/ioctl.h>
#include "../libsample/sample.h"
#include "../libmobile/sender.h"
+#include "../libdebug/debug.h"
#define HEIGHT 11
@@ -82,20 +83,11 @@ void display_wave_on(int on)
wave_on = 1 - wave_on;
else
wave_on = on;
-}
-
-void display_wave_limit_scroll(int on)
-{
- int w, h;
-
- if (!wave_on)
- return;
- get_win_size(&w, &h);
-
- printf("\0337");
- printf("\033[%d;%dr", (on) ? num_sender * HEIGHT + 1 : 1, h);
- printf("\0338");
+ if (wave_on)
+ debug_limit_scroll = HEIGHT * num_sender;
+ else
+ debug_limit_scroll = 0;
}
/*
diff --git a/src/libemphasis/emphasis.c b/src/libemphasis/emphasis.c
index d9d192d..ed4e2ec 100644
--- a/src/libemphasis/emphasis.c
+++ b/src/libemphasis/emphasis.c
@@ -22,7 +22,6 @@
#include <string.h>
#include <math.h>
#include "../libsample/sample.h"
-#include "../libdebug/debug.h"
#include "../libfilter/iir_filter.h"
#include "emphasis.h"
@@ -61,7 +60,7 @@ int init_emphasis(emphasis_t *state, int samplerate, double cut_off)
/* exp (-2 * PI * CUT_OFF * delta_t) */
factor = exp(-2.0 * PI * cut_off / (double)samplerate); /* 1/samplerate == delta_t */
- PDEBUG(DDSP, DEBUG_DEBUG, "Emphasis factor = %.3f\n", factor);
+// printf("Emphasis factor = %.3f\n", factor);
state->p.factor = factor;
state->p.amp = 1.0;
state->d.factor = factor;
diff --git a/src/libmncc/mncc_console.c b/src/libmncc/mncc_console.c
index b1ae57c..72ce21c 100644
--- a/src/libmncc/mncc_console.c
+++ b/src/libmncc/mncc_console.c
@@ -223,12 +223,39 @@ static int console_mncc_up(uint8_t *buf, int length)
return 0;
}
+static char console_text[256];
+static char console_clear[256];
+static int console_len = 0;
+
+static void _clear_console_text(void)
+{
+ if (!console_len)
+ return;
+
+ fwrite(console_clear, console_len, 1, stdout);
+ // note: fflused by user of this function
+ console_len = 0;
+}
+
+static void _print_console_text(void)
+{
+ if (!console_len)
+ return;
+
+ printf("\033[1;37m");
+ fwrite(console_text, console_len, 1, stdout);
+ printf("\033[0;39m");
+}
+
int console_init(const char *station_id, const char *audiodev, int samplerate, int latency, int dial_digits, int loopback, int echo_test)
{
int rc = 0;
init_testton();
+ clear_console_text = _clear_console_text;
+ print_console_text = _print_console_text;
+
memset(&console, 0, sizeof(console));
strncpy(console.station_id, station_id, sizeof(console.station_id) - 1);
strncpy(console.audiodev, audiodev, sizeof(console.audiodev) - 1);
@@ -295,10 +322,6 @@ void console_cleanup(void)
jitter_destroy(&console.dejitter);
}
-static char console_text[256];
-static char console_clear[256];
-static int console_len = 0;
-
static void process_ui(int c)
{
char text[256];
@@ -395,26 +418,6 @@ dial_after_hangup:
fflush(stdout);
}
-void clear_console_text(void)
-{
- if (!console_len)
- return;
-
- fwrite(console_clear, console_len, 1, stdout);
- // note: fflused by user of this function
- console_len = 0;
-}
-
-void print_console_text(void)
-{
- if (!console_len)
- return;
-
- printf("\033[1;37m");
- fwrite(console_text, console_len, 1, stdout);
- printf("\033[0;39m");
-}
-
/* get keys from keyboad to control call via console
* returns 1 on exit (ctrl+c) */
void process_console(int c)
diff --git a/src/libmncc/mncc_console.h b/src/libmncc/mncc_console.h
index f61c8a4..7a80d97 100644
--- a/src/libmncc/mncc_console.h
+++ b/src/libmncc/mncc_console.h
@@ -4,7 +4,5 @@ void console_cleanup(void);
int console_open_audio(int latspl);
int console_start_audio(void);
void console_process(int c);
-void clear_console_text(void);
-void print_console_text(void);
void process_console(int c);
diff --git a/src/libmobile/main_mobile.c b/src/libmobile/main_mobile.c
index 19312f3..0654ae9 100644
--- a/src/libmobile/main_mobile.c
+++ b/src/libmobile/main_mobile.c
@@ -396,7 +396,8 @@ void sighandler(int sigset)
if (sigset == SIGPIPE)
return;
- clear_console_text();
+ if (clear_console_text)
+ clear_console_text();
printf("Signal received: %d\n", sigset);
quit = 1;
@@ -570,7 +571,8 @@ next_char:
switch (c) {
case 3:
/* quit */
- clear_console_text();
+ if (clear_console_text)
+ clear_console_text();
printf("CTRL+c received, quitting!\n");
*quit = 1;
goto next_char;
@@ -664,7 +666,8 @@ next_char:
signal(SIGPIPE, SIG_DFL);
/* get rid of last entry */
- clear_console_text();
+ if (clear_console_text)
+ clear_console_text();
/* reset terminal */
tcsetattr(0, TCSANOW, &term_orig);
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index cac2cfe..82bb8c7 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -16,29 +16,9 @@ test_filter_SOURCES = test_filter.c dummy.c
test_filter_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/libdebug/libdebug.a \
- $(top_builddir)/src/libmobile/libmobile.a \
- $(top_builddir)/src/libdisplay/libdisplay.a \
- $(top_builddir)/src/libjitter/libjitter.a \
- $(top_builddir)/src/libtimer/libtimer.a \
- $(top_builddir)/src/libsamplerate/libsamplerate.a \
- $(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfilter/libfilter.a \
- $(top_builddir)/src/libwave/libwave.a \
- $(top_builddir)/src/libmncc/libmncc.a \
- $(top_builddir)/src/libsound/libsound.a \
- $(top_builddir)/src/libsample/libsample.a \
- $(ALSA_LIBS) \
-lm
-if HAVE_SDR
-test_filter_LDADD += \
- $(top_builddir)/src/libsdr/libsdr.a \
- $(top_builddir)/src/libfft/libfft.a \
- $(top_builddir)/src/libfm/libfm.a \
- $(UHD_LIBS) \
- $(SOAPY_LIBS)
-endif
-
test_sendevolumenregler_SOURCES = test_sendevolumenregler.c
test_sendevolumenregler_LDADD = \
@@ -58,29 +38,10 @@ test_emphasis_SOURCES = test_emphasis.c dummy.c
test_emphasis_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/libdebug/libdebug.a \
- $(top_builddir)/src/libmobile/libmobile.a \
- $(top_builddir)/src/libdisplay/libdisplay.a \
- $(top_builddir)/src/libjitter/libjitter.a \
- $(top_builddir)/src/libtimer/libtimer.a \
- $(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfilter/libfilter.a \
- $(top_builddir)/src/libwave/libwave.a \
- $(top_builddir)/src/libmncc/libmncc.a \
- $(top_builddir)/src/libsound/libsound.a \
- $(top_builddir)/src/libsample/libsample.a \
- $(ALSA_LIBS) \
-lm
-if HAVE_SDR
-test_emphasis_LDADD += \
- $(top_builddir)/src/libsdr/libsdr.a \
- $(top_builddir)/src/libfft/libfft.a \
- $(top_builddir)/src/libfm/libfm.a \
- $(UHD_LIBS) \
- $(SOAPY_LIBS)
-endif
-
test_dtmf_SOURCES = dummy.x test_dtmf.c
test_dtmf_LDADD = \
diff --git a/src/test/test_emphasis.c b/src/test/test_emphasis.c
index ef26761..f5d41ff 100644
--- a/src/test/test_emphasis.c
+++ b/src/test/test_emphasis.c
@@ -35,7 +35,9 @@ static void gen_samples(sample_t *samples, double freq)
}
}
-extern void main_mobile();
+int num_kanal;
+int get_win_size;
+
int main(void)
{
@@ -45,11 +47,6 @@ int main(void)
double level;
double i;
- /* this is never called, it forces the linker to add mobile functions */
- if (debuglevel == -1000) main_mobile();
-
- debuglevel = DEBUG_DEBUG;
-
init_emphasis(&estate, SAMPLERATE, cut_off);
printf("testing pre-emphasis filter with cut-off frequency %.1f\n", cut_off);
diff --git a/src/test/test_filter.c b/src/test/test_filter.c
index 2158937..891bea6 100644
--- a/src/test/test_filter.c
+++ b/src/test/test_filter.c
@@ -34,7 +34,8 @@ static void gen_samples(sample_t *samples, double freq)
}
}
-extern void main_mobile();
+int num_kanal;
+int get_win_size;
int main(void)
{
@@ -45,11 +46,6 @@ int main(void)
int iter = 2;
int i;
- /* this is never called, it forces the linker to add mobile functions */
- if (debuglevel == -1000) main_mobile();
-
- debuglevel = DEBUG_DEBUG;
-
printf("testing low-pass filter with %d iterations\n", iter);
iir_lowpass_init(&filter_low, 1000.0, SAMPLERATE, iter);
diff --git a/src/tv/main.c b/src/tv/main.c
index e7cde20..3423ae3 100644
--- a/src/tv/main.c
+++ b/src/tv/main.c
@@ -45,8 +45,6 @@ void *sender_head = NULL;
int use_sdr = 0;
int num_kanal = 1; /* only one channel used for debugging */
-void clear_console_text() {}
-void print_console_text() {}
void display_status_limit_scroll() {}
void *get_sender_by_empfangsfrequenz() { return NULL; }