• DuetAPI
  • DuetAPIClient
  • DuetControlServer
  • DuetWebServer
Show / Hide Table of Contents
  • DuetAPI
    • CodeChannel
    • CodeParserException
    • IncompatibleVersionException
    • InternalServerException
    • InvalidParameterTypeException
    • MissingParameterException
  • DuetAPI.Commands
    • Acknowledge
    • AddHttpEndpoint
    • AddUserSession
    • BaseCommand
    • BaseResponse
    • Cancel
    • CheckPassword
    • Code
    • CodeFlags
    • CodeParameter
    • CodeParameterConverter
    • CodeParserBuffer
    • CodeType
    • Command
    • Command<T>
    • ErrorResponse
    • EvaluateExpression
    • Flush
    • GetFileInfo
    • GetObjectModel
    • HttpResponseType
    • Ignore
    • InstallPlugin
    • InstallSystemPackage
    • InvalidateChannel
    • KeywordType
    • LockObjectModel
    • PatchObjectModel
    • ReceivedHttpRequest
    • ReloadPlugin
    • RemoveHttpEndpoint
    • RemoveUserSession
    • Resolve
    • ResolvePath
    • Response<T>
    • SendHttpResponse
    • SetNetworkProtocol
    • SetObjectModel
    • SetPluginData
    • SetPluginProcess
    • SetUpdateStatus
    • SimpleCode
    • StartPlugin
    • StartPlugins
    • StopPlugin
    • StopPlugins
    • SyncObjectModel
    • UninstallPlugin
    • UninstallSystemPackage
    • UnlockObjectModel
    • WriteMessage
  • DuetAPI.Connection
    • ConnectionMode
    • Defaults
    • InterceptionMode
    • SubscriptionMode
  • DuetAPI.Connection.InitMessages
    • ClientInitMessage
    • CodeStreamInitMessage
    • CommandInitMessage
    • InterceptInitMessage
    • PluginServiceInitMessage
    • ServerInitMessage
    • SubscribeInitMessage
  • DuetAPI.ObjectModel
    • Accelerometer
    • AccessLevel
    • AnalogSensor
    • AnalogSensorType
    • AnalogSensorTypeConverter
    • Axis
    • BeepRequest
    • Board
    • BoardClosedLoop
    • BoardState
    • Build
    • BuildObject
    • CPU
    • ClosedLoopCurrentFraction
    • ClosedLoopPositionError
    • Compatibility
    • CoreKinematics
    • CurrentMove
    • DSF
    • DeltaKinematics
    • DeltaTower
    • DeserializationFailedEventArgs
    • DeserializationFailedEventHandler
    • DirectDisplay
    • DirectDisplayController
    • DirectDisplayEncoder
    • DirectDisplayScreen
    • DirectDisplayScreenST7567
    • Directories
    • DistanceUnit
    • DistanceUnitConverter
    • Driver
    • DriverClosedLoop
    • Duet3DFilamentMonitor
    • Endstop
    • EndstopType
    • Extruder
    • ExtruderNonlinear
    • Fan
    • FanThermostaticControl
    • FilamentMonitor
    • FilamentMonitorEnableMode
    • FilamentMonitorStatus
    • FilamentMonitorType
    • GCodeFileInfo
    • GCodeFileInfoConverter
    • GpInputPort
    • GpOutputPort
    • HangprinterKinematics
    • Heat
    • Heater
    • HeaterModel
    • HeaterModelPID
    • HeaterMonitor
    • HeaterMonitorAction
    • HeaterMonitorCondition
    • HeaterState
    • HttpEndpoint
    • HttpEndpointType
    • IGrowingModelCollection
    • IModelCollection
    • IModelDictionary
    • IModelObject
    • InductiveSensor
    • InputChannel
    • InputChannelState
    • InputShaping
    • InputShapingType
    • Inputs
    • Job
    • KeepoutZone
    • KeepoutZoneCoordinates
    • Kinematics
    • KinematicsName
    • KinematicsNameConverter
    • LaserFilamentMonitor
    • LaserFilamentMonitorCalibrated
    • LaserFilamentMonitorConfigured
    • Layer
    • LedStrip
    • LedStripType
    • LimitedResponseCountAttribute
    • Limits
    • LogLevel
    • MachineMode
    • MachineStatus
    • Memory
    • Message
    • MessageBox
    • MessageBoxMode
    • MessageType
    • Microstepping
    • MinMaxCurrent<T>
    • ModelCollection<T>
    • ModelDictionaryConverter
    • ModelDictionary<TValue>
    • ModelGrowingCollection<T>
    • ModelObject
    • MotorsIdleControl
    • Move
    • MoveCalibration
    • MoveCompensation
    • MoveCompensationType
    • MoveDeviations
    • MoveQueueItem
    • MoveRotation
    • MoveSegmentation
    • Network
    • NetworkInterface
    • NetworkInterfaceType
    • NetworkProtocol
    • NetworkState
    • ObjectModel
    • ObjectModelConverter
    • Plugin
    • PluginManifest
    • PolarKinematics
    • Probe
    • ProbeGrid
    • ProbeType
    • PulsedFilamentMonitor
    • PulsedFilamentMonitorCalibrated
    • PulsedFilamentMonitorConfigured
    • RestorePoint
    • RotatingMagnetFilamentMonitor
    • RotatingMagnetFilamentMonitorCalibrated
    • RotatingMagnetFilamentMonitorConfigured
    • SBC
    • SbcPropertyAttribute
    • ScaraKinematics
    • Sensors
    • SessionType
    • Skew
    • Spindle
    • SpindleState
    • StartupError
    • State
    • TemperatureError
    • ThumbnailInfo
    • ThumbnailInfoFormat
    • TiltCorrection
    • TimesLeft
    • Tool
    • ToolRetraction
    • ToolState
    • UserSession
    • Volume
    • ZLeadscrewKinematics
  • DuetAPI.Utility
    • DriverId
    • DriverIdJsonConverter
    • FileLists
    • Heightmap
    • JsonCamelCaseStringEnumConverter
    • JsonCharEnumConverter
    • JsonHelper
    • JsonLowerCaseStringEnumConverter
    • JsonOptionalShortDateTimeConverter
    • JsonPolymorphicWriteOnlyConverter<T>
    • JsonRegexListConverter
    • JsonShortDateTimeConverter
    • RequiredPermissionsAttribute
    • SbcPermissions
    • SbcPermissionsConverter
  • DuetAPIClient
    • BaseCommandConnection
    • BaseConnection
    • CodeStreamConnection
    • CommandConnection
    • HttpEndpointConnection
    • HttpEndpointUnixSocket
    • HttpEndpointUnixSocket.EndpointRequestReceived
    • InterceptConnection
    • SubscribeConnection
  • DuetControlServer
    • Program
    • Settings
  • DuetControlServer.Codes
    • ChannelProcessor
    • PipelineStage
    • Processor
  • DuetControlServer.Codes.Handlers
    • Functions
    • GCodes
    • Keywords
    • MCodes
    • TCodes
  • DuetControlServer.Codes.Pipelines
    • Executed
    • Firmware
    • PipelineBase
    • PipelineStackItem
    • Post
    • Pre
    • ProcessInternally
    • Start
  • DuetControlServer.Commands
    • AddHttpEndpoint
    • AddUserSession
    • CheckPassword
    • Code
    • EvaluateExpression
    • Flush
    • GetFileInfo
    • GetObjectModel
    • IConnectionCommand
    • InstallPlugin
    • InstallSystemPackage
    • InvalidateChannel
    • LockObjectModel
    • PatchObjectModel
    • ReloadPlugin
    • RemoveHttpEndpoint
    • RemoveUserSession
    • ResolvePath
    • SetNetworkProtocol
    • SetObjectModel
    • SetPluginData
    • SetPluginProcess
    • SetUpdateStatus
    • SimpleCode
    • StartPlugin
    • StartPlugins
    • StopPlugin
    • StopPlugins
    • SyncObjectModel
    • UninstallPlugin
    • UninstallSystemPackage
    • UnlockObjectModel
    • WriteMessage
  • DuetControlServer.Files
    • CodeBlock
    • CodeFile
    • FileDirectory
    • FilePath
    • InfoParser
    • JobProcessor
    • MacroFile
  • DuetControlServer.Files.ImageProcessing
    • IconImageParser
    • ImageParser
    • ImageProcessingException
  • DuetControlServer.IPC
    • Connection
    • LockManager
    • Server
  • DuetControlServer.IPC.Processors
    • Base
    • CodeInterception
    • CodeStream
    • Command
    • ModelSubscription
    • PluginService
  • DuetControlServer.Model
    • Expressions
    • Expressions.CustomAsyncFunctionResolver
    • Filter
    • ItemPathNode
    • Observer
    • Observer.PropertyPathChanged
    • PeriodicUpdater
    • PropertyChangeType
    • Provider
    • Updater
  • DuetControlServer.SPI
    • DataTransfer
    • EvaluateExpressionRequest
    • Interface
    • Interface.MovementLock
    • VariableRequest
  • DuetControlServer.SPI.Channel
    • LockRequest
    • Manager
    • Processor
    • State
  • DuetControlServer.SPI.Communication
    • Consts
  • DuetControlServer.SPI.Communication.FirmwareRequests
    • AbortFileHeader
    • CodeBufferUpdateHeader
    • DoCodeHeader
    • EvaluationResultHeader
    • ExecuteMacroHeader
    • FileChunkHeader
    • FileHandleHeader
    • OpenFileHeader
    • PrintPausedHeader
    • PrintPausedReason
    • ReadFileHeader
    • Request
    • SeekFileHeader
  • DuetControlServer.SPI.Communication.SbcRequests
    • AssignFilamentHeader
    • BooleanHeader
    • CodeFlags
    • CodeHeader
    • CodeParameter
    • DeleteLocalVariableHeader
    • FileChunkHeader
    • FileDataHeader
    • GetObjectModelHeader
    • MacroCompleteHeader
    • OpenFileResult
    • PrintStartedHeader
    • PrintStoppedHeader
    • Request
    • SetObjectModelHeader
    • SetVariableHeader
  • DuetControlServer.SPI.Communication.Shared
    • CodeChannelHeader
    • DataType
    • HeightMapHeader
    • MessageHeader
    • MessageTypeFlags
    • PacketHeader
    • PrintStoppedReason
    • StringHeader
    • TransferHeader
    • TransferResponse
  • DuetControlServer.SPI.Serialization
    • Reader
    • Writer
  • DuetControlServer.Utility
    • BuildDateTimeAttribute
    • CRC16
    • CRC32
    • Firmware
    • Logger
    • PriorityThreadRunner
  • DuetWebServer
    • Program
    • Settings
    • Startup
  • DuetWebServer.Authorization
    • Policies
    • SessionKeyAuthenticationHandler
    • SessionKeyAuthenticationSchemeOptions
  • DuetWebServer.Controllers
    • MachineController
    • RepRapFirmwareController
    • WebSocketController
  • DuetWebServer.FileProviders
    • DuetFileProvider
  • DuetWebServer.Middleware
    • CustomEndpointMiddleware
    • FallbackMiddleware
    • FixContentTypeMiddleware
    • HttpEndpointConnection
  • DuetWebServer.Services
    • ModelObserver
    • SessionExpiry
  • DuetWebServer.Singletons
    • IModelProvider
    • IModelProvider.WebDirectoryChanged
    • ISessionStorage
    • ModelProvider
    • SessionStorage
  • DuetWebServer.Utility
    • CRC32

