Zum Hauptinhalt springen

raydriver.xtool

xTool device drivers implemented in Rust. XtoolSession supports D-series G-code jobs over the HTTP API. M2Session is available at raydriver.xtool.m2 for WS-V2 monitoring and control; it does not upload G-code jobs. Its untrusted-certificate option is explicit and disabled by default.

XtoolSession​

An xTool device session: connection lifecycle, interactive commands and job execution over the proprietary WiFi API, entirely in Rust.

All async methods return asyncio futures; a typed SessionEvent is delivered to event_callback(event) on the event loop thread.

is_job_running​

is_job_running: bool

resource_uri​

resource_uri: Optional[str]

state​

state: types.DeviceState

Current snapshot of the device state.

cancel()​

cancel(emergency: bool = False) -> Any

Stop the running job and send the safety-off commands.

ParameterTypeDescription
emergencybool = False
ReturnsAny

connect()​

connect() -> Any

Open the connection and start the background tasks.

ParameterTypeDescription
ReturnsAny

disconnect()​

disconnect() -> Any

Stop all background tasks and close the connection.

ParameterTypeDescription
ReturnsAny

execute_block()​

execute_block(block: str) -> Any

Execute a multi-line block of G-code via POST /cmd.

ParameterTypeDescription
blockstr
ReturnsAny

execute_command()​

execute_command(command: str) -> Any

Queue a single G-code line without failing on device-side rejections; the command status carries the error.

ParameterTypeDescription
commandstr
ReturnsAny

execute_interactive_command()​

execute_interactive_command(command: str) -> Any

Send a single G-code line and await the device's HTTP acknowledgement. The protocol has no per-line response text, so the result is always empty.

ParameterTypeDescription
commandstr
ReturnsAny

home()​

home() -> Any

Run the homing cycle and await the machine going idle again.

ParameterTypeDescription
ReturnsAny

jog()​

jog(speed: float, deltas: Optional[Sequence[tuple[str, float]]] = None) -> Any

Jog by relative deltas (mm) at speed (mm/min).

ParameterTypeDescription
speedfloat
deltasOptional[Sequence[tuple[str, float]]] = None
ReturnsAny

move_to()​

move_to(
x: float,
y: float,
z: Optional[float] = None,
speed: Optional[float] = None,
) -> Any

Move to an absolute position (mm) at speed (mm/min).

ParameterTypeDescription
xfloat
yfloat
zOptional[float] = None
speedOptional[float] = None
ReturnsAny

run()​

run(gcode: str) -> Any

Upload a G-code job, start it and await the machine's job-state events until it reports idle again.

ParameterTypeDescription
gcodestr
ReturnsAny

run_raw()​

run_raw(machine_code: str) -> Any

Upload a raw G-code string, start it and await completion.

ParameterTypeDescription
machine_codestr
ReturnsAny

set_focus_power()​

set_focus_power(power: Optional[float] = None) -> Any

Set laser power for focus mode; None turns the laser off.

ParameterTypeDescription
powerOptional[float] = None
ReturnsAny

set_hold()​

set_hold(hold: bool = True) -> Any

Pause (true) or resume (false) the running job.

ParameterTypeDescription
holdbool = True
ReturnsAny

set_power()​

set_power(power: Optional[float] = None) -> Any

Set laser power. power is the absolute S value; None turns the laser off.

ParameterTypeDescription
powerOptional[float] = None
ReturnsAny

update_dialect()​

update_dialect(dialect: dict) -> None
ParameterTypeDescription
dialectdict
ReturnsNone