1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 10:50:51 +01:00

acmecape: Add check for nonzero return code from iio-capture

This commit is contained in:
Brendan Jackman 2017-10-04 17:32:32 +01:00
parent 0b04ffcc44
commit dbe568f51b

View File

@ -77,17 +77,22 @@ class AcmeCapeInstrument(Instrument):
def stop(self): def stop(self):
self.process.terminate() self.process.terminate()
timeout_secs = 10 timeout_secs = 10
output = ''
for _ in xrange(timeout_secs): for _ in xrange(timeout_secs):
if self.process.poll() is not None: if self.process.poll() is not None:
break break
time.sleep(1) time.sleep(1)
else: else:
output = _read_nonblock(self.process.stdout) output += _read_nonblock(self.process.stdout)
self.process.kill() self.process.kill()
self.logger.error('iio-capture did not terminate gracefully') self.logger.error('iio-capture did not terminate gracefully')
if self.process.poll() is None: if self.process.poll() is None:
msg = 'Could not terminate iio-capture:\n{}' msg = 'Could not terminate iio-capture:\n{}'
raise HostError(msg.format(output)) raise HostError(msg.format(output))
if self.process.returncode != 15: # iio-capture exits with 15 when killed
output += self.process.stdout.read()
raise HostError('iio-capture exited with an error ({}), output:\n{}'
.format(self.process.returncode, output))
if not os.path.isfile(self.raw_data_file): if not os.path.isfile(self.raw_data_file):
raise HostError('Output CSV not generated.') raise HostError('Output CSV not generated.')