C-Netz: Fix scheduling of frames when there is nothing to send

pull/1/head
Andreas Eversberg 2 years ago
parent 09f8473c3b
commit 118b0260bc
  1. 10
      src/cnetz/cnetz.c
  2. 37
      src/cnetz/dsp.c
  3. 3
      src/cnetz/telegramm.c

@ -1300,9 +1300,10 @@ const telegramm_t *cnetz_transmit_telegramm_spk_k(cnetz_t *cnetz)
transaction_t *trans = cnetz->trans_list;
cnetz_t *ogk;
memset(&telegramm, 0, sizeof(telegramm));
if (!trans)
return &telegramm;
return NULL;
memset(&telegramm, 0, sizeof(telegramm));
telegramm.max_sendeleistung = cnetz_power2bits(cnetz->ms_power);
telegramm.sendeleistungsanpassung = (cnetz->ms_power < 8) ? 1 : 0;
@ -1623,9 +1624,10 @@ const telegramm_t *cnetz_transmit_telegramm_spk_v(cnetz_t *cnetz)
transaction_t *trans = cnetz->trans_list;
int meter = 0;
memset(&telegramm, 0, sizeof(telegramm));
if (!trans)
return &telegramm;
return NULL;
memset(&telegramm, 0, sizeof(telegramm));
if (cnetz->metering) {
double now = get_time();

@ -686,25 +686,38 @@ again:
/* set last time slot, so we know to which time slot the message from mobile station belongs to */
cnetz->sched_last_ts = cnetz->sched_ts;
bits = cnetz_encode_telegramm(cnetz);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Rufblock' at timeslot %d\n", cnetz->sched_ts);
if (bits) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Rufblock' at timeslot %d\n", cnetz->sched_ts);
fsk_block_encode(cnetz, bits, 1);
} else
fsk_nothing_encode(cnetz);
} else {
bits = cnetz_encode_telegramm(cnetz);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Meldeblock' at timeslot %d\n", cnetz->sched_ts);
if (bits) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Meldeblock' at timeslot %d\n", cnetz->sched_ts);
fsk_block_encode(cnetz, bits, 1);
} else
fsk_nothing_encode(cnetz);
}
fsk_block_encode(cnetz, bits, 1);
} else {
fsk_nothing_encode(cnetz);
}
break;
case DSP_MODE_SPK_K:
bits = cnetz_encode_telegramm(cnetz);
fsk_block_encode(cnetz, bits, 0);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Konzentrierte Signalisierung' at timeslot %d.%d\n", cnetz->sched_ts, cnetz->sched_r_m * 5);
if (bits) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Konzentrierte Signalisierung' at timeslot %d.%d\n", cnetz->sched_ts, cnetz->sched_r_m * 5);
fsk_block_encode(cnetz, bits, 0);
} else
fsk_nothing_encode(cnetz);
break;
case DSP_MODE_SPK_V:
bits = cnetz_encode_telegramm(cnetz);
fsk_distributed_encode(cnetz, bits);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Verteilte Signalisierung' starting at timeslot %d\n", cnetz->sched_ts);
if (bits) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Verteilte Signalisierung' starting at timeslot %d\n", cnetz->sched_ts);
fsk_distributed_encode(cnetz, bits);
} else
fsk_nothing_encode(cnetz);
break;
case DSP_MODE_OFF:
default:
@ -879,10 +892,12 @@ void cnetz_set_dsp_mode(cnetz_t *cnetz, enum dsp_mode mode)
void cnetz_set_sched_dsp_mode(cnetz_t *cnetz, enum dsp_mode mode, int timeslot)
{
if (mode != cnetz->dsp_mode) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Schedule DSP mode %s -> %s at timeslot %d\n", cnetz_dsp_mode_name(cnetz->dsp_mode), cnetz_dsp_mode_name(mode), timeslot);
cnetz->sched_dsp_mode = mode;
cnetz->sched_dsp_mode_ts = timeslot;
if (cnetz->sched_dsp_mode_ts < 0 && mode == cnetz->dsp_mode) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Schedule DSP mode %s not required, we are already in that mode\n", cnetz_dsp_mode_name(mode));
return;
}
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Schedule DSP mode %s -> %s at timeslot %d\n", cnetz_dsp_mode_name(cnetz->dsp_mode), cnetz_dsp_mode_name(mode), timeslot);
cnetz->sched_dsp_mode = mode;
cnetz->sched_dsp_mode_ts = timeslot;
}

@ -1597,6 +1597,9 @@ const char *cnetz_encode_telegramm(cnetz_t *cnetz)
;
}
if (!telegramm)
return NULL;
opcode = telegramm->opcode;
bits = assemble_telegramm(telegramm, (opcode != OPCODE_LR_R) && (opcode != OPCODE_MLR_M));
bits = encode(bits);

Loading…
Cancel
Save