Commit bc8de744 authored by Projects's avatar Projects

pulsegen: Disable output upon exception

parent 5cafc73b
...@@ -238,6 +238,12 @@ class PulseGen: ...@@ -238,6 +238,12 @@ class PulseGen:
raise RuntimeError('Operation interrupted (status: %s)' % status) raise RuntimeError('Operation interrupted (status: %s)' % status)
break break
def output_enable(self, state):
""" Enables/disables the generator output.
:param state: True to enable the output, false to disable it.
"""
self.ser.write(b'OUTP %s\r\n' % (b'ON' if state else b'OFF'))
############################################################################### ###############################################################################
if __name__ == '__main__': if __name__ == '__main__':
...@@ -309,5 +315,6 @@ if __name__ == '__main__': ...@@ -309,5 +315,6 @@ if __name__ == '__main__':
print(err.strerror) print(err.strerror)
sys.exit(2) sys.exit(2)
except: except:
gen.output_enable(False)
print('Error occurred') print('Error occurred')
sys.exit(2) sys.exit(2)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment