Skip to content

Commit 75c0b4e

Browse files
Merge pull request #1053 from TheDeanLab/ms2000_errorcode_fix
2 parents 19bb66b + f2973dd commit 75c0b4e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/navigate/model/devices/APIs/asi/asi_MS2000_controller.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ def __init__(self, code: str):
8484
self.code = code
8585

8686
#: str: Error message
87-
self.message = self.error_codes[code]
87+
try:
88+
self.message = self.error_codes[code]
89+
except KeyError:
90+
# if the exception is not a standard ASI Error Code:
91+
self.message = code
8892

8993
# Gets the proper message based on error code received.
9094
super().__init__(self.message)
@@ -371,10 +375,12 @@ def read_response(self) -> str:
371375
self.safe_to_write.set()
372376
response = response.decode(encoding="ascii")
373377
# Remove leading and trailing empty spaces
374-
self.report_to_console(f"Received Response: {response.strip()}")
378+
response = response.strip()
379+
self.report_to_console(f"Received Response: {response}")
375380
if response.startswith(":N"):
376-
logger.error(f"Incorrect response received: {response}")
377-
raise MS2000Exception(response)
381+
if not response.endswith("-21"): # we can ignore HALT command exceptions
382+
logger.error(f"Incorrect response received: {response}")
383+
raise MS2000Exception(response)
378384

379385
return response # in case we want to read the response
380386

0 commit comments

Comments
 (0)