C-Netz: Fixed multi-transceiver mode and show channel in various logs

This commit is contained in:
Andreas Eversberg
2016-07-31 15:09:46 +02:00
parent eb8a22e2c2
commit f729b32745
6 changed files with 91 additions and 74 deletions

View File

@@ -58,22 +58,30 @@ struct debug_cat {
int debuglevel = DEBUG_INFO;
uint64_t debug_mask = ~0;
extern int num_kanal;
void _printdebug(const char *file, const char *function, int line, int cat, int level, const char *fmt, ...)
void _printdebug(const char *file, const char *function, int line, int cat, int level, int chan, const char *fmt, ...)
{
char buffer[4096];
char buffer[4096], *b = buffer;
const char *p;
va_list args;
if (debuglevel > level)
return;
buffer[sizeof(buffer) - 1] = '\0';
/* if chan is used, prefix the channel number */
if (num_kanal > 1 && chan >= 0) {
sprintf(buffer, "(chan %d) ", chan);
b = strchr(buffer, '\0');
}
if (!(debug_mask & (1 << cat)))
return;
va_start(args, fmt);
vsnprintf(buffer, sizeof(buffer) - 1, fmt, args);
buffer[sizeof(buffer) - 1] = '\0';
vsnprintf(b, sizeof(buffer) - strlen(buffer) - 1, fmt, args);
va_end(args);
while ((p = strchr(file, '/')))

View File

@@ -20,8 +20,9 @@
#define DDMS 13
#define DSMS 14
#define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, fmt, ## arg)
void _printdebug(const char *file, const char *function, int line, int cat, int level, const char *fmt, ...);
#define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, -1, fmt, ## arg)
#define PDEBUG_CHAN(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, CHAN, fmt, ## arg)
void _printdebug(const char *file, const char *function, int line, int cat, int level, int chan, const char *fmt, ...);
const char *debug_amplitude(double level);

View File

@@ -20,6 +20,8 @@
/* Uncomment this for writing TX as wave (For debug purpose) */
//#define WAVE_WRITE_TX
#define CHAN sender->kanal
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@@ -38,7 +40,19 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
sender_t *master;
int rc = 0;
PDEBUG(DSENDER, DEBUG_DEBUG, "Creating 'Sender' instance\n");
sender->kanal = kanal;
strncpy(sender->sounddev, sounddev, sizeof(sender->sounddev) - 1);
sender->samplerate = samplerate;
sender->cross_channels = cross_channels;
sender->rx_gain = rx_gain;
sender->pre_emphasis = pre_emphasis;
sender->de_emphasis = de_emphasis;
sender->loopback = loopback;
sender->loss_volume = loss_volume;
sender->use_pilot_signal = use_pilot_signal;
sender->pilotton_phaseshift = 1.0 / ((double)samplerate / 1000.0);
PDEBUG_CHAN(DSENDER, DEBUG_DEBUG, "Creating 'Sender' instance\n");
/* if we find a channel that uses the same device as we do,
* we will link us as slave to this master channel. then we
@@ -89,18 +103,6 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
}
}
sender->samplerate = samplerate;
sender->cross_channels = cross_channels;
sender->rx_gain = rx_gain;
sender->pre_emphasis = pre_emphasis;
sender->de_emphasis = de_emphasis;
sender->kanal = kanal;
sender->loopback = loopback;
sender->loss_volume = loss_volume;
sender->use_pilot_signal = use_pilot_signal;
sender->pilotton_phaseshift = 1.0 / ((double)samplerate / 1000.0);
strncpy(sender->sounddev, sounddev, sizeof(sender->sounddev) - 1);
rc = init_samplerate(&sender->srstate, samplerate);
if (rc < 0) {
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to init sample rate conversion!\n");
@@ -148,7 +150,7 @@ error:
/* Destroy transceiver instance and unlink from list. */
void sender_destroy(sender_t *sender)
{
PDEBUG(DSENDER, DEBUG_DEBUG, "Destroying 'Sender' instance\n");
PDEBUG_CHAN(DSENDER, DEBUG_DEBUG, "Destroying 'Sender' instance\n");
sender_tailp = &sender_head;
while (*sender_tailp) {