aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2020-12-20 19:21:52 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2020-12-21 08:38:44 +0100
commit118b0260bcac528cb99d1b88ce57da1dd752c71a (patch)
treeecd457556ad2f349c720205a72e7621a2003f7bb
parent09f8473c3b04f08a9b433282402fea96ce5c1404 (diff)
C-Netz: Fix scheduling of frames when there is nothing to send
-rw-r--r--src/cnetz/cnetz.c10
-rw-r--r--src/cnetz/dsp.c37
-rw-r--r--src/cnetz/telegramm.c3
3 files changed, 35 insertions, 15 deletions
diff --git a/src/cnetz/cnetz.c b/src/cnetz/cnetz.c
index 97c8795..e09a52b 100644
--- a/src/cnetz/cnetz.c
+++ b/src/cnetz/cnetz.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();
diff --git a/src/cnetz/dsp.c b/src/cnetz/dsp.c
index 1c03b6d..493c515 100644
--- a/src/cnetz/dsp.c
+++ b/src/cnetz/dsp.c
@@ -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;
}
diff --git a/src/cnetz/telegramm.c b/src/cnetz/telegramm.c
index e6f8a5d..f74fffd 100644
--- a/src/cnetz/telegramm.c
+++ b/src/cnetz/telegramm.c
@@ -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);