X-Git-Url: https://git.karo-electronics.de/?p=rdstmc.git;a=blobdiff_plain;f=decoder%2Frds.c;fp=decoder%2Frds.c;h=ca927b2e9c753364482100031e695b5332c656fe;hp=bdaee7b9fe76ff0f8e2bb75da20a704a3a18f3d0;hb=068df065c2148fd7932e4b4c3f67bdf59b70df4b;hpb=d4f8c46bc4a5cad443611ac86bfe0a83a9d1b49b diff --git a/decoder/rds.c b/decoder/rds.c index bdaee7b..ca927b2 100644 --- a/decoder/rds.c +++ b/decoder/rds.c @@ -138,10 +138,18 @@ enum RDSGroupType { GROUP_0A=0, GROUP_0B, GROUP_1A, GROUP_1B, GROUP_2A, GROUP_2B GROUP_12A, GROUP_12B, GROUP_13A, GROUP_13B, GROUP_14A, GROUP_14B, GROUP_15A, GROUP_15B, GROUP_UNKNOWN }; +void rds_radio_retuned(void) +{ + memset(&rds_info, 0, sizeof(rds_info)); + rds_info.LTN = -1; + memset(&rds_time, 0, sizeof(rds_time)); +} + void rds_decode_group(unsigned short *rdsgroup) { static unsigned short ogrp[4]; static unsigned char grp_decoded = 0; +static unsigned char sname_rcvd = 0; unsigned char grp_type = (rdsgroup[1] >> 11); unsigned char offs; static unsigned char otextAB = 0, newtext = 0; @@ -172,6 +180,7 @@ int year_, mon_, K; rds_info.ccode = (PI & 0xf000) >> 12; rds_info.ptype = (PI & 0x0f00) >> 8; rds_info.pref = (PI & 0x00ff); + sname_rcvd = 0; if (rds_info.pref == 0) /* something is wrong here */ return; rds_info.PI = rdsgroup[0]; @@ -187,10 +196,20 @@ int year_, mon_, K; float AF1=0, AF2=0; offs = (rdsgroup[1] & 0x03); + if (offs == 0) + sname_rcvd = 0; + if (offs == 1 && sname_rcvd == 0) + sname_rcvd = 1; + if (offs == 2 && sname_rcvd == 1) + sname_rcvd = 2; + if (offs == 3 && sname_rcvd == 2) + sname_rcvd = 3; rds_info.sname[offs*2] = ((rdsgroup[3] & 0xff00) >> 8); rds_info.sname[(offs*2)+1] = rdsgroup[3] & 0x00ff; - if (_rds_private.rds_sname_cb != NULL) + if (_rds_private.rds_sname_cb != NULL && sname_rcvd == 3) { _rds_private.rds_sname_cb(rds_info.sname, _rds_private.rds_sname_cb_data); + sname_rcvd = 0; + } rds_info.TA = (rdsgroup[1] & 0x10) >> 4; rds_info.TP = (rdsgroup[1] & 0x400) >> 10;