|
|
|
|
@ -293,33 +293,36 @@ int rds_decoder_redsea_impl::work (int noutput_items,
|
|
|
|
|
checkword=reg & 0x3ff;//checkword part of received block (lower 10 bits)
|
|
|
|
|
/* manage special case of C or C' offset word */ |
|
|
|
|
if (block_number==2) { |
|
|
|
|
if (variant==0){//A
|
|
|
|
|
offset_char = 'C'; |
|
|
|
|
block_received_crc=checkword^offset_word[2]; |
|
|
|
|
} |
|
|
|
|
else{//B
|
|
|
|
|
offset_char = 'c'; |
|
|
|
|
block_received_crc=checkword^offset_word[4]; |
|
|
|
|
//dout<<"B"<<std::endl;
|
|
|
|
|
} |
|
|
|
|
if (block_received_crc==block_calculated_crc) { |
|
|
|
|
good_block=true; |
|
|
|
|
}else{ |
|
|
|
|
//try correcting:
|
|
|
|
|
uint32_t corrected_block= correctBurstErrors(reg,offset_char); |
|
|
|
|
if(corrected_block != reg){ |
|
|
|
|
if (variant == 2 ) dout << "error: 3rd block received before 2nd"<<std::endl; |
|
|
|
|
else{ |
|
|
|
|
if (variant==0){//A
|
|
|
|
|
offset_char = 'C'; |
|
|
|
|
block_received_crc=checkword^offset_word[2]; |
|
|
|
|
} |
|
|
|
|
else{//B
|
|
|
|
|
offset_char = 'c'; |
|
|
|
|
block_received_crc=checkword^offset_word[4]; |
|
|
|
|
//dout<<"B"<<std::endl;
|
|
|
|
|
} |
|
|
|
|
if (block_received_crc==block_calculated_crc) { |
|
|
|
|
good_block=true; |
|
|
|
|
block_was_corrected=true; |
|
|
|
|
group_corrected_blocks_counter++; |
|
|
|
|
//wrong_blocks_counter++;
|
|
|
|
|
dataword=(corrected_block>>10) & 0xffff; |
|
|
|
|
checkword=corrected_block & 0x3ff; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//dout << "corrected error"<<std::endl;
|
|
|
|
|
}else { |
|
|
|
|
wrong_blocks_counter++; |
|
|
|
|
good_block=false; |
|
|
|
|
}else{ |
|
|
|
|
//try correcting:
|
|
|
|
|
uint32_t corrected_block= correctBurstErrors(reg,offset_char); |
|
|
|
|
if(corrected_block != reg){ |
|
|
|
|
good_block=true; |
|
|
|
|
block_was_corrected=true; |
|
|
|
|
group_corrected_blocks_counter++; |
|
|
|
|
//wrong_blocks_counter++;
|
|
|
|
|
dataword=(corrected_block>>10) & 0xffff; |
|
|
|
|
checkword=corrected_block & 0x3ff; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//dout << "corrected error"<<std::endl;
|
|
|
|
|
}else { |
|
|
|
|
wrong_blocks_counter++; |
|
|
|
|
good_block=false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -327,8 +330,6 @@ int rds_decoder_redsea_impl::work (int noutput_items,
|
|
|
|
|
else { |
|
|
|
|
block_received_crc=checkword^offset_word[block_number]; |
|
|
|
|
if (block_received_crc==block_calculated_crc) {//valid block
|
|
|
|
|
if (block_number==0) |
|
|
|
|
last_pi=dataword; |
|
|
|
|
good_block=true; |
|
|
|
|
offset_char=expected_offset_char[block_number]; //expected_offset_char[]={'A','B','?','D'};
|
|
|
|
|
/*if (block_number==0) offset_char = 'A';
|
|
|
|
|
@ -380,10 +381,12 @@ int rds_decoder_redsea_impl::work (int noutput_items,
|
|
|
|
|
} |
|
|
|
|
/* done checking CRC */
|
|
|
|
|
if (block_number==0 && good_block) { |
|
|
|
|
last_pi=dataword; |
|
|
|
|
group_assembly_started=true; |
|
|
|
|
//group_corrected_blocks_counter=block_was_corrected;
|
|
|
|
|
group_corrected_blocks_counter=0; |
|
|
|
|
group_good_blocks_counter=1; |
|
|
|
|
variant=2; |
|
|
|
|
} |
|
|
|
|
if (block_number==1 && good_block) {//2nd block - > read group type variant
|
|
|
|
|
variant=(dataword>>11)& 0x1; |
|
|
|
|
@ -406,6 +409,7 @@ int rds_decoder_redsea_impl::work (int noutput_items,
|
|
|
|
|
group_good_blocks_counter++; |
|
|
|
|
} |
|
|
|
|
if (group_good_blocks_counter==5) decode_group(group); |
|
|
|
|
//if (group_good_blocks_counter==5 and group_corrected_blocks_counter>0) decode_group(group);//test corrected blocks
|
|
|
|
|
} |
|
|
|
|
block_bit_counter=0; |
|
|
|
|
block_number=(block_number+1) % 4; |
|
|
|
|
|