forked from M-Labs/artiq
1
0
Fork 0

Controller cleanups

This commit is contained in:
Yann Sionneau 2015-03-23 08:58:20 +01:00 committed by Sebastien Bourdeauducq
parent b45ad9d1a3
commit 2651050c83
4 changed files with 17 additions and 3 deletions

View File

@ -26,6 +26,10 @@ class Ldasim:
def get_att_step_size(self): def get_att_step_size(self):
return self._att_step_size return self._att_step_size
def close(self):
"""Close the device."""
pass
def get_attenuation(self): def get_attenuation(self):
"""Reads last attenuation value set to the simulated device. """Reads last attenuation value set to the simulated device.

View File

@ -211,6 +211,10 @@ class Tcube:
self.port.flush() self.port.flush()
logger.debug("baud rate set to 115200") logger.debug("baud rate set to 115200")
def close(self):
"""Close the device."""
self.port.close()
def send(self, msg): def send(self, msg):
msg.send(self.port) msg.send(self.port)

View File

@ -27,8 +27,11 @@ def main():
lda = Ldasim() lda = Ldasim()
else: else:
lda = Lda(args.serial, args.product) lda = Lda(args.serial, args.product)
simple_server_loop({"lda": lda}, try:
args.bind, args.port) simple_server_loop({"lda": lda},
args.bind, args.port)
finally:
lda.close()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -37,7 +37,10 @@ def main():
elif args.product == "TPZ001": elif args.product == "TPZ001":
dev = Tpz(args.device) dev = Tpz(args.device)
simple_server_loop({args.product.lower(): dev}, args.bind, args.port) try:
simple_server_loop({args.product.lower(): dev}, args.bind, args.port)
finally:
dev.close()
if __name__ == "__main__": if __name__ == "__main__":
main() main()