Class Writer

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.

Inheritance
object
Writer
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DuetControlServer.SPI.Serialization
Assembly: DuetControlServer.dll
Syntax
public static class Writer

Methods

InitTransferHeader(ref TransferHeader)

Initialize a transfer header

Declaration
public static void InitTransferHeader(ref TransferHeader header)
Parameters
Type Name Description
TransferHeader header

Header reference to initialize

WriteAssignFilament(Span<byte>, int, string)

Assign a filament name to the given extruder drive

Declaration
public static int WriteAssignFilament(Span<byte> to, int extruder, string filamentName)
Parameters
Type Name Description
Span<byte> to

Destination

int extruder

Extruder drive

string filamentName

Filament name

Returns
Type Description
int

Number of bytes written

WriteBoolean(Span<byte>, bool)

Write an arbitrary boolean value

Declaration
public static int WriteBoolean(Span<byte> to, bool value)
Parameters
Type Name Description
Span<byte> to

Destination

bool value

Boolean value

Returns
Type Description
int

Number of bytes written

WriteCode(Span<byte>, Code)

Write a parsed G/M/T code in binary format to a memory span

Declaration
public static int WriteCode(Span<byte> to, Code code)
Parameters
Type Name Description
Span<byte> to

Destination

Code code

Code to write

