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):
return self._att_step_size
def close(self):
"""Close the device."""
pass
def get_attenuation(self):
"""Reads last attenuation value set to the simulated device.

View File

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

View File

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

View File

@ -37,7 +37,10 @@ def main():
elif args.product == "TPZ001":
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__":
main()