Browse Source

fft-multi-decoder fixed and auto-freq with 9 decoders, decoder_compare block

master
Clemens Richter 9 years ago
parent
commit
08872c2b2f
  1. 3
      grc/CMakeLists.txt
  2. 28
      grc/crfa_decoder_compare.xml
  3. 1
      grc/crfa_vector_cutter.xml
  4. 2
      lib/rds_decoder_impl.cc
  5. 3
      python/CMakeLists.txt
  6. 1
      python/__init__.py
  7. 62
      python/decoder_compare.py
  8. 18
      python/max_freq.py
  9. 1
      python/rds_parser_table_qt.py

3
grc/CMakeLists.txt

@ -25,5 +25,6 @@ install(FILES
crfa_max_freq.xml crfa_max_freq.xml
crfa_smooth_vectors.xml crfa_smooth_vectors.xml
crfa_stream_selector.xml crfa_stream_selector.xml
crfa_vector_cutter.xml DESTINATION share/gnuradio/grc/blocks crfa_vector_cutter.xml
crfa_decoder_compare.xml DESTINATION share/gnuradio/grc/blocks
) )

28
grc/crfa_decoder_compare.xml

@ -0,0 +1,28 @@
<?xml version="1.0"?>
<block>
<name>decoder_compare</name>
<key>crfa_decoder_compare</key>
<category>[crfa]</category>
<import>import crfa</import>
<make>crfa.decoder_compare($nPorts)</make>
<!-- Make one 'param' node for every Parameter you want settable from the GUI.
Sub-nodes:
* name
* key (makes the value accessible as $keyname, e.g. in the make node)
* type -->
<param>
<name>Number of Ports</name>
<key>nPorts</key>
<value>2</value>
<type>int</type>
<hide>part</hide>
</param>
<check>$nPorts &gt; 0</check>
<sink>
<name>in</name>
<type>message</type>
<nports>$nPorts</nports>
<!-- <optional>1</optional> -->
</sink>
</block>

1
grc/crfa_vector_cutter.xml

@ -71,7 +71,6 @@
<type>complex</type> <type>complex</type>
<vlen>$insize</vlen> <vlen>$insize</vlen>
</sink> </sink>
<source> <source>
<name>out</name> <name>out</name>
<type>complex</type> <type>complex</type>

2
lib/rds_decoder_impl.cc

