Browse Source

changed syndrome var in makeErrorTable from uint16_t to uint32_t

dev
Clemens Richter 9 years ago
parent
commit
d9f868aba0
  1. 42
      lib/rds_decoder_redsea_impl.cc

42
lib/rds_decoder_redsea_impl.cc

@ -58,16 +58,12 @@ namespace gr {
dout << "constructing error lookup table"<<std::endl;
kErrorLookup = makeErrorLookupTable();
//dout<< kErrorLookup.count({(uint16_t)7, 'A'})<< std::endl;
//dout<< kErrorLookup.count({(uint16_t)7, 'B'})<< std::endl;
//dout<< kErrorLookup.count({(uint16_t)7, 'A'})<< std::endl;
//dout<< kErrorLookup.at({704, 'A'})<< std::endl;
//~ if (kErrorLookup.count({(uint16_t)14, (char)'A'}) > 0) {
//~ dout<<"found sy 14 offset A in table"<<std::endl;
//~ }
dout<< "i am new"<< std::endl;
//dout<< kErrorLookup.at({704, 'A'})<< std::endl;
// if (kErrorLookup.count({(uint16_t)14, (char)'A'}) > 0) {
// dout<<"found sy 14 offset A in table"<<std::endl;
// }
//dout<< "i am new"<< std::endl;
}
/*
@ -133,7 +129,12 @@ std::map<std::pair<uint16_t, char>, uint32_t> rds_decoder_redsea_impl::makeError
static const unsigned int offset_word[5]={252,408,360,436,848};
static const unsigned int syndrome[5]={383,14,303,663,748};
static const char * const offset_name[]={"A","B","C","D","c"};*/
//const std::vector<uint16_t> offset_words ={0x0FC, 0x198, 0x168, 0x350, 0x1B4};
for (uint8_t offset_num=0;offset_num<5;offset_num++) {
//dout<<"name:" <<offset_name[offset_num];
//dout<<"\t word:" <<offset_word[offset_num]<< std::endl;
// "...the error-correction system should be enabled, but should be
// restricted by attempting to correct bursts of errors spanning one or two
// bits."
@ -143,7 +144,8 @@ static const char * const offset_name[]={"A","B","C","D","c"};*/
for (uint32_t e : {0x1,0x3}) {//fix up to 2-bit burst errors (as book says)
for (int shift=0; shift < 26; shift++) {
uint32_t errvec = ((e << shift) & kBitmask26);
uint16_t sy = calc_syndrome(errvec ^ offset_word[offset_num],26);
//uint16_t sy = calc_syndrome(errvec ^ offset_word[offset_num],26);
uint32_t sy = calc_syndrome(errvec ^ offset_word[offset_num],26);//why uint32 and not uint16 as everywhere else???
result.insert({{sy, offset_name[offset_num]}, errvec});
//dout << "adding sy:"<<sy<<"\t\toffset:"<<offset_name[offset_num]<<"\terrvec:"<<std::bitset<32>(errvec) <<std::endl;
}
@ -160,7 +162,7 @@ uint32_t rds_decoder_redsea_impl::correctBurstErrors(uint32_t block, char offset
if (kErrorLookup.count({(uint16_t)syndrome, (char)offset}) > 0) {
uint32_t err = kErrorLookup.at({(uint16_t)syndrome, (char)offset});
//dout << "correcting"<<std::endl;
//err=0;//correction disabled
err=0;//correction disabled
corrected_block ^= err;
}
@ -301,10 +303,26 @@ int rds_decoder_redsea_impl::work (int noutput_items,
uint16_t diff2=(dataword>>1)^(last_pi);
unsigned int num_diff_bits = std::bitset<16>(diff).count();
unsigned int num_diff_bits2 = std::bitset<16>(diff2).count();
if (num_diff_bits<2 or num_diff_bits2<2){
dout << "clockslip detection:"<<std::endl;
if (num_diff_bits<2){
dout << "clockslip detection (forward,skipped one):"<<std::endl;
dout << "dataword:"<<std::bitset<16>(dataword)<<"\tlast_pi:"<<std::bitset<16>(last_pi)<<std::endl;
}
if (num_diff_bits2<2){
dout << "clockslip detection (backward,repeated one):"<<std::endl;
dout << "dataword:"<<std::bitset<16>(dataword)<<"\tlast_pi:"<<std::bitset<16>(last_pi)<<std::endl;
}
diff=dataword^(last_pi>>2);
diff2=(dataword>>2)^(last_pi);
num_diff_bits = std::bitset<16>(diff).count();
num_diff_bits2 = std::bitset<16>(diff2).count();
if (num_diff_bits<2){
dout << "clockslip detection (forward,skipped two):"<<std::endl;
dout << "dataword:"<<std::bitset<16>(dataword)<<"\tlast_pi:"<<std::bitset<16>(last_pi)<<std::endl;
}
if (num_diff_bits2<2){
dout << "clockslip detection (backward,repeated two):"<<std::endl;
dout << "dataword:"<<std::bitset<16>(dataword)<<"\tlast_pi:"<<std::bitset<16>(last_pi)<<std::endl;
}
}
//try correcting:
uint32_t corrected_block= correctBurstErrors(reg,expected_offset_char[block_number]);

Loading…
Cancel
Save