z
This commit is contained in:
@@ -86,12 +86,20 @@ class PrologixEndpointLoop:
|
||||
return default_cmds + extra
|
||||
return default_cmds
|
||||
|
||||
def _drain_errors(self, inst: Any, maxn: int = 20) -> list[str]:
|
||||
out: list[str] = []
|
||||
for _ in range(maxn):
|
||||
e = str(inst.ask(":SYST:ERR?")).strip()
|
||||
if e.startswith("0,") or "No error" in e:
|
||||
break
|
||||
out.append(e)
|
||||
return out
|
||||
|
||||
def _init_device(
|
||||
self, gpib_addr: int, driver_key: str, meta: dict[str, Any]
|
||||
) -> None:
|
||||
key = (driver_key or "").strip().lower()
|
||||
|
||||
# Only init if the configured driver is explicitly Keithley2000
|
||||
if key not in KEITHLEY_DRIVER_KEYS:
|
||||
self._initialized_addrs.add(gpib_addr)
|
||||
return
|
||||
@@ -108,11 +116,15 @@ class PrologixEndpointLoop:
|
||||
inst.write(cmd)
|
||||
time.sleep(0.02)
|
||||
|
||||
# Read error after each command; stop early if something is wrong
|
||||
err = str(inst.ask(":SYST:ERR?")).strip()
|
||||
if not err.startswith("0,") and "No error" not in err:
|
||||
log.error(f"Keithley init failed at {cmd}: {err}")
|
||||
break
|
||||
if err.startswith("0,") or "No error" in err:
|
||||
continue
|
||||
|
||||
log.error(f"Keithley init error at {cmd}: {err}")
|
||||
|
||||
errs = self._drain_errors(inst)
|
||||
if errs:
|
||||
log.warning(f"Keithley @ {gpib_addr} init error queue leftover: {errs}")
|
||||
|
||||
self._initialized_addrs.add(gpib_addr)
|
||||
|
||||
@@ -122,6 +134,7 @@ class PrologixEndpointLoop:
|
||||
|
||||
res = self.endpoint.conn["resource"]
|
||||
to_ms = int(self.endpoint.conn.get("gpib_read_timeout_ms", 500))
|
||||
log.info(f"gpib_read_timeout_ms set to {to_ms}")
|
||||
|
||||
# auto=False gives us manual control over addressing
|
||||
self._adapter = PrologixAdapter(res, gpib_read_timeout=to_ms, auto=False)
|
||||
@@ -208,7 +221,7 @@ class PrologixEndpointLoop:
|
||||
)
|
||||
except Exception as e:
|
||||
log.error(
|
||||
f"Prologix error {b.device.device_key}/{b.channel.metric}: {e}"
|
||||
f"Prologix error {b.device.device_key}/{b.channel.metric} query={b.query!r}: {e}"
|
||||
)
|
||||
await self.writer.write_error(
|
||||
device_id=b.device.device_id, error=f"prologix: {e}"
|
||||
|
||||
Reference in New Issue
Block a user