B-Netz: Work on pilot signal generation
The pilot signal to switch to channel 19 can be: * a tone * a tone that is turned off (notone) * positive amplitude * negative amplitude
This commit is contained in:
committed by
Andreas Eversberg
parent
e029a6a858
commit
b205cfcf03
@@ -400,7 +400,7 @@ int amps_create(int channel, enum amps_chan_type chan_type, const char *sounddev
|
|||||||
PDEBUG(DAMPS, DEBUG_DEBUG, "Creating 'AMPS' instance for channel = %d (sample rate %d).\n", channel, samplerate);
|
PDEBUG(DAMPS, DEBUG_DEBUG, "Creating 'AMPS' instance for channel = %d (sample rate %d).\n", channel, samplerate);
|
||||||
|
|
||||||
/* init general part of transceiver */
|
/* init general part of transceiver */
|
||||||
rc = sender_create(&s->sender, channel, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_wave, read_wave, loopback, 0, -1);
|
rc = sender_create(&s->sender, channel, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_wave, read_wave, loopback, 0, PILOT_SIGNAL_NONE);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
@@ -156,7 +156,7 @@ int anetz_create(int kanal, const char *sounddev, int samplerate, int cross_chan
|
|||||||
PDEBUG(DANETZ, DEBUG_DEBUG, "Creating 'A-Netz' instance for 'Kanal' = %d (sample rate %d).\n", kanal, samplerate);
|
PDEBUG(DANETZ, DEBUG_DEBUG, "Creating 'A-Netz' instance for 'Kanal' = %d (sample rate %d).\n", kanal, samplerate);
|
||||||
|
|
||||||
/* init general part of transceiver */
|
/* init general part of transceiver */
|
||||||
rc = sender_create(&anetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, loss_volume, -1);
|
rc = sender_create(&anetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, loss_volume, PILOT_SIGNAL_NONE);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
PDEBUG(DANETZ, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
|
PDEBUG(DANETZ, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
@@ -207,17 +207,15 @@ static struct impulstelegramme *bnetz_telegramm(int digit)
|
|||||||
/* switch pilot signal (tone or file) */
|
/* switch pilot signal (tone or file) */
|
||||||
static void switch_channel_19(bnetz_t *bnetz, int on)
|
static void switch_channel_19(bnetz_t *bnetz, int on)
|
||||||
{
|
{
|
||||||
if (bnetz->sender.use_pilot_signal >= 0) {
|
/* affects only if pilot signal is used */
|
||||||
bnetz->sender.pilot_on = on;
|
sender_pilot(&bnetz->sender, on);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bnetz->pilot_file && bnetz->pilot_is_on != on) {
|
if (bnetz->pilot_file[0] && bnetz->pilot_is_on != on) {
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
fp = fopen(bnetz->pilot_file, "w");
|
fp = fopen(bnetz->pilot_file, "w");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to open file '%s' to switch channel 19!\n");
|
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to open file '%s' to switch channel 19!\n", bnetz->pilot_file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fprintf(fp, "%s\n", (on) ? bnetz->pilot_on : bnetz->pilot_off);
|
fprintf(fp, "%s\n", (on) ? bnetz->pilot_on : bnetz->pilot_off);
|
||||||
@@ -250,7 +248,7 @@ static void bnetz_go_idle(bnetz_t *bnetz);
|
|||||||
int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_factor, const char *pilot)
|
int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_factor, const char *pilot)
|
||||||
{
|
{
|
||||||
bnetz_t *bnetz;
|
bnetz_t *bnetz;
|
||||||
int use_pilot_tone = -1;
|
enum pilot_signal pilot_signal = PILOT_SIGNAL_NONE;
|
||||||
char pilot_file[256] = "", pilot_on[256] = "", pilot_off[256] = "";
|
char pilot_file[256] = "", pilot_on[256] = "", pilot_off[256] = "";
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -269,14 +267,17 @@ int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_chan
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(pilot, "notone"))
|
||||||
|
pilot_signal = PILOT_SIGNAL_NOTONE;
|
||||||
|
else
|
||||||
if (!strcmp(pilot, "tone"))
|
if (!strcmp(pilot, "tone"))
|
||||||
use_pilot_tone = 2;
|
pilot_signal = PILOT_SIGNAL_TONE;
|
||||||
else
|
else
|
||||||
if (!strcmp(pilot, "positive"))
|
if (!strcmp(pilot, "positive"))
|
||||||
use_pilot_tone = 1;
|
pilot_signal = PILOT_SIGNAL_POSITIVE;
|
||||||
else
|
else
|
||||||
if (!strcmp(pilot, "negative"))
|
if (!strcmp(pilot, "negative"))
|
||||||
use_pilot_tone = 0;
|
pilot_signal = PILOT_SIGNAL_NEGATIVE;
|
||||||
else {
|
else {
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
@@ -305,7 +306,7 @@ error_pilot:
|
|||||||
PDEBUG(DBNETZ, DEBUG_DEBUG, "Creating 'B-Netz' instance for 'Kanal' = %d 'Gruppenfreisignal' = %d (sample rate %d).\n", kanal, gfs, samplerate);
|
PDEBUG(DBNETZ, DEBUG_DEBUG, "Creating 'B-Netz' instance for 'Kanal' = %d 'Gruppenfreisignal' = %d (sample rate %d).\n", kanal, gfs, samplerate);
|
||||||
|
|
||||||
/* init general part of transceiver */
|
/* init general part of transceiver */
|
||||||
rc = sender_create(&bnetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, loss_factor, use_pilot_tone);
|
rc = sender_create(&bnetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, loss_factor, pilot_signal);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
@@ -55,11 +55,12 @@ void print_help(const char *arg0)
|
|||||||
printf(" Set to 19 in order to make the phone transmit at 100 mW instead of\n");
|
printf(" Set to 19 in order to make the phone transmit at 100 mW instead of\n");
|
||||||
printf(" full 15 Watts. If supported, the phone uses the channel with low power\n");
|
printf(" full 15 Watts. If supported, the phone uses the channel with low power\n");
|
||||||
printf(" (Kanal kleiner Leistung).\n");
|
printf(" (Kanal kleiner Leistung).\n");
|
||||||
printf(" -P --pilot tone | positive | negative | <file>=<on>:<off>\n");
|
printf(" -P --pilot tone | notone | positive | negative | <file>=<on>:<off>\n");
|
||||||
printf(" Send a tone, give a signal or write to a file when switching to\n");
|
printf(" Send a tone, give a signal or write to a file when switching to\n");
|
||||||
printf(" channel 19. (paging the phone).\n");
|
printf(" channel 19. (paging the phone).\n");
|
||||||
printf(" 'tone', 'positive', 'negative' is sent on second audio channel.\n");
|
printf(" 'tone', 'positive', 'negative' is sent on second audio channel.\n");
|
||||||
printf(" 'tone' sends a tone whenever channel 19 is switchted.\n");
|
printf(" 'tone' sends a tone whenever channel 19 is switched.\n");
|
||||||
|
printf(" 'notone' sends a tone whenever channel 19 is NOT switched.\n");
|
||||||
printf(" 'positive' sends a positive signal for channel 19, else negative.\n");
|
printf(" 'positive' sends a positive signal for channel 19, else negative.\n");
|
||||||
printf(" 'negative' sends a negative signal for channel 19, else positive.\n");
|
printf(" 'negative' sends a negative signal for channel 19, else positive.\n");
|
||||||
printf(" Example: /sys/class/gpio/gpio17/value=1:0 writes a '1' to\n");
|
printf(" Example: /sys/class/gpio/gpio17/value=1:0 writes a '1' to\n");
|
||||||
|
@@ -235,7 +235,7 @@ int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev
|
|||||||
|
|
||||||
/* init general part of transceiver */
|
/* init general part of transceiver */
|
||||||
/* do not enable emphasis, since it is done by cnetz code, not by common sender code */
|
/* do not enable emphasis, since it is done by cnetz code, not by common sender code */
|
||||||
rc = sender_create(&cnetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_wave, read_wave, loopback, 0, -1);
|
rc = sender_create(&cnetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_wave, read_wave, loopback, 0, PILOT_SIGNAL_NONE);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
@@ -35,7 +35,7 @@ static sender_t **sender_tailp = &sender_head;
|
|||||||
int cant_recover = 0;
|
int cant_recover = 0;
|
||||||
|
|
||||||
/* Init transceiver instance and link to list of transceivers. */
|
/* Init transceiver instance and link to list of transceivers. */
|
||||||
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume, int use_pilot_signal)
|
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal)
|
||||||
{
|
{
|
||||||
sender_t *master;
|
sender_t *master;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
@@ -49,7 +49,7 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
|
|||||||
sender->de_emphasis = de_emphasis;
|
sender->de_emphasis = de_emphasis;
|
||||||
sender->loopback = loopback;
|
sender->loopback = loopback;
|
||||||
sender->loss_volume = loss_volume;
|
sender->loss_volume = loss_volume;
|
||||||
sender->use_pilot_signal = use_pilot_signal;
|
sender->pilot_signal = pilot_signal;
|
||||||
sender->pilotton_phaseshift = 1.0 / ((double)samplerate / 1000.0);
|
sender->pilotton_phaseshift = 1.0 / ((double)samplerate / 1000.0);
|
||||||
|
|
||||||
PDEBUG_CHAN(DSENDER, DEBUG_DEBUG, "Creating 'Sender' instance\n");
|
PDEBUG_CHAN(DSENDER, DEBUG_DEBUG, "Creating 'Sender' instance\n");
|
||||||
@@ -79,12 +79,12 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
|
|||||||
rc = -EBUSY;
|
rc = -EBUSY;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (master->use_pilot_signal >= 0) {
|
if (master->pilot_signal != PILOT_SIGNAL_NONE) {
|
||||||
PDEBUG(DSENDER, DEBUG_ERROR, "Cannot share sound device with channel %d, because second channel is used for pilot signal!\n", master->kanal);
|
PDEBUG(DSENDER, DEBUG_ERROR, "Cannot share sound device with channel %d, because second channel is used for pilot signal!\n", master->kanal);
|
||||||
rc = -EBUSY;
|
rc = -EBUSY;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (use_pilot_signal >= 0) {
|
if (pilot_signal != PILOT_SIGNAL_NONE) {
|
||||||
PDEBUG(DSENDER, DEBUG_ERROR, "Cannot share sound device with channel %d, because we need a stereo channel for pilot signal!\n", master->kanal);
|
PDEBUG(DSENDER, DEBUG_ERROR, "Cannot share sound device with channel %d, because we need a stereo channel for pilot signal!\n", master->kanal);
|
||||||
rc = -EBUSY;
|
rc = -EBUSY;
|
||||||
goto error;
|
goto error;
|
||||||
@@ -277,8 +277,8 @@ cant_recover:
|
|||||||
if (slave->pre_emphasis)
|
if (slave->pre_emphasis)
|
||||||
pre_emphasis(&slave->estate, slave_samples, count);
|
pre_emphasis(&slave->estate, slave_samples, count);
|
||||||
}
|
}
|
||||||
switch (sender->use_pilot_signal) {
|
switch (sender->pilot_signal) {
|
||||||
case 2:
|
case PILOT_SIGNAL_TONE:
|
||||||
/* tone if pilot signal is on */
|
/* tone if pilot signal is on */
|
||||||
if (sender->pilot_on)
|
if (sender->pilot_on)
|
||||||
gen_pilotton(sender, pilot, count);
|
gen_pilotton(sender, pilot, count);
|
||||||
@@ -289,7 +289,18 @@ cant_recover:
|
|||||||
else
|
else
|
||||||
rc = sound_write(sender->sound, pilot, samples, count);
|
rc = sound_write(sender->sound, pilot, samples, count);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case PILOT_SIGNAL_NOTONE:
|
||||||
|
/* tone if pilot signal is off */
|
||||||
|
if (!sender->pilot_on)
|
||||||
|
gen_pilotton(sender, pilot, count);
|
||||||
|
else
|
||||||
|
memset(pilot, 0, count << 1);
|
||||||
|
if (!sender->cross_channels)
|
||||||
|
rc = sound_write(sender->sound, samples, pilot, count);
|
||||||
|
else
|
||||||
|
rc = sound_write(sender->sound, pilot, samples, count);
|
||||||
|
break;
|
||||||
|
case PILOT_SIGNAL_POSITIVE:
|
||||||
/* positive signal if pilot signal is on */
|
/* positive signal if pilot signal is on */
|
||||||
if (sender->pilot_on)
|
if (sender->pilot_on)
|
||||||
memset(pilot, 127, count << 1);
|
memset(pilot, 127, count << 1);
|
||||||
@@ -300,7 +311,7 @@ cant_recover:
|
|||||||
else
|
else
|
||||||
rc = sound_write(sender->sound, pilot, samples, count);
|
rc = sound_write(sender->sound, pilot, samples, count);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case PILOT_SIGNAL_NEGATIVE:
|
||||||
/* negative signal if pilot signal is on */
|
/* negative signal if pilot signal is on */
|
||||||
if (sender->pilot_on)
|
if (sender->pilot_on)
|
||||||
memset(pilot, 128, count << 1);
|
memset(pilot, 128, count << 1);
|
||||||
@@ -393,3 +404,8 @@ cant_recover:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sender_pilot(sender_t *sender, int on)
|
||||||
|
{
|
||||||
|
sender->pilot_on = on;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -8,6 +8,15 @@
|
|||||||
|
|
||||||
#define MAX_SENDER 16
|
#define MAX_SENDER 16
|
||||||
|
|
||||||
|
/* how to send a 'pilot' signal (trigger transmitter) */
|
||||||
|
enum pilot_signal {
|
||||||
|
PILOT_SIGNAL_NONE = 0,
|
||||||
|
PILOT_SIGNAL_TONE,
|
||||||
|
PILOT_SIGNAL_NOTONE,
|
||||||
|
PILOT_SIGNAL_POSITIVE,
|
||||||
|
PILOT_SIGNAL_NEGATIVE,
|
||||||
|
};
|
||||||
|
|
||||||
/* common structure of each transmitter */
|
/* common structure of each transmitter */
|
||||||
typedef struct sender {
|
typedef struct sender {
|
||||||
struct sender *next;
|
struct sender *next;
|
||||||
@@ -47,7 +56,7 @@ typedef struct sender {
|
|||||||
loss_t loss;
|
loss_t loss;
|
||||||
|
|
||||||
/* pilot tone */
|
/* pilot tone */
|
||||||
int use_pilot_signal; /* -1 if not used, 1 for positive, 0 for negative, 2 for tone */
|
enum pilot_signal pilot_signal; /* if pilot signal is used and how it is performed */
|
||||||
int pilot_on; /* 1 or 0 for on or off */
|
int pilot_on; /* 1 or 0 for on or off */
|
||||||
double pilotton_phaseshift; /* phase to shift every sample */
|
double pilotton_phaseshift; /* phase to shift every sample */
|
||||||
double pilotton_phase; /* current phase */
|
double pilotton_phase; /* current phase */
|
||||||
@@ -60,9 +69,10 @@ typedef struct sender {
|
|||||||
extern sender_t *sender_head;
|
extern sender_t *sender_head;
|
||||||
extern int cant_recover;
|
extern int cant_recover;
|
||||||
|
|
||||||
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume, int use_pilot_signal);
|
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal);
|
||||||
void sender_destroy(sender_t *sender);
|
void sender_destroy(sender_t *sender);
|
||||||
void process_sender_audio(sender_t *sender, int *quit, int latspl);
|
void process_sender_audio(sender_t *sender, int *quit, int latspl);
|
||||||
void sender_send(sender_t *sender, int16_t *samples, int count);
|
void sender_send(sender_t *sender, int16_t *samples, int count);
|
||||||
void sender_receive(sender_t *sender, int16_t *samples, int count);
|
void sender_receive(sender_t *sender, int16_t *samples, int count);
|
||||||
|
void sender_pilot(sender_t *sender, int on);
|
||||||
|
|
||||||
|
@@ -334,7 +334,7 @@ int nmt_create(int channel, enum nmt_chan_type chan_type, const char *sounddev,
|
|||||||
PDEBUG(DNMT, DEBUG_DEBUG, "Creating 'NMT' instance for channel = %d (sample rate %d).\n", channel, samplerate);
|
PDEBUG(DNMT, DEBUG_DEBUG, "Creating 'NMT' instance for channel = %d (sample rate %d).\n", channel, samplerate);
|
||||||
|
|
||||||
/* init general part of transceiver */
|
/* init general part of transceiver */
|
||||||
rc = sender_create(&nmt->sender, channel, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, 0, -1);
|
rc = sender_create(&nmt->sender, channel, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, 0, PILOT_SIGNAL_NONE);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
PDEBUG(DNMT, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
PDEBUG(DNMT, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
Reference in New Issue
Block a user