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 "../libsample/sample.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "../libdisplay/display.h"
|
#include "../libdisplay/display.h"
|
||||||
#include "../libmncc/mncc_console.h"
|
|
||||||
|
|
||||||
const char *debug_level[] = {
|
const char *debug_level[] = {
|
||||||
"debug ",
|
"debug ",
|
||||||
|
@ -67,12 +66,18 @@ int debuglevel = DEBUG_INFO;
|
||||||
uint64_t debug_mask = ~0;
|
uint64_t debug_mask = ~0;
|
||||||
extern int num_kanal;
|
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, ...)
|
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;
|
char buffer[4096], *b = buffer;
|
||||||
int s = sizeof(buffer) - 1;
|
int s = sizeof(buffer) - 1;
|
||||||
const char *p;
|
const char *p;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
if (debuglevel > level)
|
if (debuglevel > level)
|
||||||
return;
|
return;
|
||||||
|
@ -96,23 +101,16 @@ void _printdebug(const char *file, const char __attribute__((unused)) *function,
|
||||||
while ((p = strchr(file, '/')))
|
while ((p = strchr(file, '/')))
|
||||||
file = p + 1;
|
file = p + 1;
|
||||||
|
|
||||||
|
if (clear_console_text)
|
||||||
clear_console_text();
|
clear_console_text();
|
||||||
// printf("%s%s:%d %s() %s: %s\033[0;39m", debug_cat[cat].color, file, line, function, debug_level[level], buffer);
|
if (debug_limit_scroll) {
|
||||||
display_wave_limit_scroll(1);
|
get_win_size(&w, &h);
|
||||||
display_status_limit_scroll(1);
|
printf("\0337\033[%d;%dr\0338", debug_limit_scroll + 1, h);
|
||||||
display_measurements_limit_scroll(1);
|
}
|
||||||
#ifdef HAVE_SDR
|
|
||||||
display_iq_limit_scroll(1);
|
|
||||||
display_spectrum_limit_scroll(1);
|
|
||||||
#endif
|
|
||||||
printf("%s%s:%d %s: %s\033[0;39m", debug_cat[cat].color, file, line, debug_level[level], buffer);
|
printf("%s%s:%d %s: %s\033[0;39m", debug_cat[cat].color, file, line, debug_level[level], buffer);
|
||||||
display_wave_limit_scroll(0);
|
if (debug_limit_scroll)
|
||||||
display_status_limit_scroll(0);
|
printf("\0337\033[%d;%dr\0338", 1, h);
|
||||||
display_measurements_limit_scroll(0);
|
if (print_console_text)
|
||||||
#ifdef HAVE_SDR
|
|
||||||
display_iq_limit_scroll(0);
|
|
||||||
display_spectrum_limit_scroll(0);
|
|
||||||
#endif
|
|
||||||
print_console_text();
|
print_console_text();
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,3 +36,8 @@ int parse_debug_opt(const char *opt);
|
||||||
|
|
||||||
extern int debuglevel;
|
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_init(sender_t *sender, int samplerate);
|
||||||
void display_wave_on(int on);
|
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_wave(sender_t *sender, sample_t *samples, int length, double range);
|
||||||
|
|
||||||
void display_status_on(int on);
|
void display_status_on(int on);
|
||||||
void display_status_limit_scroll(int on);
|
|
||||||
void display_status_start(void);
|
void display_status_start(void);
|
||||||
void display_status_channel(int channel, const char *type, const char *state);
|
void display_status_channel(int channel, const char *type, const char *state);
|
||||||
void display_status_subscriber(const char *number, 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_init(sender_t *sender, int samplerate);
|
||||||
void display_measurements_exit(sender_t *sender);
|
void display_measurements_exit(sender_t *sender);
|
||||||
void display_measurements_on(int on);
|
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);
|
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_update(dispmeasparam_t *param, double value, double value2);
|
||||||
void display_measurements(double elapsed);
|
void display_measurements(double elapsed);
|
||||||
|
|
||||||
void display_iq_init(int samplerate);
|
void display_iq_init(int samplerate);
|
||||||
void display_iq_on(int on);
|
void display_iq_on(int on);
|
||||||
void display_iq_limit_scroll(int on);
|
|
||||||
void display_iq(float *samples, int length);
|
void display_iq(float *samples, int length);
|
||||||
|
|
||||||
void display_spectrum_init(int samplerate, double center_frequency);
|
void display_spectrum_init(int samplerate, double center_frequency);
|
||||||
void display_spectrum_on(int on);
|
void display_spectrum_on(int on);
|
||||||
void display_spectrum_limit_scroll(int on);
|
|
||||||
void display_spectrum(float *samples, int length);
|
void display_spectrum(float *samples, int length);
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "../libsample/sample.h"
|
#include "../libsample/sample.h"
|
||||||
#include "../libmobile/sender.h"
|
#include "../libmobile/sender.h"
|
||||||
|
#include "../libdebug/debug.h"
|
||||||
|
|
||||||
/* must be odd value! */
|
/* must be odd value! */
|
||||||
#define SIZE 23
|
#define SIZE 23
|
||||||
|
@ -70,20 +71,11 @@ void display_iq_on(int on)
|
||||||
iq_on = 0;
|
iq_on = 0;
|
||||||
} else
|
} else
|
||||||
iq_on = on;
|
iq_on = on;
|
||||||
}
|
|
||||||
|
|
||||||
void display_iq_limit_scroll(int on)
|
if (iq_on)
|
||||||
{
|
debug_limit_scroll = SIZE;
|
||||||
int w, h;
|
else
|
||||||
|
debug_limit_scroll = 0;
|
||||||
if (!iq_on)
|
|
||||||
return;
|
|
||||||
|
|
||||||
get_win_size(&w, &h);
|
|
||||||
|
|
||||||
printf("\0337");
|
|
||||||
printf("\033[%d;%dr", (on) ? SIZE + 1 : 1, h);
|
|
||||||
printf("\0338");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "../libsample/sample.h"
|
#include "../libsample/sample.h"
|
||||||
#include "../libmobile/sender.h"
|
#include "../libmobile/sender.h"
|
||||||
|
#include "../libdebug/debug.h"
|
||||||
|
|
||||||
#define MAX_NAME_LEN 16
|
#define MAX_NAME_LEN 16
|
||||||
#define MAX_UNIT_LEN 16
|
#define MAX_UNIT_LEN 16
|
||||||
|
@ -240,6 +241,8 @@ static void print_measurements(int on)
|
||||||
}
|
}
|
||||||
/* reset color and position */
|
/* reset color and position */
|
||||||
printf("\033[0;39m\0338"); fflush(stdout);
|
printf("\033[0;39m\0338"); fflush(stdout);
|
||||||
|
|
||||||
|
debug_limit_scroll = lines_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_measurements_on(int on)
|
void display_measurements_on(int on)
|
||||||
|
@ -251,20 +254,8 @@ void display_measurements_on(int on)
|
||||||
measurements_on = 1 - measurements_on;
|
measurements_on = 1 - measurements_on;
|
||||||
else
|
else
|
||||||
measurements_on = on;
|
measurements_on = on;
|
||||||
}
|
|
||||||
|
|
||||||
void display_measurements_limit_scroll(int on)
|
debug_limit_scroll = 0;
|
||||||
{
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add new parameter on startup to the list of measurements */
|
/* add new parameter on startup to the list of measurements */
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "../libsample/sample.h"
|
#include "../libsample/sample.h"
|
||||||
#include "../libmobile/sender.h"
|
#include "../libmobile/sender.h"
|
||||||
#include "../libfft/fft.h"
|
#include "../libfft/fft.h"
|
||||||
|
#include "../libdebug/debug.h"
|
||||||
|
|
||||||
#define HEIGHT 20
|
#define HEIGHT 20
|
||||||
|
|
||||||
|
@ -74,20 +75,11 @@ void display_spectrum_on(int on)
|
||||||
spectrum_on = 0;
|
spectrum_on = 0;
|
||||||
} else
|
} else
|
||||||
spectrum_on = on;
|
spectrum_on = on;
|
||||||
}
|
|
||||||
|
|
||||||
void display_spectrum_limit_scroll(int on)
|
if (spectrum_on)
|
||||||
{
|
debug_limit_scroll = HEIGHT;
|
||||||
int w, h;
|
else
|
||||||
|
debug_limit_scroll = 0;
|
||||||
if (!spectrum_on)
|
|
||||||
return;
|
|
||||||
|
|
||||||
get_win_size(&w, &h);
|
|
||||||
|
|
||||||
printf("\0337");
|
|
||||||
printf("\033[%d;%dr", (on) ? HEIGHT + 1 : 1, h);
|
|
||||||
printf("\0338");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "../libsample/sample.h"
|
#include "../libsample/sample.h"
|
||||||
#include "../libmobile/sender.h"
|
#include "../libmobile/sender.h"
|
||||||
|
#include "../libdebug/debug.h"
|
||||||
|
|
||||||
static int status_on = 0;
|
static int status_on = 0;
|
||||||
static int line_count = 0;
|
static int line_count = 0;
|
||||||
|
@ -70,20 +71,11 @@ void display_status_on(int on)
|
||||||
|
|
||||||
if (status_on)
|
if (status_on)
|
||||||
print_status(1);
|
print_status(1);
|
||||||
}
|
|
||||||
|
|
||||||
void display_status_limit_scroll(int on)
|
if (status_on)
|
||||||
{
|
debug_limit_scroll = lines_total;
|
||||||
int w, h;
|
else
|
||||||
|
debug_limit_scroll = 0;
|
||||||
if (!status_on)
|
|
||||||
return;
|
|
||||||
|
|
||||||
get_win_size(&w, &h);
|
|
||||||
|
|
||||||
printf("\0337");
|
|
||||||
printf("\033[%d;%dr", (on) ? lines_total + 1 : 1, h);
|
|
||||||
printf("\0338");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start status display */
|
/* start status display */
|
||||||
|
@ -142,6 +134,8 @@ void display_status_end(void)
|
||||||
print_status(1);
|
print_status(1);
|
||||||
/* set new total lines */
|
/* set new total lines */
|
||||||
lines_total = line_count;
|
lines_total = line_count;
|
||||||
|
if (status_on)
|
||||||
|
debug_limit_scroll = lines_total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include "../libsample/sample.h"
|
#include "../libsample/sample.h"
|
||||||
#include "../libmobile/sender.h"
|
#include "../libmobile/sender.h"
|
||||||
|
#include "../libdebug/debug.h"
|
||||||
|
|
||||||
#define HEIGHT 11
|
#define HEIGHT 11
|
||||||
|
|
||||||
|
@ -82,20 +83,11 @@ void display_wave_on(int on)
|
||||||
wave_on = 1 - wave_on;
|
wave_on = 1 - wave_on;
|
||||||
else
|
else
|
||||||
wave_on = on;
|
wave_on = on;
|
||||||
}
|
|
||||||
|
|
||||||
void display_wave_limit_scroll(int on)
|
if (wave_on)
|
||||||
{
|
debug_limit_scroll = HEIGHT * num_sender;
|
||||||
int w, h;
|
else
|
||||||
|
debug_limit_scroll = 0;
|
||||||
if (!wave_on)
|
|
||||||
return;
|
|
||||||
|
|
||||||
get_win_size(&w, &h);
|
|
||||||
|
|
||||||
printf("\0337");
|
|
||||||
printf("\033[%d;%dr", (on) ? num_sender * HEIGHT + 1 : 1, h);
|
|
||||||
printf("\0338");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "../libsample/sample.h"
|
#include "../libsample/sample.h"
|
||||||
#include "../libdebug/debug.h"
|
|
||||||
#include "../libfilter/iir_filter.h"
|
#include "../libfilter/iir_filter.h"
|
||||||
#include "emphasis.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) */
|
/* exp (-2 * PI * CUT_OFF * delta_t) */
|
||||||
factor = exp(-2.0 * PI * cut_off / (double)samplerate); /* 1/samplerate == 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.factor = factor;
|
||||||
state->p.amp = 1.0;
|
state->p.amp = 1.0;
|
||||||
state->d.factor = factor;
|
state->d.factor = factor;
|
||||||
|
|
|
@ -223,12 +223,39 @@ static int console_mncc_up(uint8_t *buf, int length)
|
||||||
return 0;
|
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 console_init(const char *station_id, const char *audiodev, int samplerate, int latency, int dial_digits, int loopback, int echo_test)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
init_testton();
|
init_testton();
|
||||||
|
|
||||||
|
clear_console_text = _clear_console_text;
|
||||||
|
print_console_text = _print_console_text;
|
||||||
|
|
||||||
memset(&console, 0, sizeof(console));
|
memset(&console, 0, sizeof(console));
|
||||||
strncpy(console.station_id, station_id, sizeof(console.station_id) - 1);
|
strncpy(console.station_id, station_id, sizeof(console.station_id) - 1);
|
||||||
strncpy(console.audiodev, audiodev, sizeof(console.audiodev) - 1);
|
strncpy(console.audiodev, audiodev, sizeof(console.audiodev) - 1);
|
||||||
|
@ -295,10 +322,6 @@ void console_cleanup(void)
|
||||||
jitter_destroy(&console.dejitter);
|
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)
|
static void process_ui(int c)
|
||||||
{
|
{
|
||||||
char text[256];
|
char text[256];
|
||||||
|
@ -395,26 +418,6 @@ dial_after_hangup:
|
||||||
fflush(stdout);
|
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
|
/* get keys from keyboad to control call via console
|
||||||
* returns 1 on exit (ctrl+c) */
|
* returns 1 on exit (ctrl+c) */
|
||||||
void process_console(int c)
|
void process_console(int c)
|
||||||
|
|
|
@ -4,7 +4,5 @@ void console_cleanup(void);
|
||||||
int console_open_audio(int latspl);
|
int console_open_audio(int latspl);
|
||||||
int console_start_audio(void);
|
int console_start_audio(void);
|
||||||
void console_process(int c);
|
void console_process(int c);
|
||||||
void clear_console_text(void);
|
|
||||||
void print_console_text(void);
|
|
||||||
void process_console(int c);
|
void process_console(int c);
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,7 @@ void sighandler(int sigset)
|
||||||
if (sigset == SIGPIPE)
|
if (sigset == SIGPIPE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (clear_console_text)
|
||||||
clear_console_text();
|
clear_console_text();
|
||||||
printf("Signal received: %d\n", sigset);
|
printf("Signal received: %d\n", sigset);
|
||||||
|
|
||||||
|
@ -570,6 +571,7 @@ next_char:
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 3:
|
case 3:
|
||||||
/* quit */
|
/* quit */
|
||||||
|
if (clear_console_text)
|
||||||
clear_console_text();
|
clear_console_text();
|
||||||
printf("CTRL+c received, quitting!\n");
|
printf("CTRL+c received, quitting!\n");
|
||||||
*quit = 1;
|
*quit = 1;
|
||||||
|
@ -664,6 +666,7 @@ next_char:
|
||||||
signal(SIGPIPE, SIG_DFL);
|
signal(SIGPIPE, SIG_DFL);
|
||||||
|
|
||||||
/* get rid of last entry */
|
/* get rid of last entry */
|
||||||
|
if (clear_console_text)
|
||||||
clear_console_text();
|
clear_console_text();
|
||||||
|
|
||||||
/* reset terminal */
|
/* reset terminal */
|
||||||
|
|
Loading…
Reference in New Issue