Returns
Type Description
int

Number of bytes written

Exceptions
Type Condition
ArgumentException

Unsupported data type

WriteCodeChannel(Span<byte>, CodeChannel)

Write a G-code channel

Declaration
public static int WriteCodeChannel(Span<byte> to, CodeChannel channel)
Parameters
Type Name Description
Span<byte> to

Destination

CodeChannel channel

Channel for the lock request

Returns
Type Description
int

Number of bytes written

WriteDeleteLocalVariable(Span<byte>, CodeChannel, string)

Write a DeleteLocalVariableHeader to a memory span

Declaration
public static int WriteDeleteLocalVariable(Span<byte> to, CodeChannel channel, string varName)
Parameters
Type Name Description
Span<byte> to

Destination

CodeChannel channel

Source of this request

string varName

Name of the variable excluding var prefix

Returns
Type Description
int

Number of bytes written

WriteEvaluateExpression(Span<byte>, CodeChannel, string)

Write a request to evaluate an expression

Declaration
public static int WriteEvaluateExpression(Span<byte> to, CodeChannel channel, string expression)
Parameters
Type Name Description
Span<byte> to

Destination

CodeChannel channel

Where to evaluate the expression

string expression

Expression to evaluate

Returns
Type Description
int

Number of bytes written

WriteFileChunk(Span<byte>, Span<byte>, long)

