Class Reader
- Namespace
- DuetControlServer.Link.Protocol
- Assembly
- DuetControlServer.dll
Static class for reading data from SPI transmissions. It is expected that each data block occupies entire 4-byte blocks. Make sure to keep the data returned by these functions only as long as the underlying buffer is actually valid!
public static class Reader
- Inheritance
-
Reader
- Inherited Members
Methods
ReadAbortFile(ReadOnlySpan<byte>, out CodeChannel, out bool)
Read information about an abort file request
public static int ReadAbortFile(ReadOnlySpan<byte> from, out CodeChannel channel, out bool abortAll)
Parameters
fromReadOnlySpan<byte>Origin
channelCodeChannelCode channel running the file
abortAllboolWhether all files are supposed to be aborted
Returns
- int
Number of bytes read
ReadCodeBufferUpdate(ReadOnlySpan<byte>, out ushort)
Read a code buffer update from a memory span
public static int ReadCodeBufferUpdate(ReadOnlySpan<byte> from, out ushort bufferSpace)
Parameters
fromReadOnlySpan<byte>Origin
bufferSpaceushortBuffer space
Returns
- int
Number of bytes read
ReadCodeChannel(ReadOnlySpan<byte>, out CodeChannel)
Read a G-code channel
public static int ReadCodeChannel(ReadOnlySpan<byte> from, out CodeChannel channel)
Parameters
fromReadOnlySpan<byte>Origin
channelCodeChannelChannel that has acquired the lock
Returns
- int
Number of bytes read
ReadDoCode(ReadOnlySpan<byte>, out CodeChannel, out string)
Read a DoCode request
public static int ReadDoCode(ReadOnlySpan<byte> from, out CodeChannel channel, out string code)
Parameters
fromReadOnlySpan<byte>Origin
channelCodeChannelCode channel
codestringCode to execute
Returns
- int
Number of bytes read
ReadEvaluationResult(ReadOnlySpan<byte>, out CodeChannel, out string, out object?)
Read a EvaluationResult request
public static int ReadEvaluationResult(ReadOnlySpan<byte> from, out CodeChannel channel, out string expression, out object? result)
Parameters
fromReadOnlySpan<byte>Origin
channelCodeChannelChannel where the evaluation was performed
expressionstringExpression
resultobjectEvaluation result
Returns
- int
Number of bytes read
ReadFileChunkRequest(ReadOnlySpan<byte>, out string, out uint, out int)
Read a file chunk request`
public static int ReadFileChunkRequest(ReadOnlySpan<byte> from, out string filename, out uint offset, out int maxLength)
Parameters
fromReadOnlySpan<byte>Origin
filenamestringFilename to read from
offsetuintOffset in the file
maxLengthintMaximum chunk length
Returns
- int
Number of bytes read
ReadFileHandle(ReadOnlySpan<byte>, out uint)
Read an arbitrary file handle
public static int ReadFileHandle(ReadOnlySpan<byte> from, out uint handle)
Parameters
fromReadOnlySpan<byte>Origin
handleuintFile handle
Returns
- int
Number of bytes read
ReadFileRequest(ReadOnlySpan<byte>, out uint, out int)
Read a request to retrieve data from a file
public static int ReadFileRequest(ReadOnlySpan<byte> from, out uint handle, out int maxLength)
Parameters
fromReadOnlySpan<byte>Origin
handleuintFile handle
maxLengthintMaximum buffer length
Returns
- int
Number of bytes read
ReadLegacyPrintPaused(ReadOnlySpan<byte>, out uint, out PrintPausedReason)
Read a legacy print pause event
public static int ReadLegacyPrintPaused(ReadOnlySpan<byte> from, out uint filePosition, out PrintPausedReason reason)
Parameters
fromReadOnlySpan<byte>Origin
filePositionuintPosition at which the print has been paused
reasonPrintPausedReasonReason why the print has been paused
Returns
- int
Number of bytes read
ReadMacroRequest(ReadOnlySpan<byte>, out CodeChannel, out bool, out string)
Read a macro file request from a memory span
public static int ReadMacroRequest(ReadOnlySpan<byte> from, out CodeChannel channel, out bool fromCode, out string filename)
Parameters
fromReadOnlySpan<byte>Origin
channelCodeChannelCode channel that requested the execution
fromCodeboolWhether the macro request came from the G/M/T-code being executed
filenamestringFilename of the macro to execute
Returns
- int
Number of bytes read
ReadMessage(ReadOnlySpan<byte>, out MessageTypeFlags, out string)
Read a message from a memory span
public static int ReadMessage(ReadOnlySpan<byte> from, out MessageTypeFlags messageType, out string reply)
Parameters
fromReadOnlySpan<byte>Origin
messageTypeMessageTypeFlagsMessage flags
replystringRaw message
Returns
- int
Number of bytes read
ReadOpenFile(ReadOnlySpan<byte>, out string, out bool, out bool, out long)
Read an open file request
public static int ReadOpenFile(ReadOnlySpan<byte> from, out string filename, out bool forWriting, out bool append, out long preAllocSize)
Parameters
fromReadOnlySpan<byte>Origin
filenamestringFilename to open
forWritingboolWhether the file is supposed to be written to
appendboolWhether data is supposed to be appended in write mode
preAllocSizelongHow many bytes to allocate if the file is created or overwritten
Returns
- int
Number of bytes read
ReadPacketHeader(ReadOnlySpan<byte>, out PacketHeader)
Read a packet header from a memory span
public static int ReadPacketHeader(ReadOnlySpan<byte> from, out PacketHeader packet)
Parameters
fromReadOnlySpan<byte>Origin
packetPacketHeaderRead packet
Returns
- int
Number of bytes read
ReadPrintPaused(ReadOnlySpan<byte>, out uint, out uint, out PrintPausedReason)
Read a print pause event
public static int ReadPrintPaused(ReadOnlySpan<byte> from, out uint filePosition, out uint filePosition2, out PrintPausedReason reason)
Parameters
fromReadOnlySpan<byte>Origin
filePositionuintPosition at which the print has been paused
filePosition2uintPosition at which the second open file has been paused (if applicable)
reasonPrintPausedReasonReason why the print has been paused
Returns
- int
Number of bytes read
ReadSeekFile(ReadOnlySpan<byte>, out uint, out long)
Read a request to seek in a file
public static int ReadSeekFile(ReadOnlySpan<byte> from, out uint handle, out long offset)
Parameters
fromReadOnlySpan<byte>Origin
handleuintFile handle
offsetlongNew file position
Returns
- int
Number of bytes read
ReadStringRequest(ReadOnlySpan<byte>, out ReadOnlySpan<byte>)
Read a UTF-8 encoded string request from a memory span
public static int ReadStringRequest(ReadOnlySpan<byte> from, out ReadOnlySpan<byte> data)
Parameters
fromReadOnlySpan<byte>Origin
dataReadOnlySpan<byte>UTF-8 string
Returns
- int
Number of bytes read
ReadStringRequest(ReadOnlySpan<byte>, out string)
Read a UTF-8 encoded string request from a memory span
public static int ReadStringRequest(ReadOnlySpan<byte> from, out string data)
Parameters
fromReadOnlySpan<byte>Origin
datastringUTF-8 string
Returns
- int
Number of bytes read