@ -110,7 +110,7 @@ unsigned int rds_decoder_impl::calc_syndrome(unsigned long message,
void rds_decoder_impl::decode_group(unsigned int *group) { void rds_decoder_impl::decode_group(unsigned int *group) {
// raw data bytes, as received from RDS. // raw data bytes, as received from RDS.
// 8 info bytes, followed by 4 RDS offset chars: ABCD/ABcD/EEEE (in US) // 8 info bytes, followed by 4 RDS offset chars: ABCD/ABcD/EEEE (in US)
unsigned char bytes[12]; unsigned char bytes[13];
// RDS information words // RDS information words
bytes[0] = (group[0] >> 8U) & 0xffU; bytes[0] = (group[0] >> 8U) & 0xffU;

3
python/CMakeLists.txt

@ -39,7 +39,8 @@ GR_PYTHON_INSTALL(
smooth_vectors.py smooth_vectors.py
chart.py chart.py
stream_selector.py stream_selector.py
vector_cutter.py DESTINATION ${GR_PYTHON_DIR}/crfa vector_cutter.py
decoder_compare.py DESTINATION ${GR_PYTHON_DIR}/crfa
) )
######################################################################## ########################################################################

1
python/__init__.py

@ -40,4 +40,5 @@ from smooth_vectors import smooth_vectors
from chart import Chart from chart import Chart
from stream_selector import stream_selector from stream_selector import stream_selector
from vector_cutter import vector_cutter from vector_cutter import vector_cutter
from decoder_compare import decoder_compare
# #

62
python/decoder_compare.py

@ -0,0 +1,62 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2017 <+YOU OR YOUR COMPANY+>.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
import numpy
from gnuradio import gr
import pmt,functools,time
class decoder_compare(gr.sync_block):
"""
docstring for block decoder_compare
"""
def __init__(self, nPorts=2):
gr.sync_block.__init__(self,
name="decoder_compare",
in_sig=None,
out_sig=None)
if nPorts==1:
self.message_port_register_in(pmt.intern('in'))
self.set_msg_handler(pmt.intern('in'), functools.partial(self.handle_msg, port=0))
else:
for i in range(nPorts):
self.message_port_register_in(pmt.intern('in%d'%i))
self.set_msg_handler(pmt.intern('in%d'%i), functools.partial(self.handle_msg, port=i))
self.nPorts=nPorts
self.synced=[False]*nPorts
self.numErrors=[0]*nPorts
self.numPackets=[0]*nPorts
self.printTime=time.time()
def handle_msg(self,msg,port):
#print("port:%i, msg:%s"%(port,pmt.to_python(msg)))
if pmt.to_long(pmt.car(msg))==1L:
data=pmt.to_python(pmt.cdr(msg))
#print("port:%i, data: %s"%(port,data))
self.synced[port]=data
print("errors:%s,Packets:%s, sync:%s"%(self.numErrors,self.numPackets,self.synced))
else: #elif pmt.to_long(pmt.car(msg))==0L
array=pmt.to_python(msg)[1]
self.numErrors[port]=array[12]
self.numPackets[port]+=1
if time.time()-self.printTime>2:#max every 2 sec
print("errors:%s,Packets:%s, sync:%s"%(self.numErrors,self.numPackets,self.synced))
self.printTime=time.time()
self.numPackets=[0]*self.nPorts

18
python/max_freq.py

@ -21,7 +21,7 @@
import numpy as np import numpy as np
from gnuradio import gr from gnuradio import gr
import code,math,pmt import code,math,pmt,time
class max_freq(gr.sync_block): class max_freq(gr.sync_block):
""" """
@ -40,10 +40,10 @@ class max_freq(gr.sync_block):
self.debug=debug self.debug=debug
self.last_station_indices=[0]*self.num_decoders self.last_station_indices=[0]*self.num_decoders
self.message_port_register_out(pmt.intern('out')) self.message_port_register_out(pmt.intern('out'))
self.counter=0 self.timer=time.time()
self.message_port_register_in(pmt.intern('ctrl')) self.message_port_register_in(pmt.intern('ctrl'))
self.set_msg_handler(pmt.intern('ctrl'), self.handle_ctrl_msg) self.set_msg_handler(pmt.intern('ctrl'), self.handle_ctrl_msg)
self.searchMode=True self.searchMode=False
self.index_fixed=[False]*self.num_decoders self.index_fixed=[False]*self.num_decoders
def freq_to_index(self,freq): def freq_to_index(self,freq):
startfreq=self.center_freq-self.samp_rate/2 startfreq=self.center_freq-self.samp_rate/2
@ -85,11 +85,9 @@ class max_freq(gr.sync_block):
else: else:
self.center_freq = int(freq) self.center_freq = int(freq)
def work(self, input_items, output_items): def work(self, input_items, output_items):
if self.counter<5: if time.time()-self.timer<1:#every 1 seconds
self.counter+=1
return len(input_items[0]) return len(input_items[0])
elif self.searchMode: elif self.searchMode:
self.counter=0
#in0 = input_items[0] #in0 = input_items[0]
#ii=input_items #ii=input_items
carrier_width=2 carrier_width=2
@ -184,10 +182,10 @@ class max_freq(gr.sync_block):
send_pmt = pmt.string_to_symbol(msg_string) send_pmt = pmt.string_to_symbol(msg_string)
self.message_port_pub(pmt.intern('out'), send_pmt) self.message_port_pub(pmt.intern('out'), send_pmt)
if self.debug: if self.debug:
print(max_indices) #print(max_indices)
print(station_indices_sorted) #print(station_indices_sorted)
print(station_indices_tune) #print(station_indices_tune)
print(station_strength) #print(station_strength)
print(station_freqs) print(station_freqs)
return len(input_items[0]) return len(input_items[0])

1
python/rds_parser_table_qt.py

@ -1024,6 +1024,7 @@ class rds_parser_table_qt(gr.sync_block):#START
#249 1111 1001 = 25AF #249 1111 1001 = 25AF
fillercode=205#1100 1101 fillercode=205#1100 1101
if not self.RDS_data[PI]["AF"].has_key("main") and self.RDS_data[PI].has_key("tuned_freq"): if not self.RDS_data[PI]["AF"].has_key("main") and self.RDS_data[PI].has_key("tuned_freq"):
#if self.RDS_data[PI].has_key("tuned_freq"):#update main freq even if one exists -> DB problem
freq=self.decode_AF_freq(array[4]) freq=self.decode_AF_freq(array[4])
if freq==self.RDS_data[PI]["tuned_freq"]: if freq==self.RDS_data[PI]["tuned_freq"]:
self.RDS_data[PI]["AF"]["main"]=freq self.RDS_data[PI]["AF"]["main"]=freq

Loading…
Cancel
Save