Browse Source

external tmc decoder: basic printing; table:fixed indenting (tabs -> spaces), xubdesk-hackrf-flowgraph: set gains/filterbw, now decoding 9 stations 90.8..1077, 270groups in 3 seconds

master
Clemens Richter 9 years ago
parent
commit
44db8a218d
  1. 3
      grc/CMakeLists.txt
  2. 10
      grc/crfa_rds_parser_table_qt.xml
  3. 100
      grc/crfa_tmc_parser.xml
  4. 3
      python/CMakeLists.txt
  5. 1
      python/__init__.py
  6. 27
      python/rds_parser_table_qt.py
  7. 1346
      python/rds_parser_table_qt.py.bak
  8. 77
      python/tmc_parser.py

3
grc/CMakeLists.txt

@ -31,5 +31,6 @@ install(FILES
crfa_sync_decim.xml
crfa_rds_decoder_redsea.xml
crfa_qtgui_range.xml
crfa_variable_setter.xml DESTINATION share/gnuradio/grc/blocks
crfa_variable_setter.xml
crfa_tmc_parser.xml DESTINATION share/gnuradio/grc/blocks
)

10
grc/crfa_rds_parser_table_qt.xml

@ -5,7 +5,9 @@
<category>[crfa]</category>
<import>import crfa</import>
<import>from crfa.rds_parser_table_qt import rds_parser_table_qt, rds_parser_table_qt_Widget,rds_parser_table_qt_Signals</import>
<!--
<var_make>self.$(id) = $(id) = $value</var_make>
-->
<make>#set $win = 'self._%s_win'%$id
#set $signals = 'self._%s_signals'%$id
#if not $label()
@ -108,7 +110,7 @@ $(gui_hint()($win))</make>
</option>
</param>
<!--
<!--
check if pty list file exists
check directory doesnt work:
<check>os.path.isdir($workdir)</check>
@ -135,7 +137,11 @@ check if pty list file exists
<type>message</type>
<optional>1</optional>
</source>
<source>
<name>tmc_raw</name>
<type>message</type>
<optional>1</optional>
</source>
<doc>show RDS data from multiple stations in QT table \
input: raw group data (array of ints) \
4x2 raw block data, 4x1 offset chars, 1x1 number of valid blocks (of last 50) \

100
grc/crfa_tmc_parser.xml

@ -0,0 +1,100 @@
<?xml version="1.0"?>
<block>
<name>tmc_parser</name>
<key>crfa_tmc_parser</key>
<category>crfa</category>
<import>import crfa</import>
<make>#set $win = 'self._%s_win'%$id
#set $parser = 'self.%s_parser'%$id
#if not $label()
#set $label = '"%s"'%$id
#end if
$(parser) = crfa.tmc_parser($workdir, $log, $debug, $writeDB)
$(win) = $(parser).getqtwidget()
$(gui_hint()($win))
</make>
<!--
crfa.tmc_parser($workdir, $log, $debug, $writeDB)
-->
<param>
<name>work directory</name>
<key>workdir</key>
<value></value>
<type>string</type>
<hide>part</hide>
</param>
<param>
<name>Label</name>
<key>label</key>
<value></value>
<type>string</type>
<hide>#if $label() then 'none' else 'part'#</hide>
</param>
<param>
<name>Log</name>
<key>log</key>
<value>False</value>
<type>bool</type>
<option>
<name>Enable</name>
<key>True</key>
</option>
<option>
<name>Disable</name>
<key>False</key>
</option>
</param>
<param>
<name>Debug</name>
<key>debug</key>
<value>False</value>
<type>bool</type>
<option>
<name>Enable</name>
<key>True</key>
</option>
<option>
<name>Disable</name>
<key>False</key>
</option>
</param>
<param>
<name>write Database</name>
<key>writeDB</key>
<value>False</value>
<type>bool</type>
<!--<hide>part</hide>-->
<option>
<name>Enable</name>
<key>True</key>
</option>
<option>
<name>Disable</name>
<key>False</key>
</option>
</param>
<param>
<name>GUI Hint</name>
<key>gui_hint</key>
<value></value>
<type>gui_hint</type>
<hide>part</hide>
</param>
<!--
check if event-list file exists
check directory doesnt work:
<check>os.path.isdir($workdir)</check>
-->
<check>open($workdir+"event-list_with_forecast_sort.csv").close() or True</check>
<!--
check if workdir is writable
-->
<check>open($workdir+"directory_writable","w").close() or True</check>
<sink>
<name>in</name>
<type>message</type>
<optional>1</optional>
</sink>
</block>

