Hi Leute .. ich will die RDS Infos decodieren aber bin mir nicht ganz sicher wie es funzt ..
die specs kosten ja richtig asche
habe mal im radio plugin gestoebert und was verdaechtiges gefunden aber bin mir nicht sicher .. evtl kann mir ja jemand helfer der sich da auskennt..
leider kenne ich mich mit c ansich auch noch nicht so gut aus .. komme aus der java welt.
danke und lg mentox
PS: ich vermute das das der relevante code ist plus die hilfs methoden bzw arrays ..
Code
for (int i = 0, val = 0; i < (TS_SIZE-offset); i++) {
val = Data[offset+i];
if (val == 0xfe) { // Start
index = -1;
rt_start = true;
rt_bstuff = false;
mec = 0;
if ((S_Verbose & 0x0f) >= 2)
printf("\nRDS-Start: ");
}
if (rt_start) {
if ((S_Verbose & 0x0f) >= 2)
printf("%02x ", val);
// byte-stuffing reverse: 0xfd00->0xfd, 0xfd01->0xfe, 0xfd02->0xff
if (rt_bstuff) {
switch (val) {
case 0x00: mtext[index] = 0xfd; break;
case 0x01: mtext[index] = 0xfe; break;
case 0x02: mtext[index] = 0xff; break;
default: mtext[++index] = val; // should never be
}
rt_bstuff = false;
if ((S_Verbose & 0x0f) >= 2)
printf("(Bytestuffing -> %02x) ", mtext[index]);
}
else
mtext[++index] = val;
if (val == 0xfd && index > 0) // stuffing found
rt_bstuff = true;
// early check for used MEC
if (index == 5) {
//mec = val;
switch (val) {
case 0x0a: // RT
case 0x46: // ODA-Data
case 0x07: // PTY
case 0x3e: // PTYN
case 0x30: // TMC
case 0x02: mec = val; // PS
RdsLogo = true;
break;
default: rt_start = false;
if ((S_Verbose & 0x0f) >= 2)
printf("[RDS-MEC '%02x' not used -> End]\n", val);
}
}
if (index >= mframel) { // max. rdslength, garbage ?
rt_start = false;
if ((S_Verbose & 0x0f) >= 2)
printf("(RDS-Error: too long, garbage ?)\n");
}
}
if (rt_start && val == 0xff) { // End
rt_start = false;
if ((S_Verbose & 0x0f) >= 2)
printf("(RDS-End)\n");
if (index < 9) { // min. rdslength, garbage ?
if ((S_Verbose & 0x0f) >= 1)
printf("RDS-Error: too short -> garbage ?\n");
}
else {
// crc16-check
unsigned short crc16 = crc16_ccitt(mtext, index-3, true);
if (crc16 != (mtext[index-2]<<8)+mtext[index-1]) {
if ((S_Verbose & 0x0f) >= 1)
printf("RDS-Error: wrong CRC # calc = %04x <> transmit = %02x%02x\n", crc16, mtext[index-2], mtext[index-1]);
}
else {
switch (mec) {
case 0x0a: RadioAudio->RadiotextDecode(mtext, index); // Radiotext
break;
case 0x46: switch ((mtext[7]<<8)+mtext[8]) { // ODA-ID
case 0x4bd7: RadioAudio->RadiotextDecode(mtext, index); // RT+
break;
case 0x0d45:
case 0xcd46: if ((S_Verbose & 0x20) > 0) {
unsigned char tmc[6]; // TMC Alert-C
int i;
for (i=9; i<=(index-3); i++)
tmc[i-9] = mtext[i];
tmc_parser(tmc, i-8);
}
break;
default: if ((S_Verbose & 0x0f) >= 2)
printf("[RDS-ODA AID '%02x%02x' not used -> End]\n", mtext[7], mtext[8]);
}
break;
case 0x07: RT_PTY = mtext[8]; // PTY
if ((S_Verbose & 0x0f) >= 1)
printf("RDS-PTY set to '%s'\n", ptynr2string(RT_PTY));
break;
case 0x3e: RadioAudio->RDS_PsPtynDecode(true, mtext, index); // PTYN
break;
case 0x02: RadioAudio->RDS_PsPtynDecode(false, mtext, index); // PS
break;
case 0x30: if ((S_Verbose & 0x20) > 0) { // TMC Alert-C
unsigned char tmc[6];
int i;
for (i=7; i<=(index-3); i++)
tmc[i-7] = mtext[i];
tmc_parser(tmc, i-6);
}
break;
}
}
}
}
}
}
Alles anzeigen