Skip to content

Commit ce42306

Browse files
author
Paul Prozesky
committed
Better handling of incomplete ?meta informs
1 parent 068d6d7 commit ce42306

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/katcp_fpga.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,11 @@ def _read_design_info_from_host(self, device=None):
598598
metalist = []
599599
for inform in informs:
600600
if len(inform.arguments) < 4:
601-
LOGGER.warn('Incorrect number of meta inform '
602-
'arguments: %s' % str(inform.arguments))
603-
# raise ValueError('Incorrect number of meta inform '
604-
# 'arguments: %s' % str(inform.arguments))
605601
if len(inform.arguments) == 3:
606-
inform.arguments.append('WARNING: no value rxd from host!')
602+
LOGGER.warn('Incorrect number of meta inform '
603+
'arguments, missing value '
604+
'field: %s' % str(inform.arguments))
605+
inform.arguments.append('-1')
607606
else:
608607
LOGGER.error('FEWER than THREE meta inform '
609608
'arguments: %s' % str(inform.arguments))

src/utils.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ def create_meta_dictionary(metalist):
2020
meta_items[name] = {}
2121
try:
2222
if meta_items[name]['tag'] != tag:
23-
raise ValueError('Different tags - %s, %s - for the same item %s' %
24-
(meta_items[name]['tag'], tag, name))
23+
raise ValueError(
24+
'Different tags - %s, %s - for the same item %s' % (
25+
meta_items[name]['tag'], tag, name))
2526
except KeyError:
2627
meta_items[name]['tag'] = tag
2728
meta_items[name][param] = value
@@ -60,12 +61,15 @@ def parse_fpg(filename):
6061
# and carry on as usual.
6162
line = line.replace('\_', ' ').replace('?meta', '')
6263
line = line.replace('\n', '').lstrip().rstrip()
63-
lineSplit = line.split('\t')
64-
name = lineSplit[0]
65-
tag = lineSplit[1]
66-
param = lineSplit[2]
67-
value = lineSplit[3:][0] if len(lineSplit[3:]) == 1 else ' '.join(lineSplit[3:])
68-
#name, tag, param, value = line.split('\t')
64+
line_split = line.split('\t')
65+
name = line_split[0]
66+
tag = line_split[1]
67+
param = line_split[2]
68+
if len(line_split[3:]) == 1:
69+
value = line_split[3:][0]
70+
else:
71+
value = ' '.join(line_split[3:])
72+
# name, tag, param, value = line.split('\t')
6973
name = name.replace('/', '_')
7074
metalist.append((name, tag, param, value))
7175
elif line.startswith('?register'):

0 commit comments

Comments
 (0)