From 5d2ab4e5f2c869f7c1dae5190eb123a50f473a87 Mon Sep 17 00:00:00 2001 From: csrichter Date: Sun, 16 Apr 2017 11:59:44 +0200 Subject: [PATCH] wrongblock_ratio separate PMT message , TMC messages added to dict in parser not tmc_classes --- .gitignore | 1 + lib/rds_decoder_impl.cc | 10 +++++++--- lib/rds_decoder_redsea_impl.cc | 11 ++++++++--- python/rds_parser_table_qt.py | 26 +++++++++++++++++++++----- python/tmc_classes.py | 1 - python/tmc_parser.py | 4 +++- 6 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/lib/rds_decoder_impl.cc b/lib/rds_decoder_impl.cc index d86b60c..d924e53 100644 --- a/lib/rds_decoder_impl.cc +++ b/lib/rds_decoder_impl.cc @@ -113,7 +113,7 @@ unsigned int rds_decoder_impl::calc_syndrome(unsigned long message, void rds_decoder_impl::decode_group(unsigned int *group) { // raw data bytes, as received from RDS. // 8 info bytes, followed by 4 RDS offset chars: ABCD/ABcD/EEEE (in US) - unsigned char bytes[13]; + unsigned char bytes[12]; // RDS information words bytes[0] = (group[0] >> 8U) & 0xffU; @@ -130,8 +130,8 @@ void rds_decoder_impl::decode_group(unsigned int *group) { bytes[9] = offset_chars[1]; bytes[10] = offset_chars[2]; bytes[11] = offset_chars[3]; - bytes[12]=last_wrong_blocks_counter; - pmt::pmt_t data(pmt::make_blob(bytes, 13)); + //bytes[12]=last_wrong_blocks_counter; + pmt::pmt_t data(pmt::make_blob(bytes, 12)); //pmt::pmt_t meta(pmt::PMT_NIL); pmt::pmt_t meta(pmt::from_long(0)); pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair @@ -250,6 +250,10 @@ int rds_decoder_impl::work (int noutput_items, << " bad blocks on " << blocks_counter << " total)" << std::endl; } + pmt::pmt_t meta(pmt::from_long(2)); + pmt::pmt_t data(pmt::from_double((double)wrong_blocks_counter/(double)blocks_counter)); + pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair + message_port_pub(pmt::mp("out"), pdu); blocks_counter=0; wrong_blocks_counter=0; } diff --git a/lib/rds_decoder_redsea_impl.cc b/lib/rds_decoder_redsea_impl.cc index 0737103..fbc8e73 100644 --- a/lib/rds_decoder_redsea_impl.cc +++ b/lib/rds_decoder_redsea_impl.cc @@ -163,7 +163,7 @@ uint32_t rds_decoder_redsea_impl::correctBurstErrors(uint32_t block, char offset void rds_decoder_redsea_impl::decode_group(uint16_t *group) { // raw data bytes, as received from RDS. // 8 info bytes, followed by 4 RDS offset chars: ABCD/ABcD/EEEE (in US) - uint8_t bytes[13]; + uint8_t bytes[12]; // RDS information words bytes[0] = (group[0] >> 8U) & 0xffU; @@ -180,8 +180,8 @@ void rds_decoder_redsea_impl::decode_group(uint16_t *group) { bytes[9] = offset_chars[1]; bytes[10] = offset_chars[2]; bytes[11] = offset_chars[3]; - bytes[12]=last_wrong_blocks_counter; - pmt::pmt_t data(pmt::make_blob(bytes, 13)); + //bytes[12]=last_wrong_blocks_counter; + pmt::pmt_t data(pmt::make_blob(bytes, 12)); //pmt::pmt_t meta(pmt::PMT_NIL); pmt::pmt_t meta(pmt::from_long(0)); pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair @@ -327,7 +327,12 @@ int rds_decoder_redsea_impl::work (int noutput_items, lout << "@@@@@ Still Sync-ed (Got " << wrong_blocks_counter << " bad blocks on " << blocks_counter << " total)" << std::endl; + } + pmt::pmt_t meta(pmt::from_long(2)); + pmt::pmt_t data(pmt::from_double((double)wrong_blocks_counter/(double)blocks_counter)); + pmt::pmt_t pdu(pmt::cons(meta, data)); // make PDU: (metadata, data) pair + message_port_pub(pmt::mp("out"), pdu); blocks_counter=0; wrong_blocks_counter=0; } diff --git a/python/rds_parser_table_qt.py b/python/rds_parser_table_qt.py index 140c3c0..d557862 100644 --- a/python/rds_parser_table_qt.py +++ b/python/rds_parser_table_qt.py @@ -89,7 +89,7 @@ class rds_parser_table_qt(gr.sync_block):#START self.decoder_frequencies={} self.decoders=[] for i in range(nPorts): - self.decoders.append({'synced':False,'freq':None}) + self.decoders.append({'synced':False,'freq':None,'PI':""}) #self.decoder_synced={} #self.colorder=['ID','freq','name','PTY','AF','time','text','quality','buttons'] self.colorder=['ID','freq','name','buttons','PTY','AF','time','text','quality','RT+'] @@ -240,12 +240,23 @@ class rds_parser_table_qt(gr.sync_block):#START self.RDS_data[PI]["DI"]=[2,2,2,2] self.RDS_data[PI]["internals"]={"last_rt_tooltip":"","unfinished_TMC":{},"last_valid_rt":"","last_valid_psn":"","RT_history":[]} self.RDS_data[PI]["time"]={"timestring":"88:88","datestring":"00-00-0000","datetime":None} + self.RDS_data[PI]["wrong_block_ratio"]=1#100% def handle_msg(self, msg, port):#port from 0 to 3 if pmt.to_long(pmt.car(msg))==1L: - data=pmt.to_python(pmt.cdr(msg)) + synced=pmt.to_python(pmt.cdr(msg)) #print("port:%i, data: %s"%(port,data)) - self.decoders[port]['synced']=data + self.decoders[port]['synced']=synced self.update_freq() + PI=self.decoders[port]['PI'] + if self.RDS_data.has_key(PI) and not synced: + self.RDS_data[PI]["wrong_block_ratio"]=1#100% + elif pmt.to_long(pmt.car(msg))==2L: + wrong_block_ratio=pmt.to_python(pmt.cdr(msg)) + PI=self.decoders[port]['PI'] + if self.RDS_data.has_key(PI): + dots="."*self.RDS_data[PI]["blockcounts"]["any"] + self.RDS_data[PI]["wrong_block_ratio"]=wrong_block_ratio + self.signals.DataUpdateEvent.emit({'PI':PI,'wrong_block_ratio':wrong_block_ratio,'dots':dots}) else: #elif pmt.to_long(pmt.car(msg))==0L array=pmt.to_python(msg)[1] @@ -277,10 +288,11 @@ class rds_parser_table_qt(gr.sync_block):#START #else: #PI="%02X%02X" %(array[0],array[1]) PI="%02X%02X" %(array[0],array[1]) + self.decoders[port]['PI']=PI TP=(array[2]>>2)&0x1 block2=(array[2]<<8)|(array[3]) #block2 PTY=(block2>>5)&0x1F - wrong_blocks=int(array[12]) + #wrong_blocks=int(array[12]) try: self.PI_dict[PI]+=1 @@ -317,7 +329,7 @@ class rds_parser_table_qt(gr.sync_block):#START self.RDS_data[PI]["TP"]=TP self.RDS_data[PI]["PTY"]=self.pty_dict[PTY] - self.signals.DataUpdateEvent.emit({'row':port,'PI':PI,'PTY':self.pty_dict[PTY],'TP':TP,'wrong_blocks':wrong_blocks,'dots':dots}) + self.signals.DataUpdateEvent.emit({'PI':PI,'PTY':self.pty_dict[PTY],'TP':TP,'wrong_block_ratio':wrong_block_ratio,'dots':dots}) @@ -1134,6 +1146,10 @@ class rds_parser_table_qt_Widget(QtGui.QWidget): freqcol=self.colorder.index('freq') item=self.table.cellWidget(row,freqcol) item.setText(event['freq']) + if event.has_key('wrong_block_ratio'): + item=self.table.cellWidget(row,self.colorder.index('quality')) + quality_string="%i%% %s"% (100-100*event['wrong_block_ratio'],event['dots']) + item.setText(quality_string) if event.has_key('wrong_blocks'): item=self.table.cellWidget(row,self.colorder.index('quality')) quality_string="%i%% %s"% (100-2*event['wrong_blocks'],event['dots']) diff --git a/python/tmc_classes.py b/python/tmc_classes.py index 52bf9cf..105ffa4 100644 --- a/python/tmc_classes.py +++ b/python/tmc_classes.py @@ -590,7 +590,6 @@ class tmc_message: print(self) else:#subsequent groups in multigroup -> Y0..Y11 and Z0..Z15 are special format raise ValueError, "subsequent groups must be added to existing tmc message" - tableobj.tmc_messages.add(self) def add_group(self,tmc_y,tmc_z): sg=int((tmc_y>>14)&0x1)#=1 if second group Y14 gsi=int((tmc_y>>12)&0x3)#group sequence indicator Y12..13 ,max length:5 diff --git a/python/tmc_parser.py b/python/tmc_parser.py index a5ae13e..00eb54b 100644 --- a/python/tmc_parser.py +++ b/python/tmc_parser.py @@ -153,10 +153,12 @@ class tmc_parser(gr.sync_block): if tmc_T == 0: if tmc_F==1:#single group tmc_msg=tmc_message(PI,psn,ltn,tmc_x,tmc_y,tmc_z,datetime_received,self) + self.tmc_messages.add(tmc_msg) self.print_tmc_msg(tmc_msg) elif tmc_F==0 and Y15==1:#1st group of multigroup ci=int(tmc_x&0x7) tmc_msg=tmc_message(PI,psn,ltn,tmc_x,tmc_y,tmc_z,datetime_received,self) + self.tmc_messages.add(tmc_msg) #if self.RDS_data[PI]["internals"]["unfinished_TMC"].has_key(ci): #print("overwriting parital message") self.unfinished_messages[PI][ci]={"msg":tmc_msg,"time":time.time()} @@ -170,7 +172,7 @@ class tmc_parser(gr.sync_block): #print("%f: continuing message PI:%s,age:%f,ci:%i complete:%i"%t) self.unfinished_messages[PI]["time"]=time.time() if tmc_msg.is_complete: - self.print_tmc_msg(tmc_msg)#print and store message + self.print_tmc_msg(tmc_msg)#print message del self.unfinished_messages[PI][tmc_msg.ci]#delete finished message else: #if not ci==0: