Table of Contents

Class LinkInterface

Namespace
DuetControlServer.Link
Assembly
DuetControlServer.dll

Main firmware interface

[DiagnosticsPriority(-5)]
public sealed class LinkInterface : IDiagnostics
Inheritance
LinkInterface
Implements
Inherited Members

Constructors

Main firmware interface

public LinkInterface(Manager channels, ILinkAdapter linkAdapter, ILogger<LinkInterface> logger, IOptions<Settings> settings)

Parameters

channels Manager

Channel manager

linkAdapter ILinkAdapter

Firmware link adapter

logger ILogger<LinkInterface>

Logger instance

settings IOptions<Settings>

Settings

Methods

Abort all files in RRF on the given channel asynchronously

public Task AbortAllAsync(CodeChannel channel, CancellationToken cancellationToken = default)

Parameters

channel CodeChannel

Channel where all the files have been aborted

cancellationToken CancellationToken

Optional cancellation token

Returns

Task

Asynchronous task

Exceptions

InvalidOperationException

Not connected over SPI

Copy the state from one channel processor to another

public Task CopyStateAsync(CodeChannel from, CodeChannel to, CancellationToken cancellationToken = default)

Parameters

from CodeChannel

Source channel

to CodeChannel

Target channel

cancellationToken CancellationToken

Cancellation token

Returns

Task

Asynchronous task

Request an immediate emergency stop

public Task EmergencyStopAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token

Returns

Task

Asynchronous task

Evaluate an arbitrary expression

public Task<object?> EvaluateExpressionAsync(CodeChannel channel, string expression, CancellationToken cancellationToken = default)

Parameters

channel CodeChannel

Where to evaluate the expression

expression string

Expression to evaluate

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<object>

Result of the evaluated expression

Exceptions

CodeParserException

Failed to evaluate expression

InvalidOperationException

Not connected over SPI

NotSupportedException

Incompatible firmware version

ArgumentException

Invalid parameter

Wait for all pending codes of the first or last stack item to finish

public Task<bool> FlushAsync(CodeChannel channel, bool flushAll, CancellationToken cancellationToken = default)

Parameters

channel CodeChannel

Code channel to wait for

flushAll bool

Flush everything

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<bool>

Whether the codes have been flushed successfully

Wait for all pending codes on the same stack level as the given code to finish. By default this replaces all expressions as well for convenient parsing by the code processors.

public Task<bool> FlushAsync(Code code, CancellationToken cancellationToken = default)

Parameters

code Code

Code waiting for the flush

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<bool>

Whether the codes have been flushed successfully

Wait for all pending codes to finish

public Task<bool> FlushAsync(CodeFile file, CancellationToken cancellationToken = default)

Parameters

file CodeFile

Code file

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<bool>

Whether the codes have been flushed successfully

Lock all movement systems and wait for standstill

public Task<IAsyncDisposable> LockAllMovementSystemsAndWaitForStandstill(CodeChannel channel, CancellationToken cancellationToken = default)

Parameters

channel CodeChannel

Code channel acquiring the lock

cancellationToken CancellationToken

Returns

Task<IAsyncDisposable>

Disposable lock object that releases the lock when disposed

Exceptions

InvalidOperationException

Not connected over SPI

OperationCanceledException

Failed to get movement lock

Notify that an object model key has changed

public void ObjectModelKeyChanged(string key)

Parameters

key string

Changed key

Print diagnostics of this class

public void PrintDiagnostics(StringBuilder builder)

Parameters

builder StringBuilder

String builder

Request a specific update of the object model

public Task<byte[]> RequestObjectModel(string key, string flags, CancellationToken cancellationToken = default)

Parameters

key string

Key to request

flags string

Object model flags

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<byte[]>

Deserialized JSON document

Perform a firmware reset and wait for it to finish

public Task ResetFirmwareAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token

Returns

Task

Asynchronous task

Send a message to the firmware

public void SendMessage(MessageTypeFlags flags, string message)

Parameters

flags MessageTypeFlags

Message flags

message string

Message content

Exceptions

InvalidOperationException

Incompatible firmware or not connected over SPI

NotSupportedException

Incompatible firmware version

ArgumentException

Invalid parameter

Set the last code result for a specific code channel

public Task SetLastCodeResultAsync(Code code, CancellationToken cancellationToken = default)

Parameters

code Code
cancellationToken CancellationToken

Optional cancellation token

Returns

Task

Asynchronous task

Attempt to flag the currently executing macro file as (not) pausable

public Task SetMacroPausableAsync(CodeChannel channel, bool isPausable, CancellationToken cancellationToken = default)

Parameters

channel CodeChannel

Code channel where the macro is being executed

isPausable bool

Whether or not the macro file is pausable

cancellationToken CancellationToken

Cancellation token

Returns

Task

Asynchronous task

Update the print file info in the firmware

public Task SetPrintFileInfo(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Optional cancellation token

Returns

Task

Asynchronous task

Exceptions

InvalidOperationException

Not connected over SPI

Set or delete a global or local variable

public Task<object?> SetVariableAsync(CodeChannel channel, bool createVariable, string varName, string? expression, CancellationToken cancellationToken = default)

Parameters

channel CodeChannel

Where to evaluate the expression

createVariable bool

Whether the variable shall be created

varName string

Name of the variable

expression string

Expression to evaluate

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<object>

Result of the evaluated expression

Exceptions

CodeParserException

Failed to assign or delete variable

InvalidOperationException

Not connected over SPI

NotSupportedException

Incompatible firmware version

ArgumentException

Invalid parameter

Notify the firmware that the file print has been stopped

public Task StopPrintAsync(PrintStoppedReason reason, CancellationToken cancellationToken = default)

Parameters

reason PrintStoppedReason

Reason why the print has stopped

cancellationToken CancellationToken

Optional cancellation token

Returns

Task

Asynchronous task

Exceptions

InvalidOperationException

Not connected over SPI

OperationCanceledException

Connection lost while trying to notify RRF

Perform an update of the main firmware via IAP

public Task UpdateFirmware(Stream iapStream, Stream firmwareStream, CancellationToken cancellationToken = default)

Parameters

iapStream Stream

IAP binary

firmwareStream Stream

Firmware binary

cancellationToken CancellationToken

Optional cancellation token

Returns

Task

Asynchronous task

Exceptions

InvalidOperationException

Firmware is already being updated or not connected over SPI

Wait for potential firmware update to finish

public void WaitForUpdate()

Wait for potential firmware update to finish

public Task WaitForUpdateAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Optional cancellation token

Returns

Task

Asynchronous task