Write a file chunk

Declaration
public static int WriteFileChunk(Span<byte> to, Span<byte> data, long fileLength)
Parameters
Type Name Description
Span<byte> to

Destination

Span<byte> data

File chunk data

long fileLength

Total length of the file in bytes

Returns
Type Description
int

Number of bytes written

WriteFileReadResult(Span<byte>, Span<byte>, int)

Write read file data

Declaration
public static int WriteFileReadResult(Span<byte> to, Span<byte> data, int bytesRead)
Parameters
Type Name Description
Span<byte> to

Destination

Span<byte> data

Read file data

int bytesRead

Number of bytes read

Returns
Type Description
int

Number of bytes written

WriteGetObjectModel(Span<byte>, string, string)

Request a part of the object model

Declaration
public static int WriteGetObjectModel(Span<byte> to, string key, string flags)
Parameters
Type Name Description
Span<byte> to

Destination

string key

Key to the object model part

string flags

Object model flags

Returns
Type Description
int

Number of bytes written

WriteMacroCompleted(Span<byte>, CodeChannel, bool)

Write notification about a completed macro file

Declaration
public static int WriteMacroCompleted(Span<byte> to, CodeChannel channel, bool error)
Parameters
Type Name Description
Span<byte> to

Destination

CodeChannel channel

Channel where the macro file has finished

bool error

Whether an error occurred when trying to open/process the macro file

Returns
Type Description
int

Number of bytes written

WriteMessage(Span<byte>, MessageTypeFlags, string)

Write a MessageHeader to a memory span

Declaration
public static int WriteMessage(Span<byte> to, MessageTypeFlags type, string message)
Parameters
Type Name Description
Span<byte> to

Destination

MessageTypeFlags type

Message flags

string message

Message content

Returns
Type Description
int

Number of bytes written

WriteOpenFileResult(Span<byte>, uint, long)

Write the result of an attempt to open a file

Declaration
public static int WriteOpenFileResult(Span<byte> to, uint handle, long fileSize)
Parameters
Type Name Description
Span<byte> to

Destination

uint handle

File handle

long fileSize

File length

Returns
Type Description
int

Number of bytes written

WritePacketHeader(Span<byte>, Request, ushort, int)

Write an arbitrary packet header to a memory span

Declaration
public static void WritePacketHeader(Span<byte> to, Request request, ushort id, int length)
Parameters
Type Name Description
Span<byte> to

Destination

Request request

Packet type

ushort id

Packet ID

int length

Length of the packet

WritePrintFileInfo(Span<byte>, GCodeFileInfo)

Notify the firmware that a print has started

Declaration
public static int WritePrintFileInfo(Span<byte> to, GCodeFileInfo info)
Parameters
Type Name Description
Span<byte> to

Destination

GCodeFileInfo info

Information about the file being printed

Returns
Type Description
int

Number of bytes written

Exceptions
Type Condition
ArgumentException

One of the supplied values is too big

WritePrintStopped(Span<byte>, PrintStoppedReason)

Notify the firmware that a print has been stopped

Declaration
public static int WritePrintStopped(Span<byte> to, PrintStoppedReason reason)
Parameters
Type Name Description
Span<byte> to

Destination

PrintStoppedReason reason

Reason why the print has been stopped

Returns
Type Description
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

Declaration
public static int WriteSetObjectModel(Span<byte> to, string field, object value)
Parameters
Type Name Description
Span<byte> to

Destination

string field

Path to the object model field

object value

New value

Returns
Type Description
int

Number of bytes written

Remarks

value must be of type DataType

Exceptions
Type Condition
ArgumentException

Unsupported data type

WriteSetVariable(Span<byte>, CodeChannel, bool, string, string)

Write a SetVariableHeader to a memory span

Declaration
public static int WriteSetVariable(Span<byte> to, CodeChannel channel, bool createVariable, string varName, string expression)
Parameters
Type Name Description
Span<byte> to

Destination

CodeChannel channel

Source of this request

bool createVariable

Create a new variable

string varName

Name of the variable including prefix

string expression

Content to assign to the variable

Returns
Type Description
int

Number of bytes written

WriteStringRequest(Span<byte>, string)

Write a StringHeader to a memory span

Declaration
public static int WriteStringRequest(Span<byte> to, string data)
Parameters
Type Name Description
Span<byte> to

Destination

string data

String data

Returns
Type Description
int

Number of bytes written

In this article
Back to top Generated by DocFX