Skip to content

Commit 1d85f5f

Browse files
committed
Mods for new casperfpga
1 parent af1ff7c commit 1d85f5f

File tree

2 files changed

+17
-61
lines changed

2 files changed

+17
-61
lines changed

snap_control/snap_board.py

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -60,58 +60,6 @@ def __init__(self, hostname, katcp_port=7147, timeout=3,
6060
def __repr__(self):
6161

6262
return "<SnapBoard host: %s port: %s>" % (self.host, self.katcp_port)
63-
64-
def _program(self, filename=None):
65-
"""
66-
Program the FPGA with the specified binary file.
67-
:param filename: name of file to program, can vary depending on the formats
68-
supported by the device. e.g. fpg, bof, bin
69-
:return:
70-
"""
71-
72-
if filename is None:
73-
self.logger.error('%s: cannot program with no filename given. '
74-
'Exiting.' % self.host)
75-
raise RuntimeError('Cannot program with no filename given. '
76-
'Exiting.')
77-
78-
unhandled_informs = []
79-
80-
# set the unhandled informs callback
81-
self.unhandled_inform_handler = \
82-
lambda msg: unhandled_informs.append(msg)
83-
reply, _ = self.katcprequest(name='progdev', request_timeout=10,
84-
request_args=(filename, ))
85-
self.unhandled_inform_handler = None
86-
if reply.arguments[0] == 'ok':
87-
complete_okay = False
88-
for inf in unhandled_informs:
89-
if (inf.name == 'fpga') and (inf.arguments[0] == 'ready'):
90-
complete_okay = True
91-
if not complete_okay: # Modify to do an extra check
92-
reply, _ = self.katcprequest(name='status', request_timeout=1)
93-
# Not sure whether 1 second is a good timeout here
94-
if reply.arguments[0] == 'ok':
95-
complete_okay = True
96-
else:
97-
self.logger.error('%s: programming %s failed.' %
98-
(self.host, filename))
99-
for inf in unhandled_informs:
100-
LOGGER.debug(inf)
101-
raise RuntimeError('%s: programming %s failed.' %
102-
(self.host, filename))
103-
self.system_info['last_programmed'] = filename
104-
else:
105-
self.logger.error('%s: progdev request %s failed.' %
106-
(self.host, filename))
107-
raise RuntimeError('%s: progdev request %s failed.' %
108-
(self.host, filename))
109-
if filename[-3:] == 'fpg':
110-
self.get_system_information()
111-
else:
112-
self.logger.info('%s: %s is not an fpg file, could not parse '
113-
'system information.' % (self.host, filename))
114-
self.logger.info('%s: programmed %s okay.' % (self.host, filename))
11563

11664
def est_brd_clk(self):
11765
"""Returns the approximate clock rate of the FPGA in MHz.
@@ -138,7 +86,7 @@ def program(self, boffile, gain=1, demux_mode=1, chips=('a', 'b', 'c')):
13886
# Make a dictionary out of chips specified on command line.
13987
# mapping chip letters to numbers to facilitate writing to adc16_controller
14088
self.logger.info("Programming with %s - gain %i demux %i" % (boffile, gain, demux_mode))
141-
self._program(boffile)
89+
self.transport.program(boffile)
14290

14391
if self.is_adc16_based():
14492
self.logger.info("Design is ADC16 based. Calibration routines will run.")

snap_control/snap_manager.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
import logging
1414
import numpy as np
1515
from datetime import datetime
16-
import hickle as hkl
16+
17+
try:
18+
import hickle as hkl
19+
HAS_HKL = True
20+
except:
21+
HAS_HKL = False
1722

1823
from multiprocessing import JoinableQueue
1924

@@ -150,13 +155,16 @@ def check_calibration(self):
150155
def save_adc_snapshot(self, filename=None):
151156
d = self.grab_adc_snapshot()
152157

153-
print("Saving data...")
158+
if HAS_HKL:
159+
print("Saving data...")
154160

155-
if filename is None:
156-
now = datetime.now()
157-
now_str = now.strftime("%Y-%m-%d-%H%M%S")
158-
filename = 'adc_snapshot_%s.hkl' % now_str
159-
hkl.dump(d, filename)
160-
print("OK")
161+
if filename is None:
162+
now = datetime.now()
163+
now_str = now.strftime("%Y-%m-%d-%H%M%S")
164+
filename = 'adc_snapshot_%s.hkl' % now_str
165+
hkl.dump(d, filename)
166+
print("OK")
167+
else:
168+
print("Python hickle module not installed, cannot export data.")
161169

162170

0 commit comments

Comments
 (0)