Class Writer
- Namespace
- DuetControlServer.Link.Protocol
- Assembly
- DuetControlServer.dll
Static class for writing data for SPI transmissions. This class makes sure each data block is on a 4-byte boundary to guarantee efficient DMA transfers on the remote side.
public static class Writer
- Inheritance
-
Writer
- Inherited Members
Methods
GetCodeSize(Code, int, int)
Calculate the size of a binary G/M/T-code
public static int GetCodeSize(Code code, int bufferSize, int protocolVersion)
Parameters
codeCodeCode to write
bufferSizeintSize of the buffer to write to
protocolVersionintProtocol version
Returns
- int
Code size in bytes
Exceptions
- ArgumentException
Thrown if the code is too long to fit into the buffer
InitTransferHeader(ref TransferHeader)
Initialize a transfer header
public static void InitTransferHeader(ref TransferHeader header)
Parameters
headerTransferHeaderHeader reference to initialize
WriteAssignFilament(Span<byte>, int, string)
Assign a filament name to the given extruder drive
public static int WriteAssignFilament(Span<byte> to, int extruder, string filamentName)
Parameters
Returns
- int
Number of bytes written
WriteBoolean(Span<byte>, bool)
Write an arbitrary boolean value
public static int WriteBoolean(Span<byte> to, bool value)
Parameters
Returns
- int
Number of bytes written
WriteCode(Span<byte>, Code, int)
Write a parsed G/M/T code in binary format to a memory span
public static int WriteCode(Span<byte> to, Code code, int protocolVersion)
Parameters
Returns
- int
Number of bytes written
Exceptions
- ArgumentException
Unsupported data type
WriteCodeChannel(Span<byte>, CodeChannel)
Write a G-code channel
public static int WriteCodeChannel(Span<byte> to, CodeChannel channel)
Parameters
toSpan<byte>Destination
channelCodeChannelChannel for the lock request
Returns
- int
Number of bytes written
WriteDeleteLocalVariable(Span<byte>, CodeChannel, string)
Write a DeleteLocalVariableHeader to a memory span
public static int WriteDeleteLocalVariable(Span<byte> to, CodeChannel channel, string varName)
Parameters
toSpan<byte>Destination
channelCodeChannelSource of this request
varNamestringName of the variable excluding var prefix
Returns
- int
Number of bytes written
WriteEvaluateExpression(Span<byte>, CodeChannel, string)
Write a request to evaluate an expression
public static int WriteEvaluateExpression(Span<byte> to, CodeChannel channel, string expression)
Parameters
toSpan<byte>Destination
channelCodeChannelWhere to evaluate the expression
expressionstringExpression to evaluate
Returns
- int
Number of bytes written
WriteFileChunk(Span<byte>, Span<byte>, long)
Write a file chunk
public static int WriteFileChunk(Span<byte> to, Span<byte> data, long fileLength)
Parameters
toSpan<byte>Destination
dataSpan<byte>File chunk data
fileLengthlongTotal length of the file in bytes
Returns
- int
Number of bytes written
WriteFileReadResult(Span<byte>, Span<byte>, int)
Write read file data
public static int WriteFileReadResult(Span<byte> to, Span<byte> data, int bytesRead)
Parameters
Returns
- int
Number of bytes written
WriteGetObjectModel(Span<byte>, string, string)
Request a part of the object model
public static int WriteGetObjectModel(Span<byte> to, string key, string flags)
Parameters
Returns
- int
Number of bytes written
WriteMacroCompleted(Span<byte>, CodeChannel, bool)
Write notification about a completed macro file
public static int WriteMacroCompleted(Span<byte> to, CodeChannel channel, bool error)
Parameters
toSpan<byte>Destination
channelCodeChannelChannel where the macro file has finished
errorboolWhether an error occurred when trying to open/process the macro file
Returns
- int
Number of bytes written
WriteMessage(Span<byte>, MessageTypeFlags, string)
Write a MessageHeader to a memory span
public static int WriteMessage(Span<byte> to, MessageTypeFlags type, string message)
Parameters
toSpan<byte>Destination
typeMessageTypeFlagsMessage flags
messagestringMessage content
Returns
- int
Number of bytes written
WriteOpenFileResult(Span<byte>, uint, long)
Write the result of an attempt to open a file
public static int WriteOpenFileResult(Span<byte> to, uint handle, long fileSize)
Parameters
Returns
- int
Number of bytes written
WritePacketHeader(Span<byte>, Request, ushort, int)
Write an arbitrary packet header to a memory span
public static void WritePacketHeader(Span<byte> to, Request request, ushort id, int length)
Parameters
toSpan<byte>Destination
requestRequestPacket type
idushortPacket ID
lengthintLength of the packet
WritePrintFileInfo(Span<byte>, GCodeFileInfo)
Notify the firmware that a print has started
public static int WritePrintFileInfo(Span<byte> to, GCodeFileInfo info)
Parameters
toSpan<byte>Destination
infoGCodeFileInfoInformation about the file being printed
Returns
- int
Number of bytes written
Exceptions
- ArgumentException
One of the supplied values is too big
WritePrintStopped(Span<byte>, PrintStoppedReason)
Notify the firmware that a print has been stopped
public static int WritePrintStopped(Span<byte> to, PrintStoppedReason reason)
Parameters
toSpan<byte>Destination
reasonPrintStoppedReasonReason why the print has been stopped
Returns
- int
Number of bytes written
WriteSetLastCodeResult(Span<byte>, CodeChannel, CodeResult)
Write the last result of a code executed by the SBC
public static int WriteSetLastCodeResult(Span<byte> to, CodeChannel channel, CodeResult result)
Parameters
toSpan<byte>Destination
channelCodeChannelCode channel
resultCodeResultCode result
Returns
- int
Number of bytes written
WriteSetObjectModel(Span<byte>, string, object)
Request the update of an object model field to an arbitrary value via a GetObjectModel request
public static int WriteSetObjectModel(Span<byte> to, string field, object value)
Parameters
Returns
- int
Number of bytes written
Remarks
value must be of type DataType
Exceptions
- ArgumentException
Unsupported data type
WriteSetVariable(Span<byte>, CodeChannel, bool, string, string)
Write a SetVariableHeader to a memory span
public static int WriteSetVariable(Span<byte> to, CodeChannel channel, bool createVariable, string varName, string expression)
Parameters
toSpan<byte>Destination
channelCodeChannelSource of this request
createVariableboolCreate a new variable
varNamestringName of the variable including prefix
expressionstringContent to assign to the variable
Returns
- int
Number of bytes written
WriteStringRequest(Span<byte>, string)
Write a StringHeader to a memory span
public static int WriteStringRequest(Span<byte> to, string data)
Parameters
Returns
- int
Number of bytes written