Class Interface
This class accesses RepRapFirmware via SPI and deals with general communication
Inherited Members
Namespace: DuetControlServer.SPI
Assembly: DuetControlServer.dll
Syntax
public static class Interface
Methods
AbortAllAsync(CodeChannel)
Abort all files in RRF on the given channel asynchronously
Declaration
public static Task AbortAllAsync(CodeChannel channel)
Parameters
Type | Name | Description |
---|---|---|
CodeChannel | channel | Channel where all the files have been aborted |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Not connected over SPI |
CopyStateAsync(CodeChannel, CodeChannel)
Copy the state from one channel processor to another
Declaration
public static Task CopyStateAsync(CodeChannel from, CodeChannel to)
Parameters
Type | Name | Description |
---|---|---|
CodeChannel | from | Source channel |
CodeChannel | to | Target channel |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
NotImplementedException |
Diagnostics(StringBuilder)
Print diagnostics of this class
Declaration
public static Task Diagnostics(StringBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
StringBuilder | builder | String builder |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
EmergencyStop()
Request an immediate emergency stop
Declaration
public static Task EmergencyStop()
Returns
Type | Description |
---|---|
Task | Asynchronous task |
EvaluateExpression(CodeChannel, string)
Evaluate an arbitrary expression
Declaration
public static Task<object?> EvaluateExpression(CodeChannel channel, string expression)
Parameters
Type | Name | Description |
---|---|---|
CodeChannel | channel | Where to evaluate the expression |
string | expression | Expression to evaluate |
Returns
Type | Description |
---|---|
Task<object> | Result of the evaluated expression |
Exceptions
Type | Condition |
---|---|
CodeParserException | Failed to evaluate expression |
InvalidOperationException | Not connected over SPI |
NotSupportedException | Incompatible firmware version |
ArgumentException | Invalid parameter |
FlushAsync(CodeChannel, bool)
Wait for all pending codes of the first or last stack item to finish
Declaration
public static Task<bool> FlushAsync(CodeChannel channel, bool flushAll)
Parameters
Type | Name | Description |
---|---|---|
CodeChannel | channel | Code channel to wait for |
bool | flushAll | Flush everything |
Returns
Type | Description |
---|---|
Task<bool> | Whether the codes have been flushed successfully |
FlushAsync(Code, bool, bool)
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.
Declaration
public static Task<bool> FlushAsync(Code code, bool evaluateExpressions = true, bool evaluateAll = true)
Parameters
Type | Name | Description |
---|---|---|
Code | code | Code waiting for the flush |
bool | evaluateExpressions | Evaluate all expressions when pending codes have been flushed |
bool | evaluateAll | Evaluate the expressions or only SBC fields if evaluateExpressions is set to true |
Returns
Type | Description |
---|---|
Task<bool> | Whether the codes have been flushed successfully |
FlushAsync(CodeFile)
Wait for all pending codes to finish
Declaration
public static Task<bool> FlushAsync(CodeFile file)
Parameters
Type | Name | Description |
---|---|---|
CodeFile | file | Code file |
Returns
Type | Description |
---|---|
Task<bool> | Whether the codes have been flushed successfully |
IsWaitingForAcknowledgment(CodeChannel)
Check if a code channel is waiting for acknowledgement
Declaration
public static bool IsWaitingForAcknowledgment(CodeChannel channel)
Parameters
Type | Name | Description |
---|---|---|
CodeChannel | channel | Channel to query |
Returns
Type | Description |
---|---|
bool | Whether the channel is awaiting acknowledgement |
LockAllMovementSystemsAndWaitForStandstill(CodeChannel)
Lock all movement systems and wait for standstill
Declaration
public static Task<IAsyncDisposable> LockAllMovementSystemsAndWaitForStandstill(CodeChannel channel)
Parameters
Type | Name | Description |
---|---|---|
CodeChannel | channel | Code channel acquiring the lock |
Returns
Type | Description |
---|---|
Task<IAsyncDisposable> | Disposable lock object that releases the lock when disposed |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Not connected over SPI |
OperationCanceledException | Failed to get movement lock |
RequestObjectModel(string, string)
Request a specific update of the object model
Declaration
public static Task<byte[]> RequestObjectModel(string key, string flags)
Parameters
Type | Name | Description |
---|---|---|
string | key | Key to request |
string | flags | Object model flags |
Returns
Type | Description |
---|---|
Task<byte[]> | Deserialized JSON document |
ResetFirmware()
Perform a firmware reset and wait for it to finish
Declaration
public static Task ResetFirmware()
Returns
Type | Description |
---|---|
Task | Asynchronous task |
Run()
Perform communication with the RepRapFirmware controller over SPI
Declaration
public static void Run()
SendMessage(MessageTypeFlags, string)
Send a message to the firmware
Declaration
public static void SendMessage(MessageTypeFlags flags, string message)
Parameters
Type | Name | Description |
---|---|---|
MessageTypeFlags | flags | Message flags |
string | message | Message content |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Incompatible firmware or not connected over SPI |
NotSupportedException | Incompatible firmware version |
ArgumentException | Invalid parameter |
SetMacroPausable(CodeChannel, bool)
Attempt to flag the currently executing macro file as (not) pausable
Declaration
public static Task SetMacroPausable(CodeChannel channel, bool isPausable)
Parameters
Type | Name | Description |
---|---|---|
CodeChannel | channel | Code channel where the macro is being executed |
bool | isPausable | Whether or not the macro file is pausable |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
SetPrintFileInfo()
Update the print file info in the firmware
Declaration
public static Task SetPrintFileInfo()
Returns
Type | Description |
---|---|
Task | Asynchronous task |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Not connected over SPI |
SetVariable(CodeChannel, bool, string, string?)
Set or delete a global or local variable
Declaration
public static Task<object?> SetVariable(CodeChannel channel, bool createVariable, string varName, string? expression)
Parameters
Type | Name | Description |
---|---|---|
CodeChannel | channel | Where to evaluate the expression |
bool | createVariable | Whether the variable shall be created |
string | varName | Name of the variable |
string | expression | Expression to evaluate |
Returns
Type | Description |
---|---|
Task<object> | Result of the evaluated expression |
Exceptions
Type | Condition |
---|---|
CodeParserException | Failed to assign or delete variable |
InvalidOperationException | Not connected over SPI |
NotSupportedException | Incompatible firmware version |
ArgumentException | Invalid parameter |
ShutdownAsync()
Called to shut down the SPI subsystem asynchronously
Declaration
public static Task ShutdownAsync()
Returns
Type | Description |
---|---|
Task | Asynchronous task |
StopPrint(PrintStoppedReason)
Notify the firmware that the file print has been stopped
Declaration
public static Task StopPrint(PrintStoppedReason reason)
Parameters
Type | Name | Description |
---|---|---|
PrintStoppedReason | reason | Reason why the print has stopped |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Not connected over SPI |
UpdateFirmware(Stream, Stream)
Perform an update of the main firmware via IAP
Declaration
public static Task UpdateFirmware(Stream iapStream, Stream firmwareStream)
Parameters
Type | Name | Description |
---|---|---|
Stream | iapStream | IAP binary |
Stream | firmwareStream | Firmware binary |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Firmware is already being updated or not connected over SPI |
WaitForUpdate()
Wait for potential firmware update to finish
Declaration
public static void WaitForUpdate()
WaitForUpdateAsync()
Wait for potential firmware update to finish
Declaration
public static Task WaitForUpdateAsync()
Returns
Type | Description |
---|---|
Task | Asynchronous task |