28 #include "boost/format.hpp" 74 {
"DE",
"GR",
"MA",
"__",
"MD"},
75 {
"DZ",
"CY",
"CZ",
"IE",
"EE"},
76 {
"AD",
"SM",
"PL",
"TR",
"__"},
77 {
"IL",
"CH",
"VA",
"MK",
"__"},
78 {
"IT",
"JO",
"SK",
"__",
"__"},
79 {
"BE",
"FI",
"SY",
"__",
"UA"},
80 {
"RU",
"LU",
"TN",
"__",
"__"},
81 {
"PS",
"BG",
"__",
"NL",
"PT"},
82 {
"AL",
"DK",
"LI",
"LV",
"SI"},
83 {
"AT",
"GI",
"IS",
"LB",
"__"},
84 {
"HU",
"IQ",
"MC",
"__",
"__"},
85 {
"MT",
"GB",
"LT",
"HR",
"__"},
86 {
"DE",
"LY",
"YU",
"__",
"__"},
87 {
"__",
"RO",
"ES",
"SE",
"__"},
88 {
"EG",
"FR",
"NO",
"BY",
"BA"}
202 {
"no duration given",
"no duration given"},
203 {
"15 minutes",
"next few hours"},
204 {
"30 minutes",
"rest of the day"},
205 {
"1 hour",
"until tomorrow evening"},
206 {
"2 hours",
"rest of the week"},
207 {
"3 hours",
"end of next week"},
208 {
"4 hours",
"end of the month"},
209 {
"rest of the day",
"long period"}
214 const int RDSParser::optional_content_lengths[16] = {3,3,5,5,5,8,8,8,8,11,16,16,16,16,0,0};
219 "Length of route affected",
220 "Speed limit advice",
223 "Supplementary information code",
224 "Explicit start time",
225 "Explicit stop time",
227 "Detailed diversion instructions",
229 "RFU (Reserved for future use)",
230 "Cross linkage to source of problem, or another route",
232 "RFU (Reserved for future use)" 376 unsigned int group_type = (
unsigned int)((group[1] >> 12) & 0xf);
377 bool ab = (group[1] >> 11 ) & 0x1;
407 switch (group_type) {
469 unsigned int af_code_1 = 0;
470 unsigned int af_code_2 = 0;
471 unsigned int no_af = 0;
482 bool decoder_control_bit = (group[1] >> 2) & 0x01;
483 unsigned char segment_address = group[1] & 0x03;
485 if (segment_address == 0)
497 switch (segment_address)
524 static std::string af_string;
528 af_code_1 = int(group[2] >> 8) & 0xff;
529 af_code_2 = int(group[2]) & 0xff;
590 static bool vhf_or_lfmf = 0;
591 double alt_frequency = 0;
593 if ((af_code == 0) ||
595 ((af_code >= 206) && (af_code <= 223)) ||
602 if ((af_code >= 225) && (af_code <= 249))
614 if ((af_code > 0) && (af_code < 205) && vhf_or_lfmf) {
615 alt_frequency = 100.0 * (af_code + 875);
617 else if ((af_code > 0) && (af_code < 16) && !vhf_or_lfmf) {
618 alt_frequency = 153.0 + (af_code - 1) * 9;
620 else if ((af_code > 15) && (af_code < 136) && !vhf_or_lfmf) {
621 alt_frequency = 531.0 + (af_code - 16) * 9 + 531;
624 return alt_frequency;
631 char country_code = (group[0] >> 12) & 0x0f;
632 char radio_paging_codes = group[1] & 0x1f;
633 int variant_code = (group[2] >> 12) & 0x7;
634 unsigned int slow_labelling = group[2] & 0xfff;
641 if (radio_paging_codes) {
654 switch (variant_code)
657 paging = (slow_labelling >> 8) & 0x0f;
658 ecc = slow_labelling & 0xff;
662 if ((ecc > 223) && (ecc < 229)) {
670 qDebug() <<
"RDSParser::decode_type1: " <<
"invalid extended country code: " << ecc;
680 if (slow_labelling < 44) {
685 qDebug() <<
"RDSParser::decode_type1: " <<
"language: invalid language code " << slow_labelling;
696 unsigned char text_segment_address_code = group[1] & 0x0f;
712 m_g2_radiotext[text_segment_address_code * 4 ] = (group[2] >> 8) & 0xff;
713 m_g2_radiotext[text_segment_address_code * 4 + 1] = group[2] & 0xff;
714 m_g2_radiotext[text_segment_address_code * 4 + 2] = (group[3] >> 8) & 0xff;
715 m_g2_radiotext[text_segment_address_code * 4 + 3] = group[3] & 0xff;
719 m_g2_radiotext[text_segment_address_code * 2 ] = (group[3] >> 8) & 0xff;
720 m_g2_radiotext[text_segment_address_code * 2 + 1] = group[3] & 0xff;
731 qDebug() <<
"RDSParser::decode_type3: type 3B not implemented yet";
735 int application_group = (group[1] >> 1) & 0xf;
736 int group_type = group[1] & 0x1;
737 int message = group[2];
748 if ((application_group == 8) && (group_type == 0))
750 int variant_code = (message >> 14) & 0x3;
752 if (variant_code == 0)
772 else if (variant_code==1)
795 qDebug() <<
"RDSParser::decode_type4: type 4B not implemented yet";
802 m_g4_hours = ((group[2] & 0x1) << 4) | ((group[3] >> 12) & 0x0f);
806 if ((group[3] >> 5) & 0x1) {
810 double modified_julian_date = ((group[1] & 0x03) << 15) | ((group[2] >> 1) & 0x7fff);
812 m_g4_year = int((modified_julian_date - 15078.2) / 365.25);
831 qDebug() <<
"RDSParser::decode_type5: type5 not implemented yet";
839 qDebug() <<
"RDSParser::decode_type6: type 6 not implemented yet";
847 qDebug() <<
"RDSParser::decode_type7: type 7 not implemented yet";
856 qDebug() <<
"RDSParser::decode_type8: type 8B not implemented yet";
863 bool T = (group[1] >> 4) & 0x1;
864 bool F = (group[1] >> 3) & 0x1;
865 bool D = (group[2] >> 15) & 0x1;
868 static unsigned long int free_format[4];
869 static int no_groups = 0;
873 qDebug() <<
"RDSParser::decode_type8: #tuning info# ";
874 int variant = group[1] & 0xf;
876 if((variant > 3) && (variant < 10)) {
877 qDebug() <<
"RDSParser::decode_type8: variant: " << variant <<
" - " 878 << group[2] <<
" " << group[3];
880 qDebug() <<
"RDSParser::decode_type8: invalid variant: " << variant;
892 qDebug() <<
"RDSParser::decode_type8: #user msg# " << (D ?
"diversion recommended, " :
"");
897 qDebug() <<
"RDSParser::decode_type8: multi-grp, continuity index:" <<
m_g8_dp_ci;
902 qDebug() <<
"RDSParser::decode_type8: extent:" << (
m_g8_sign ?
"-" :
"") <<
m_g8_extent + 1 <<
" segments" 909 unsigned int ci = group[1] & 0x7;
910 bool sg = (group[2] >> 14) & 0x1;
911 unsigned int gsi = (group[2] >> 12) & 0x3;
913 qDebug() <<
"RDSParser::decode_type8: #user msg# multi-grp, continuity index:" << ci
914 << (sg ?
", second group" :
"") <<
", gsi:" << gsi;
916 qDebug() <<
"RDSParser::decode_type8: free format: " << (group[2] & 0xfff) <<
" " 924 free_format[gsi] = ((group[2] & 0xfff) << 12) | group[3];
934 int content_length = 0;
942 ff_pointer = 12 + 16;
944 while(ff_pointer >= 7)
949 ff_pointer -= content_length;
950 m_g8_content = (free_format[
i] && ((int(std::pow(2, content_length) - 1) << ff_pointer) != 0)) ? 1 : 0;
952 qDebug() <<
"RDSParser::decode_optional_content:" 981 qDebug() <<
"RDSParser::decode_type10: type 10 not implemented yet";
990 qDebug() <<
"RDSParser::decode_type11: type 11 not implemented yet";
999 qDebug() <<
"RDSParser::decode_type12: type 12 not implemented yet";
1008 qDebug() <<
"RDSParser::decode_type13: type 13 not implemented yet";
1015 char variant_code = group[1] & 0x0f;
1016 unsigned int information = group[2];
1017 unsigned int pi_on = group[3];
1028 switch (variant_code)
1043 af_1 = 100.0 * (((information >> 8) & 0xff) + 875);
1044 af_2 = 100.0 * ((information & 0xff) + 875);
1057 af_1 = 100.0 * (((information >> 8) & 0xff) + 875);
1058 af_2 = 100.0 * ((information & 0xff) + 875);
1067 af_1 = 100.0 * (((information >> 8) & 0xff) + 875);
1068 af_2 = 9.0 * ((information & 0xff) - 16) + 531;
1095 std::pair<freqs_map_t::iterator, bool> retMap;
1096 std::pair<freqs_set_t::iterator, bool> retSet;
1097 bool updated =
false;
1104 updated |= retMap.second;
1111 for (; sIt != sItEnd; ++sIt)
1113 retSet = (mIt->second).insert(*sIt);
1114 updated |= retSet.second;
1126 std::pair<freqs_map_t::iterator, bool> retMap;
1127 std::pair<freqs_set_t::iterator, bool> retSet;
1128 bool updated =
false;
1135 updated |= retMap.second;
1142 for (; sIt != sItEnd; ++sIt)
1144 retSet = (mIt->second).insert(*sIt);
1145 updated |= retSet.second;
1160 ta_on = information & 0x01;
1163 qDebug() <<
"RDSParser::decode_type14: - TA";
1198 qDebug() <<
"RDSParser::decode_type5: type 15 not implemented yet";
unsigned int m_pi_program_identification
static const std::string rds_group_acronyms[16]
void decode_type0(unsigned int *group, bool B)
unsigned int m_g4_seconds
void parseGroup(unsigned int *group)
void decode_type8(unsigned int *group, bool B)
static const std::string pty_table[32]
void decode_type12(unsigned int *group, bool B)
std::set< double > m_g14_mapped_freq_set
psns_map_t m_g14_program_service_names
key: PI, value: PSN
void decode_type14(unsigned int *group, bool B)
char m_g0_program_service_name[8+1]
bool m_pi_traffic_program
unsigned int m_g14_psn_counter
void decode_type11(unsigned int *group, bool B)
freqs_map_t m_g14_mapped_freqs
key: PI, value: set of mapped frequencies (MHz)
bool m_g8_diversion_recommended
freqs_map_t m_g14_alt_freqs
key: PI, value: set of alternate frequencies (MHz)
void decode_type3(unsigned int *group, bool B)
static const unsigned int offset_pos[5]
unsigned char pi_country_identification
void decode_type1(unsigned int *group, bool B)
unsigned char m_pi_program_type
void decode_type9(unsigned int *group, bool B)
void decode_type10(unsigned int *group, bool B)
unsigned int m_g8_location
std::set< double > m_g14_alt_freq_set
unsigned int m_g1_pin_minute
static const std::string rds_group_acronym_tags[16]
bool m_g14_data_available
static const std::string label_descriptions[16]
static const unsigned int syndrome[5]
static const std::string language_codes[44]
unsigned int m_g1_pin_day
bool m_g0_traffic_announcement
int m_g1_country_index
negative if not received
unsigned int m_g4_minutes
void decode_type2(unsigned int *group, bool B)
unsigned char m_g0_psn_bitmap
unsigned char pi_program_reference_number
std::set< double > m_g0_alt_freq
char m_g2_radiotext[64+1]
double decode_af(unsigned int)
static const std::string pi_country_codes[15][5]
static const unsigned int offset_word[5]
unsigned int m_g3_appGroup
void decode_type13(unsigned int *group, bool B)
static const std::string coverage_area_codes[16]
static const char *const offset_name[]
int m_g8_label_index
negative if not received
static const int optional_content_lengths[16]
unsigned int m_g3_message
std::pair< unsigned int, std::string > psns_map_kv_t
int m_g1_language_index
negative if not received
static int get_tmc_event_code_index(unsigned int i, unsigned int j)
unsigned int m_g1_pin_hour
int m_pi_area_coverage_index
void decode_type6(unsigned int *group, bool B)
static const std::string tmc_duration[8][2]
int m_g1_country_page_index
negative if not received
void decode_type4(unsigned int *group, bool B)
int m_pi_country_identification
char m_g14_program_service_name[8+1]
double m_g4_local_time_offset
void decode_type7(unsigned int *group, bool B)
static std::string get_tmc_events(unsigned int i, unsigned int j)
void decode_optional_content(int, unsigned long int *)
std::pair< unsigned int, std::set< double > > freqs_map_kv_t
void decode_type15(unsigned int *group, bool B)
void decode_type5(unsigned int *group, bool B)
bool m_g0_artificial_head