Class Reader
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!
Inherited Members
Namespace: DuetControlServer.SPI.Serialization
Assembly: DuetControlServer.dll
Syntax
public static class Reader
Methods
ReadAbortFile(ReadOnlySpan<byte>, out CodeChannel, out bool)
Read information about an abort file request
Declaration
public static int ReadAbortFile(ReadOnlySpan<byte> from, out CodeChannel channel, out bool abortAll)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
CodeChannel | channel | Code channel running the file |
bool | abortAll | Whether all files are supposed to be aborted |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadCodeBufferUpdate(ReadOnlySpan<byte>, out ushort)
Read a code buffer update from a memory span
Declaration
public static int ReadCodeBufferUpdate(ReadOnlySpan<byte> from, out ushort bufferSpace)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
ushort | bufferSpace | Buffer space |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadCodeChannel(ReadOnlySpan<byte>, out CodeChannel)
Read a G-code channel
Declaration
public static int ReadCodeChannel(ReadOnlySpan<byte> from, out CodeChannel channel)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
CodeChannel | channel | Channel that has acquired the lock |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadDoCode(ReadOnlySpan<byte>, out CodeChannel, out string)
Read a DoCode request
Declaration
public static int ReadDoCode(ReadOnlySpan<byte> from, out CodeChannel channel, out string code)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
CodeChannel | channel | Code channel |
string | code | Code to execute |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadEvaluationResult(ReadOnlySpan<byte>, out string, out object?)
Read a EvaluationResult request
Declaration
public static int ReadEvaluationResult(ReadOnlySpan<byte> from, out string expression, out object? result)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
string | expression | Expression |
object | result | Evaluation result |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadFileChunkRequest(ReadOnlySpan<byte>, out string, out uint, out int)
Read a file chunk request`
Declaration
public static int ReadFileChunkRequest(ReadOnlySpan<byte> from, out string filename, out uint offset, out int maxLength)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
string | filename | Filename to read from |
uint | offset | Offset in the file |
int | maxLength | Maximum chunk length |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadFileHandle(ReadOnlySpan<byte>, out uint)
Read an arbitrary file handle
Declaration
public static int ReadFileHandle(ReadOnlySpan<byte> from, out uint handle)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
uint | handle | File handle |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadFileRequest(ReadOnlySpan<byte>, out uint, out int)
Read a request to retrieve data from a file
Declaration
public static int ReadFileRequest(ReadOnlySpan<byte> from, out uint handle, out int maxLength)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
uint | handle | File handle |
int | maxLength | Maximum buffer length |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadLegacyConfigResponse(ReadOnlySpan<byte>, out ReadOnlySpan<byte>)
Read a legacy config response from a memory span
Declaration
public static int ReadLegacyConfigResponse(ReadOnlySpan<byte> from, out ReadOnlySpan<byte> json)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
ReadOnlySpan<byte> | json | Config response JSON |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadMacroRequest(ReadOnlySpan<byte>, out CodeChannel, out bool, out string)
Read a macro file request from a memory span
Declaration
public static int ReadMacroRequest(ReadOnlySpan<byte> from, out CodeChannel channel, out bool fromCode, out string filename)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
CodeChannel | channel | Code channel that requested the execution |
bool | fromCode | Whether the macro request came from the G/M/T-code being executed |
string | filename | Filename of the macro to execute |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadMessage(ReadOnlySpan<byte>, out MessageTypeFlags, out string)
Read a message from a memory span
Declaration
public static int ReadMessage(ReadOnlySpan<byte> from, out MessageTypeFlags messageType, out string reply)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
MessageTypeFlags | messageType | Message flags |
string | reply | Raw message |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadOpenFile(ReadOnlySpan<byte>, out string, out bool, out bool, out long)
Read an open file request
Declaration
public static int ReadOpenFile(ReadOnlySpan<byte> from, out string filename, out bool forWriting, out bool append, out long preAllocSize)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
string | filename | Filename to open |
bool | forWriting | Whether the file is supposed to be written to |
bool | append | Whether data is supposed to be appended in write mode |
long | preAllocSize | How many bytes to allocate if the file is created or overwritten |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadPacketHeader(ReadOnlySpan<byte>, out PacketHeader)
Read a packet header from a memory span
Declaration
public static int ReadPacketHeader(ReadOnlySpan<byte> from, out PacketHeader packet)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
PacketHeader | packet | Read packet |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadPrintPaused(ReadOnlySpan<byte>, out uint, out PrintPausedReason)
Read a print pause event
Declaration
public static int ReadPrintPaused(ReadOnlySpan<byte> from, out uint filePosition, out PrintPausedReason reason)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
uint | filePosition | Position at which the print has been paused |
PrintPausedReason | reason | Reason why the print has been paused |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadSeekFile(ReadOnlySpan<byte>, out uint, out long)
Read a request to seek in a file
Declaration
public static int ReadSeekFile(ReadOnlySpan<byte> from, out uint handle, out long offset)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
uint | handle | File handle |
long | offset | New file position |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadStringRequest(ReadOnlySpan<byte>, out ReadOnlySpan<byte>)
Read a UTF-8 encoded string request from a memory span
Declaration
public static int ReadStringRequest(ReadOnlySpan<byte> from, out ReadOnlySpan<byte> data)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
ReadOnlySpan<byte> | data | UTF-8 string |
Returns
Type | Description |
---|---|
int | Number of bytes read |
ReadStringRequest(ReadOnlySpan<byte>, out string)
Read a UTF-8 encoded string request from a memory span
Declaration
public static int ReadStringRequest(ReadOnlySpan<byte> from, out string data)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<byte> | from | Origin |
string | data | UTF-8 string |
Returns
Type | Description |
---|---|
int | Number of bytes read |