Browse Source

wrongblock_ratio separate PMT message , TMC messages added to dict in parser not tmc_classes

master
Clemens Richter 9 years ago
parent
commit
5d2ab4e5f2
  1. 1
      .gitignore
  2. 10
      lib/rds_decoder_impl.cc
  3. 11
      lib/rds_decoder_redsea_impl.cc
  4. 26
      python/rds_parser_table_qt.py
  5. 1
      python/tmc_classes.py
  6. 4
      python/tmc_parser.py

1
.gitignore vendored

@ -0,0 +1 @@
build

10
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;
}

11
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;
}

26
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'])

1
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

4
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:

Loading…
Cancel
Save