stoner_measurement.instruments.protocol.mks.MKSPR4000Protocol

class stoner_measurement.instruments.protocol.mks.MKSPR4000Protocol[source]

Bases: BaseProtocol

PR4000B-S compact ASCII protocol with carriage-return framing.

format_command(command: str) → bytes[source]

Format a command string for transmission.

Parameters:

command (str) – The human-readable command string, without any protocol- specific terminators.

Returns:

Bytes ready to be passed to BaseTransport.write().

Return type:

(bytes)

format_query(query: str) → bytes[source]

Format a query string for transmission.

Parameters:

query (str) – The human-readable query string. Many protocols distinguish between commands (which do not elicit a response) and queries (which do); subclasses may add or modify a suffix accordingly.

Returns:

Bytes ready to be passed to BaseTransport.write().

Return type:

(bytes)

property max_frame_size: int

Maximum number of response bytes expected for one protocol frame.

Returns:

Default frame-size limit used by transports when reading a single response frame.

Return type:

(int)

parse_response(raw: bytes, *, command: str | None = None) → str[source]

Parse a raw response from the instrument.

Parameters:

raw (bytes) – Raw bytes as returned by the transport layer.

Keyword Parameters:

command (str | None) – Command/query string that produced raw, when available. Defaults to None.

Returns:

The cleaned-up response string, stripped of any protocol- specific framing, terminators, or whitespace.

Return type:

(str)

terminator = b'\r'