Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions pylabrobot/plate_reading/molecular_devices/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ async def send_command(
if raw_response.count(RES_TERM_CHAR) >= num_res_fields:
break
logger.debug("[plate reader] Command: %s, Response: %s", command, raw_response)
response = raw_response.decode("utf-8").strip().split(RES_TERM_CHAR.decode())
response = raw_response.decode("utf-8", errors="replace").strip().split(RES_TERM_CHAR.decode())
response = [r.strip() for r in response if r.strip() != ""]
self._parse_basic_errors(response, command)
return response
Expand All @@ -313,7 +313,7 @@ def _parse_basic_errors(self, response: List[str], command: str) -> None:
f"Command '{command}' failed with unparsable error: {response[0]}"
)

if "OK" not in response[0]:
if not any("OK" in r for r in response):
raise MolecularDevicesError(f"Command '{command}' failed with response: {response}")
if "warning" in response[0].lower():
logger.warning("Warning for command '%s': %s", command, response)
Expand All @@ -326,19 +326,29 @@ async def close(self, plate: Optional[Plate] = None) -> None:

async def get_status(self) -> List[str]:
res = await self.send_command("!STATUS")
return res[1].split()
if len(res) > 1:
return res[1].split()
raise ValueError(f"Could not parse status from response: {res}")

async def read_error_log(self) -> str:
async def read_error_log(self) -> List[str]:
res = await self.send_command("!ERROR")
return res[1]
if len(res) > 1:
return res[1].split()
raise ValueError(f"Could not parse error log from response: {res}")

async def clear_error_log(self) -> None:
await self.send_command("!CLEAR ERROR")

async def get_temperature(self) -> Tuple[float, float]:
res = await self.send_command("!TEMP")
parts = res[1].split()
return (float(parts[1]), float(parts[0])) # current, set_point
if len(res) > 1:
parts = res[1].split()
else:
parts = res[0].replace("OK", "").split()

if len(parts) >= 2:
return (float(parts[1]), float(parts[0])) # current, set_point
raise ValueError(f"Could not parse temperature from response: {res}")

async def set_temperature(self, temperature: float) -> None:
if not (0 <= temperature <= 45):
Expand Down