diff --git a/apps/fft-multi-decoder_fixed_hackrf.grc b/apps/fft-multi-decoder_fixed_hackrf.grc index 10fa067..dbf98ff 100644 --- a/apps/fft-multi-decoder_fixed_hackrf.grc +++ b/apps/fft-multi-decoder_fixed_hackrf.grc @@ -2516,7 +2516,7 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in log - False + True loop_bw @@ -3170,7 +3170,7 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in writeDB - True + False @@ -3244,7 +3244,7 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in _enabled - True + 1 _coordinate diff --git a/apps/ifft-RDS-decoder_hier-block.grc b/apps/ifft-RDS-decoder_hier-block.grc index 2872749..89b3354 100644 --- a/apps/ifft-RDS-decoder_hier-block.grc +++ b/apps/ifft-RDS-decoder_hier-block.grc @@ -482,7 +482,7 @@ _enabled - 1 + 0 file @@ -533,11 +533,11 @@ _enabled - 0 + 1 file - "/tmp/psk_out_2375_"+str(cutpoint) + "/tmp/cr/psk_out_2375_"+str(cutpoint) _coordinate @@ -584,7 +584,7 @@ _enabled - 0 + 1 file @@ -2339,7 +2339,7 @@ debug - True + False _enabled @@ -2402,7 +2402,7 @@ log - log + False maxoutbuf diff --git a/apps/read_fmdec.grc b/apps/read_fmdec.grc index 4186abc..30a4c4c 100644 --- a/apps/read_fmdec.grc +++ b/apps/read_fmdec.grc @@ -162,6 +162,33 @@ 240000 + + variable + + comment + + + + _enabled + True + + + _coordinate + (151, 706) + + + _rotation + 0 + + + id + fft19k_len + + + value + 2048 + + variable_qtgui_range @@ -535,7 +562,7 @@ file - /user/wire2/richter/fm_dec_rec/fm_dec_240k_597.333333333 + /tmp/cr/rds_rec_all_1500news/fm_dec_240k_5888.0 _coordinate @@ -798,7 +825,7 @@ w - loop_bw + 3.14/loop_bw M @@ -1046,6 +1073,140 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in fcc + + logpwrfft_x + + avg_alpha + 1.0 + + + average + False + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + fft_size + fft19k_len + + + frame_rate + 30 + + + _coordinate + (231, 519) + + + _rotation + 0 + + + id + logpwrfft_x_0 + + + type + float + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + ref_scale + 2 + + + sample_rate + baseband_rate + + + + multirds_pilot_SNR + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + 1 + + + _coordinate + (559, 543) + + + _rotation + 0 + + + id + multirds_pilot_SNR_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + carrier_freq + 19e3 + + + fft_len + fft19k_len + + + gap_width + 4e3 + + + msg_adr + 3 + + + samp_rate + baseband_rate + + + update_period + 0.4 + + multirds_rds_decoder_redsea @@ -1082,7 +1243,7 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in log - False + True maxoutbuf @@ -1235,7 +1396,7 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in _enabled - True + 0 _coordinate @@ -2142,6 +2303,12 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in 0 0 + + blocks_throttle_0 + logpwrfft_x_0 + 0 + 0 + blocks_throttle_0 qtgui_freq_sink_x_0_0_1_2 @@ -2190,6 +2357,18 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in 0 0 + + logpwrfft_x_0 + multirds_pilot_SNR_0 + 0 + 0 + + + multirds_pilot_SNR_0 + multirds_rds_parser_table_qt_0 + out + in + multirds_rds_decoder_redsea_0 multirds_rds_parser_table_qt_0 diff --git a/apps/read_sync_decim.grc b/apps/read_sync_decim.grc index ace5beb..57b5d2f 100644 --- a/apps/read_sync_decim.grc +++ b/apps/read_sync_decim.grc @@ -344,7 +344,7 @@ file - /tmp/cr/rds-rec_sync-decim_170324_weekend/sync_decim_out_11861 + /tmp/cr/rds_rec_all_1500news/sync_decim_out_5888.0 _coordinate @@ -800,7 +800,7 @@ class blk(gr.sync_block): # other base classes are basic_block, decim_block, in _enabled - True + 1 _coordinate diff --git a/lib/rds_decoder_redsea_impl.cc b/lib/rds_decoder_redsea_impl.cc index e6d0179..384da0a 100644 --- a/lib/rds_decoder_redsea_impl.cc +++ b/lib/rds_decoder_redsea_impl.cc @@ -120,6 +120,30 @@ uint16_t rds_decoder_redsea_impl::calc_syndrome(uint32_t message,uint8_t mlen) { } //redsea stuff: +// Section B.1.1: '-- calculated by the modulo-two addition of all the rows of +// the -- matrix for which the corresponding coefficient in the -- vector is 1.' +uint32_t matrixMultiply(uint32_t vec, const std::vector& matrix) { + uint32_t result = 0; + + for (size_t k=0; k < matrix.size(); k++) + if ((vec >> k) & 0x01) + result ^= matrix[matrix.size() - 1 - k]; + + return result; +} + +// Section B.2.1: 'The calculation of the syndromes -- can easily be done by +// multiplying each word with the parity matrix H.' +uint32_t calcSyndrome_vec(uint32_t vec) { + static const std::vector parity_check_matrix({ + 0x200, 0x100, 0x080, 0x040, 0x020, 0x010, 0x008, 0x004, + 0x002, 0x001, 0x2dc, 0x16e, 0x0b7, 0x287, 0x39f, 0x313, + 0x355, 0x376, 0x1bb, 0x201, 0x3dc, + 0x1ee, 0x0f7, 0x2a7, 0x38f, 0x31b + }); + + return matrixMultiply(vec, parity_check_matrix); +} const unsigned kBitmask16 = 0x000FFFF; const unsigned kBitmask26 = 0x3FFFFFF; const unsigned kBitmask28 = 0xFFFFFFF; @@ -144,8 +168,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); uint32_t sy = calc_syndrome(errvec ^ offset_word[offset_num],26);//why uint32 and not uint16 as everywhere else??? + //uint32_t sy = calcSyndrome_vec(errvec ^ offset_word[offset_num]); result.insert({{sy, offset_name[offset_num]}, errvec}); //dout << "adding sy:"<(errvec) < 0) { - uint32_t err = kErrorLookup.at({(uint16_t)syndrome, (char)offset}); + if (kErrorLookup.count({syndrome, offset}) > 0) { + uint32_t err = kErrorLookup.at({syndrome, offset}); //dout << "correcting"<1000){ + outbit_counter=0; + weakout_counter=0; + lout<<"mode: "<=SYNC_COUNTER_MAX){ dosync_counter=0; float out_noskip; float out_skip; @@ -132,23 +145,22 @@ namespace gr { //lout<<"\t,out_skip:"<6){ + if (skip_is_better_counter>3){//2017-05-02 lowered from 6 mode=SKIP; lout<<"switched to skip"<< std::endl; } - else if (skip_is_better_counter<-6){ + else if (skip_is_better_counter<-3){ mode=NOSKIP; lout<<"switched to noskip"<< std::endl; } } - else if(mode==COPY){ + } + else if(mode==COPY){ dosync_counter++; - } } - - // Tell runtime system how many output items we produced. + outbit_counter+=noutput_items; return noutput_items; }/*end of work*/ } /* namespace multirds */ diff --git a/lib/sync_decim_impl.h b/lib/sync_decim_impl.h index 52cadff..1704ec8 100644 --- a/lib/sync_decim_impl.h +++ b/lib/sync_decim_impl.h @@ -47,6 +47,8 @@ namespace gr { unsigned int skip; void parse_ctrl_msg(pmt::pmt_t pdu); int dosync_counter; + int weakout_counter; + int outbit_counter; }; } // namespace multirds diff --git a/python/tmc_classes.py b/python/tmc_classes.py index 719f901..c6b1bd2 100644 --- a/python/tmc_classes.py +++ b/python/tmc_classes.py @@ -596,16 +596,16 @@ class tmc_dict: self.dict_lock=threading.Lock() self.list_lock=threading.Lock() @staticmethod - def matchFilter(msg,filters): - if not msg.location.is_valid: + def matchFilter(msg,showInvalid,filters): + #print("fun:matchFilter:%s,showInvalid:%i"%(filters,showInvalid)) + if showInvalid and not msg.location.is_valid: return True#always show invalid messages loc_str=str(msg.location)+str(msg.location.reflocs) if not msg.location.linRef==None: loc_str+=str(msg.location.linRef.roadnumber) - for f in filters:#filters is list of dicts {"type":"event","str":"Stau"} - stringlist=f["str"].lower().split(";") + stringlist=f["str"].lower().split(";")#filters can be separated by semicolon for string in stringlist: if f["type"]=="event" and unicode(str(msg.event), encoding="UTF-8").lower().find(string)==-1:#if event filter does not match return False @@ -638,11 +638,12 @@ class tmc_dict: print("ERROR, not adding: "+str(message)) finally: self.dict_lock.release() - def getLogString(self,filters): + def getLogString(self,showInvalid,filters): self.list_lock.acquire() retStr="" + #print("fun:getLogString,filters:%s"%filters) for message in self.message_list: - if tmc_dict.matchFilter(message,filters): + if tmc_dict.matchFilter(message,showInvalid,filters): retStr+=message.log_string() retStr+="\n" retStr+=message.multi_str() @@ -830,7 +831,7 @@ class tmc_message: text+=templates[language+"_2b"].format(D=self.location.first_name) else: text+=templates[language+"_2a"].format(D=self.location.first_name,E=offset_loc_name) - + text+=", dir:"+str(self.tmc_dir) #LocCode: RefLine: RoadNr #A #LocCode:RefLine:Name2 diff --git a/python/tmc_parser.py b/python/tmc_parser.py index ca532cc..3d70cbc 100644 --- a/python/tmc_parser.py +++ b/python/tmc_parser.py @@ -253,60 +253,63 @@ class tmc_parser(gr.sync_block): print("symbol not decoded: "+"?%02X?"%ord(char)+"in string:"+return_string) pass return return_string +def print_dbg(message,end="\n"): + dbg=False + if dbg: + print(message,end=end) class tmc_parser_Widget(QtGui.QWidget): + def print_tmc_msg(self,tmc_msg): - print("print:",end="") self.logMutex.acquire(1) - print("got mutex,",end="") + print_dbg("print:got mutex,",end="") sb=self.logOutput.verticalScrollBar() - print(".",end="") + print_dbg(".",end="") oldmax=sb.maximum() - print(".",end="") + print_dbg(".",end="") auto_scroll= abs(oldmax-sb.value())<60#auto_scroll if scrollbar was at max - print(".",end="") - #print("%i %i %r"%(sb.maximum(),sb.value(),auto_scroll)) + print_dbg(".",end="") ef=unicode(self.event_filter.text().toUtf8(), encoding="UTF-8").lower() lf=unicode(self.location_filter.text().toUtf8(), encoding="UTF-8").lower() filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}] - if tmc_dict.matchFilter(tmc_msg,filters): - print("a",end="") + if tmc_dict.matchFilter(tmc_msg,self.showInvalid,filters): + print_dbg("a",end="") self.logOutput.append(Qt.QString.fromUtf8(tmc_msg.log_string())) - print("a",end="") + print_dbg("a",end="") self.logOutput.append(Qt.QString.fromUtf8(tmc_msg.multi_str())) - print("a",end="") - #print("new message") + print_dbg("a",end="") if auto_scroll: #sb=self.logOutput.verticalScrollBar() #disabled 2017-04-28 might be cause of double free new_max=sb.maximum() - print("s",end="") + print_dbg("s",end="") sb.setValue(new_max) - print("s",end="") - print("\tdone") - # code.interact(local=locals()) - #print("scrolling %i %i %r"%(oldmax,new_max,sb.value())) - #code.interact(local=locals()) + print_dbg("s",end="") self.logMutex.release(1) + print_dbg("\tdone") + def filterChanged(self): - print("filterChanged:",end="") self.logMutex.acquire(1) - print("got mutex,",end="") + #code.interact(local=locals()) + print_dbg("filterChanged:got mutex,",end="") ef="" lf="" try: ef=unicode(self.event_filter.text().toUtf8(), encoding="UTF-8").lower() lf=unicode(self.location_filter.text().toUtf8(), encoding="UTF-8").lower() except Exception as e: - print(e) - print("error getting filter strings") + print_dbg(e) + print_dbg("error getting filter strings") code.interact(local=locals()) - print("read filters,",end="") + print_dbg("read filters,",end="") self.logOutput.clear() - print("cleared,",end="") + print_dbg("cleared,",end="") filters=[{"type":"location", "str":lf},{"type":"event", "str":ef}] - self.logOutput.append(Qt.QString.fromUtf8(self.parser.tmc_messages.getLogString(filters))) - print("appended,",end="") + #print("getting logstring with filters:%s, showInvalid:%i"%(filters,self.showInvalid)) + self.logOutput.append(Qt.QString.fromUtf8(self.parser.tmc_messages.getLogString(self.showInvalid,filters))) + print_dbg("appended,",end="") self.logMutex.release(1) - print("done") + print_dbg("done") + def update_showInvalid(self): + self.showInvalid=self.GUI_showInvalid.isChecked() def __init__(self, parser,maxheight): QtGui.QWidget.__init__(self) layout = Qt.QVBoxLayout() @@ -318,13 +321,18 @@ class tmc_parser_Widget(QtGui.QWidget): self.location_filter=QtGui.QLineEdit(u"Baden-Württemberg") self.event_filter.returnPressed.connect(self.filterChanged) self.location_filter.returnPressed.connect(self.filterChanged) - + self.showInvalid=False + self.GUI_showInvalid=QtGui.QCheckBox() + self.GUI_showInvalid.setChecked(self.showInvalid) + #self.showInvalid.stateChanged.connect(lambda:self.btnstate(self.b1)) + self.GUI_showInvalid.stateChanged.connect(self.update_showInvalid) filter_layout = Qt.QHBoxLayout() filter_layout.addWidget(QtGui.QLabel("event filter:")) filter_layout.addWidget(self.event_filter) filter_layout.addWidget(QtGui.QLabel("location filter:")) filter_layout.addWidget(self.location_filter) - + filter_layout.addWidget(QtGui.QLabel("showInvalid:")) + filter_layout.addWidget(self.GUI_showInvalid) layout.addLayout(filter_layout) layout.addWidget(self.tmc_message_label) self.logOutput = Qt.QTextEdit()