stoner_measurement.instruments.xray.protocol.LegacyXrayProtocol

class stoner_measurement.instruments.xray.protocol.LegacyXrayProtocol[source]

Bases: BaseProtocol

Framing metadata for the controller’s fixed binary response.

The driver bypasses the text formatting API and writes opcodes directly. These formatting methods therefore reject strings rather than risk an accidental ASCII command or line terminator.

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 = None