Remove dependencies between debug, displays and mncc-console
Test functions are cleaned up, due to removed dependencies.
This commit is contained in:
parent
3f217b99f6
commit
ec4c62bfb8
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue