correct the offset words for rds2, group c always has the same offsets, but groups a and b have diffrent and can be sent via group c, so

This commit is contained in:
2025-03-24 21:31:57 +01:00
parent d65aab6956
commit 9516fdc95c
4 changed files with 22 additions and 24 deletions
+4
View File
@@ -12,6 +12,10 @@ The newer standard which is the IEC one, removes these features:
- PIN - PIN
- LIC - LIC
- DI (partially, only dynamic pty is left) - DI (partially, only dynamic pty is left)
- EWS (now ODA)
- IH (now ODA)
- RP
- TDC (now ODA)
## Unique features ## Unique features
+16 -22
View File
@@ -12,8 +12,7 @@ void msleep(unsigned long ms) {
int _strnlen(const char *s, int maxlen) { int _strnlen(const char *s, int maxlen) {
int len = 0; int len = 0;
while (s[len] != 0 && len < maxlen) while (s[len] != 0 && len < maxlen) len++;
len++;
return len; return len;
} }
@@ -25,24 +24,23 @@ static uint16_t offset_words[] = {
0x350 /* C' */ 0x350 /* C' */
}; };
void add_checkwords(uint16_t *blocks, uint8_t *bits) void add_checkwords(uint16_t *blocks, uint8_t *bits, uint8_t stream)
{ {
uint8_t i, j, bit, msb; uint16_t offset_word;
uint16_t block, block_crc, check, offset_word; bool group_type_b = IS_TYPE_B(blocks);
bool group_type_b = false; bool rds2_tunneling = (blocks[0] & 0xFE00) && (stream != 0);
if (IS_TYPE_B(blocks))
group_type_b = true;
for (i = 0; i < GROUP_LENGTH; i++) { for (uint8_t i = 0; i < GROUP_LENGTH; i++) {
if (i == 2 && group_type_b) { offset_word = offset_words[i];
if ((i == 2 && group_type_b && stream == 0) ||
(i == 2 && group_type_b && rds2_tunneling)) {
offset_word = offset_words[4]; offset_word = offset_words[4];
} else {
offset_word = offset_words[i];
} }
block = blocks[i]; uint16_t block = blocks[i];
block_crc = 0; uint16_t block_crc = 0;
uint8_t j, bit, msb;
for (j = 0; j < BLOCK_SIZE; j++) { for (j = 0; j < BLOCK_SIZE; j++) {
bit = (block & (0x8000 >> j)) != 0; bit = (block & (0x8000 >> j)) != 0;
msb = (block_crc >> (POLY_DEG - 1)) & 1; msb = (block_crc >> (POLY_DEG - 1)) & 1;
@@ -50,7 +48,7 @@ void add_checkwords(uint16_t *blocks, uint8_t *bits)
if (msb ^ bit) block_crc ^= POLY; if (msb ^ bit) block_crc ^= POLY;
*bits++ = bit; *bits++ = bit;
} }
check = block_crc ^ offset_word; uint16_t check = block_crc ^ offset_word;
for (j = 0; j < POLY_DEG; j++) { for (j = 0; j < POLY_DEG; j++) {
*bits++ = (check & ((1 << (POLY_DEG - 1)) >> j)) != 0; *bits++ = (check & ((1 << (POLY_DEG - 1)) >> j)) != 0;
} }
@@ -59,15 +57,11 @@ void add_checkwords(uint16_t *blocks, uint8_t *bits)
uint8_t add_rds_af(RDSAFs *af_list, float freq) { uint8_t add_rds_af(RDSAFs *af_list, float freq) {
uint16_t af; uint16_t af;
uint8_t entries_reqd = 1; uint8_t entries_reqd = 1;
if (freq < 87.6f || freq > 107.9f) entries_reqd = 2;
if (freq < 87.6f || freq > 107.9f) { if (af_list->num_afs + entries_reqd > MAX_AFS) return 1;
entries_reqd = 2;
}
if (af_list->num_afs + entries_reqd > MAX_AFS) {
return 1;
}
if (freq >= 87.6f && freq <= 107.9f) { if (freq >= 87.6f && freq <= 107.9f) {
af = (uint16_t)(freq * 10.0f) - 875; af = (uint16_t)(freq * 10.0f) - 875;
+1 -1
View File
@@ -2,6 +2,6 @@ extern void msleep(unsigned long ms);
extern int _strnlen(const char *s, int maxlen); extern int _strnlen(const char *s, int maxlen);
extern void add_checkwords(uint16_t *blocks, uint8_t *bits); extern void add_checkwords(uint16_t *blocks, uint8_t *bits, uint8_t stream);
extern uint8_t add_rds_af(RDSAFs *af_list, float freq); extern uint8_t add_rds_af(RDSAFs *af_list, float freq);
extern char *xlat(char *str); extern char *xlat(char *str);
+1 -1
View File
@@ -659,7 +659,7 @@ group_coded:
void get_rds_bits(RDSEncoder* enc, uint8_t *bits, uint8_t stream) { void get_rds_bits(RDSEncoder* enc, uint8_t *bits, uint8_t stream) {
static uint16_t out_blocks[GROUP_LENGTH]; static uint16_t out_blocks[GROUP_LENGTH];
get_rds_group(enc, out_blocks, stream); get_rds_group(enc, out_blocks, stream);
add_checkwords(out_blocks, bits); add_checkwords(out_blocks, bits, stream);
} }
static void init_rtplus(RDSEncoder* enc, uint8_t group, uint8_t program) { static void init_rtplus(RDSEncoder* enc, uint8_t group, uint8_t program) {