3
python/CMakeLists.txt

@ -43,7 +43,8 @@ GR_PYTHON_INSTALL(
decoder_compare.py
qtgui_range.py
variable_setter.py
tmc_classes.py DESTINATION ${GR_PYTHON_DIR}/crfa
tmc_classes.py
tmc_parser.py DESTINATION ${GR_PYTHON_DIR}/crfa
)
########################################################################

1
python/__init__.py

@ -43,4 +43,5 @@ from vector_cutter import vector_cutter
from decoder_compare import decoder_compare
from qtgui_range import qtgui_range
from variable_setter import variable_setter
from tmc_parser import tmc_parser
#

27
python/rds_parser_table_qt.py

@ -57,7 +57,6 @@ class rds_parser_table_qt(gr.sync_block):#START
#self.db.commit()
self.db.close()
def __init__(self,signals,nPorts,slot,freq,log,debug,workdir,writeDB,showTMC):
#QObject.__init__()
gr.sync_block.__init__(self,
name="RDS Table",
in_sig=None,
@ -73,6 +72,8 @@ class rds_parser_table_qt(gr.sync_block):#START
self.message_port_register_in(pmt.intern('freq'))
self.set_msg_handler(pmt.intern('freq'), self.set_freq)
self.message_port_register_out(pmt.intern('ctrl'))
self.message_port_register_out(pmt.intern('tmc_raw'))
self.log=log
self.debug=debug
self.writeDB=writeDB
@ -501,13 +502,7 @@ class rds_parser_table_qt(gr.sync_block):#START
adr= array[3]&0b00001111
ab_flag=(array[3]&0b00010000)>>4
#print("PI:%s, AB:%i"%(PI,ab_flag))
#if self.RDS_data[PI]["RT_last_ab_flag"] !=ab_flag:#AB flag changed -> clear text
# self.RDS_data[PI]["RT"]="_"*64
# self.RDS_data[PI]["RT_valid"]=[False]*64
# self.RDS_data[PI]["RT_last_ab_flag"] =ab_flag
self.RDS_data[PI]["RT_last_ab_flag"] =ab_flag
#segment=self.decode_chars(chr(array[4])+chr(array[5])+chr(array[6])+chr(array[7]))
@ -630,6 +625,10 @@ class rds_parser_table_qt(gr.sync_block):#START
self.RDS_data[PI]["AID_list"][AID]["delay_time"]=(app_data>>0)&0x3
elif self.debug:
print("unknown variant %i in TMC 3A group"%variant)
send_pmt = pmt.pmt_to_python.pmt_from_dict({
"type":"3A_meta",
"data":self.RDS_data[PI]["AID_list"][AID]})
self.message_port_pub(pmt.intern('tmc_raw'), send_pmt)
elif (groupType == "4A"):#CT clock time
bits=BitArray('uint:8=%i,uint:8=%i,uint:8=%i,uint:8=%i,uint:8=%i'%tuple(array[3:8]))
spare,datecode,hours,minutes,offsetdir,local_time_offset = bits.unpack("uint:6,uint:17,uint:5,uint:6,uint:1,uint:5")
@ -664,7 +663,7 @@ class rds_parser_table_qt(gr.sync_block):#START
db.execute("INSERT INTO data (time,PI,PSN,dataType,data) VALUES (?,?,?,?,?)",t)
elif (groupType == "6A"):#IH inhouse data -> save for analysis
"""In House Data:
{'130A': {'1E1077FFFF': {'count': 1,
{'130A': {'1E1077FFFF': {'count': 1,
'last_time': '2016-12-08 16:26:54.767596'},
'1F23022015': {'count': 1,
'last_time': '2016-12-08 16:26:56.341271'}},
@ -685,11 +684,19 @@ class rds_parser_table_qt(gr.sync_block):#START
tmc_x=array[3]&0x1f #lower 5 bit of block2
tmc_y=(array[4]<<8)|(array[5]) #block3
tmc_z=(array[6]<<8)|(array[7])#block4
send_pmt = pmt.pmt_to_python.pmt_from_dict({
"type":"alert-c",
"PI":PI,
"PSN":self.RDS_data[PI]["PSN"],
"TMC_X":tmc_x,
"TMC_Y":tmc_y,
"TMC_Z":tmc_z
})
self.message_port_pub(pmt.intern('tmc_raw'), send_pmt)
tmc_hash=md5.new(str([PI,tmc_x,tmc_y,tmc_z])).hexdigest()
tmc_T=tmc_x>>4 #0:TMC-message 1:tuning info/service provider name
tmc_F=int((tmc_x>>3)&0x1) #identifies the message as a Single Group (F = 1) or Multi Group (F = 0)
Y15=int(tmc_y>>15)
#timestring=self.RDS_data[PI]["time"]["timestring"]
datetime_received=self.RDS_data[PI]["time"]["datetime"]
if tmc_T == 0:
if tmc_F==1:#single group
@ -1328,5 +1335,3 @@ if __name__ == "__main__":
sys.exit(app.exec_())
widget = None

1346
python/rds_parser_table_qt.py.bak

File diff suppressed because it is too large Load Diff

77
python/tmc_parser.py

@ -0,0 +1,77 @@
#!/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
from PyQt4 import Qt, QtCore, QtGui
class tmc_parser(gr.sync_block):
"""
docstring for block tmc_parser
"""
def __init__(self, workdir,log,debug,writeDB):
gr.sync_block.__init__(self,
name="tmc_parser",
in_sig=None,
out_sig=None)
self.message_port_register_in(pmt.intern('in'))
self.set_msg_handler(pmt.intern('in'), self.handle_msg)
self.qtwidget=tmc_parser_Widget(self)
def handle_msg(self,msg):
m=pmt.to_python(msg)
self.qtwidget.updateui()
print(m)
def getqtwidget(self):
return self.qtwidget
class tmc_parser_Widget(QtGui.QWidget):
def updateui(self):
print("updating ui")
def filterChanged(self):
print("filter changed")
def __init__(self, parser):
QtGui.QWidget.__init__(self)
layout = Qt.QVBoxLayout()
self.setLayout(layout)
self.parser=parser
self.tmc_message_label=QtGui.QLabel("TMC messages:")
self.event_filter=QtGui.QLineEdit()#QPlainTextEdit ?
self.location_filter=QtGui.QLineEdit(u"Baden-Württemberg")
self.event_filter.returnPressed.connect(self.filterChanged)
self.location_filter.returnPressed.connect(self.filterChanged)
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)
layout.addLayout(filter_layout)
layout.addWidget(self.tmc_message_label)
self.logOutput = Qt.QTextEdit()
self.logOutput.setReadOnly(True)
self.logOutput.setLineWrapMode(Qt.QTextEdit.NoWrap)
self.logOutput.setMaximumHeight(150)
font = self.logOutput.font()
font.setFamily("Courier")
font.setPointSize(10)
layout.addWidget(self.logOutput)
self.clip = QtGui.QApplication.clipboard()
Loading…
Cancel
Save