Interface ILinkAdapter
- Namespace
- DuetControlServer.Link.Adapter
- Assembly
- DuetControlServer.dll
Interface for hardware link adapters
public interface ILinkAdapter
Properties
PacketsToRead
Returns the number of packets to read
int PacketsToRead { get; }
Property Value
ProtocolVersion
Currently-used protocol version
int ProtocolVersion { get; }
Property Value
Methods
Connect(CancellationToken)
Attempt to connect to the firmware
void Connect(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenOptional cancellation token
DumpMalformedPacket()
Write the last packet + content for diagnostic purposes
void DumpMalformedPacket()
FlashFirmwareSegment(Stream)
Flash another segment of the firmware via the IAP binary
bool FlashFirmwareSegment(Stream stream)
Parameters
streamStreamStream of the firmware binary
Returns
- bool
Whether another segment could be sent
GetMaxFullTransferDelay()
Get the maximum time between two full transfers
double GetMaxFullTransferDelay()
Returns
- double
Time in ms
HadReset()
Check if the controller has been reset
bool HadReset()
Returns
- bool
Whether the controller has been reset
PerformFullTransfer(bool, CancellationToken)
Perform a full data transfer synchronously
void PerformFullTransfer(bool connecting = false, CancellationToken cancellationToken = default)
Parameters
connectingboolWhether this an initial connection is being established
cancellationTokenCancellationTokenOptional cancellation token
ReadAbortFile(out CodeChannel, out bool)
Read the content of an AbortFileHeader packet
void ReadAbortFile(out CodeChannel channel, out bool abortAll)
Parameters
channelCodeChannelCode channel where all files are supposed to be aborted
abortAllboolWhether all files are supposed to be aborted
ReadCheckFileExists(out string)
Read a request to check if a file exists
void ReadCheckFileExists(out string filename)
Parameters
filenamestringName of the file
ReadCloseFile(out uint)
Read a request to close a file
void ReadCloseFile(out uint handle)
Parameters
handleuintFile handle
ReadCodeBufferUpdate(out ushort)
Read a code buffer update
void ReadCodeBufferUpdate(out ushort bufferSpace)
Parameters
bufferSpaceushortBuffer space
ReadCodeChannel(out CodeChannel)
Read a code channel
void ReadCodeChannel(out CodeChannel channel)
Parameters
channelCodeChannelCode channel that has acquired the lock
ReadDeleteFileOrDirectory(out string)
Read a request to delete a file or directory
void ReadDeleteFileOrDirectory(out string filename)
Parameters
filenamestringName of the file
ReadDoCode(out CodeChannel, out string)
Read a code request
void ReadDoCode(out CodeChannel channel, out string code)
Parameters
channelCodeChannelChannel to execute this code on
codestringCode to execute
ReadEvaluationResult(out CodeChannel?, out string, out object?)
Read the result of an expression evaluation request
void ReadEvaluationResult(out CodeChannel? channel, out string expression, out object? result)
Parameters
channelCodeChannel?Channel where the evaluation was performed
expressionstringEvaluated expression
resultobjectResult
ReadFileChunkRequest(out string, out uint, out int)
Read a chunk of a FileChunk packet
void ReadFileChunkRequest(out string filename, out uint offset, out int maxLength)
Parameters
ReadFileRequest(out uint, out int)
Read a request to read data from a file
void ReadFileRequest(out uint handle, out int maxLength)
Parameters
ReadMacroRequest(out CodeChannel, out bool, out string)
Read the content of a ExecuteMacroHeader packet
void ReadMacroRequest(out CodeChannel channel, out bool isSystemMacro, out string filename)
Parameters
channelCodeChannelChannel requesting a macro file
isSystemMacroboolIndicates if this code is not bound to a code being executed (e.g. when a trigger macro is requested)
filenamestringFilename of the requested macro
ReadMessage(out MessageTypeFlags, out string)
Read an incoming message
void ReadMessage(out MessageTypeFlags messageType, out string reply)
Parameters
messageTypeMessageTypeFlagsMessage type flags of the reply
replystringCode reply
ReadNextPacket()
Read the next packet
PacketHeader? ReadNextPacket()
Returns
- PacketHeader?
The next packet or null if none is available
ReadObjectModel(out ReadOnlySpan<byte>)
Read the result of a GetObjectModel request
void ReadObjectModel(out ReadOnlySpan<byte> json)
Parameters
jsonReadOnlySpan<byte>JSON data
ReadOpenFile(out string, out bool, out bool, out long)
Read an open file request
void ReadOpenFile(out string filename, out bool forWriting, out bool append, out long preAllocSize)
Parameters
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
ReadPrintPaused(out uint, out uint, out PrintPausedReason)
Read the content of a PrintPausedHeader packet
void ReadPrintPaused(out uint filePosition, out uint filePosition2, out PrintPausedReason reason)
Parameters
filePositionuintPosition where the print has been paused
filePosition2uintSecondary file position where the print has been paused
reasonPrintPausedReasonReason why the print has been paused
ReadSeekFile(out uint, out long)
Read a request to seek in a file
void ReadSeekFile(out uint handle, out long offset)
Parameters
ReadTruncateFile(out uint)
Read a request to truncate a file
void ReadTruncateFile(out uint handle)
Parameters
handleuintFile handle
ReadWriteRequest(out uint, out ReadOnlySpan<byte>)
Read a request to write data to a file
void ReadWriteRequest(out uint handle, out ReadOnlySpan<byte> data)
Parameters
handleuintFile handle
dataReadOnlySpan<byte>Data to write
ResendPacket(PacketHeader, out Request)
Resend a packet back to the firmware
void ResendPacket(PacketHeader packet, out Request sbcRequest)
Parameters
packetPacketHeaderPacket holding the resend request
sbcRequestRequestContent of the packet to resend
StartIap(uint, CancellationToken)
Instruct the firmware to start the IAP binary
void StartIap(uint firmwareLength, CancellationToken cancellationToken = default)
Parameters
firmwareLengthuintLength of the firmware binary in bytes (used by USB IAP for end-of-transfer detection; ignored by SPI)
cancellationTokenCancellationTokenCancellation token
VerifyFirmwareChecksum(long, ushort)
Send the CRC16 checksum of the firmware binary to the IAP program and verify the written data
bool VerifyFirmwareChecksum(long firmwareLength, ushort crc16)
Parameters
firmwareLengthlongLength of the written firmware in bytes
crc16ushortCRC16 checksum of the firmware
Returns
- bool
Whether the firmware has been written successfully
WaitForIapReset()
Wait for the IAP program to reset the controller
void WaitForIapReset()
WriteCheckFileExistsResult(bool)
Send back whether a file exists or not
bool WriteCheckFileExistsResult(bool exists)
Parameters
existsboolWhether the file exists
Returns
- bool
If the packet could be written
WriteCode(Code)
Request a code to be executed
bool WriteCode(Code code)
Parameters
codeCodeCode to send
Returns
- bool
True if the packet could be written
WriteDeleteLocalVariable(CodeChannel, string)
Delete a local variable at the end of the current code block
bool WriteDeleteLocalVariable(CodeChannel channel, string varName)
Parameters
channelCodeChannelG-code channel
varNamestringName of the variable excluding var prefix
Returns
- bool
True if the packet could be written
WriteEmergencyStop()
Request an emergency stop
bool WriteEmergencyStop()
Returns
- bool
True if the packet could be written
WriteEvaluateExpression(CodeChannel, string)
Write a request for an expression evaluation
bool WriteEvaluateExpression(CodeChannel channel, string expression)
Parameters
channelCodeChannelWhere to evaluate the expression
expressionstringExpression to evaluate
Returns
- bool
Whether the evaluation request has been written successfully
WriteFileChunk(Span<byte>, long)
Write another chunk of the file being requested
bool WriteFileChunk(Span<byte> data, long fileLength)
Parameters
Returns
- bool
Whether the firmware has been written successfully
WriteFileDeleteResult(bool)
Send back whether a file or directory could be deleted
bool WriteFileDeleteResult(bool success)
Parameters
successboolWhether the file operation was successful
Returns
- bool
If the packet could be written
WriteFileReadResult(Span<byte>, int)
Write requested read data from a file
bool WriteFileReadResult(Span<byte> data, int bytesRead)
Parameters
Returns
- bool
If the packet could be written
WriteFileSeekResult(bool)
Tell RRF if the seek operation was successful
bool WriteFileSeekResult(bool success)
Parameters
successboolIf the seek operation succeeded
Returns
- bool
If the packet could be written
WriteFileTruncateResult(bool)
Tell RRF if the seek operation was successful
bool WriteFileTruncateResult(bool success)
Parameters
successboolIf the seek operation succeeded
Returns
- bool
If the packet could be written
WriteFileWriteResult(bool)
Tell RRF if the last file block could be written
bool WriteFileWriteResult(bool success)
Parameters
successboolIf the file data could be written
Returns
- bool
If the packet could be written
WriteGetObjectModel(string, string)
Request the key of an object module of a specific module
bool WriteGetObjectModel(string key, string flags)
Parameters
Returns
- bool
True if the packet could be written
WriteIapSegment(Stream, CancellationToken)
Write another segment of the IAP binary
bool WriteIapSegment(Stream stream, CancellationToken cancellationToken = default)
Parameters
streamStreamIAP binary
cancellationTokenCancellationTokenCancellation token
Returns
- bool
Whether another segment could be written
WriteInvalidateChannel(CodeChannel)
Called when a code channel is supposed to be invalidated (e.g. via abort keyword)
bool WriteInvalidateChannel(CodeChannel channel)
Parameters
channelCodeChannelCode channel that requires the lock
Returns
- bool
True if the packet could be written
WriteLockAllMovementSystemsAndWaitForStandstill(CodeChannel)
Request the movement systems to be locked and wait for standstill
bool WriteLockAllMovementSystemsAndWaitForStandstill(CodeChannel channel)
Parameters
channelCodeChannelCode channel that requires the lock
Returns
- bool
True if the packet could be written
WriteMacroCompleted(CodeChannel, bool)
Notify the firmware about a completed macro file. This function is only used for macro files that the firmware requested
bool WriteMacroCompleted(CodeChannel channel, bool error)
Parameters
channelCodeChannelCode channel of the finished macro
errorboolWhether an error occurred
Returns
- bool
True if the packet could be written
WriteMacroStarted(CodeChannel)
Notify RepRapFirmware that a macro file could be started
bool WriteMacroStarted(CodeChannel channel)
Parameters
channelCodeChannelCode channel that requires the lock
Returns
- bool
True if the packet could be written
WriteMessage(MessageTypeFlags, string)
Write a message
bool WriteMessage(MessageTypeFlags flags, string message)
Parameters
flagsMessageTypeFlagsMessage flags
messagestringMessage content
Returns
- bool
Whether the firmware has been written successfully
WriteObjectModelKeyChanged(string)
Notify RRF that an object model key has changed
bool WriteObjectModelKeyChanged(string key)
Parameters
keystringKey that has changed
Returns
- bool
If the packet could be written
WriteOpenFileResult(uint, long)
Write the new file handle and file length of the file that has just been opened
bool WriteOpenFileResult(uint fileHandle, long length)
Parameters
fileHandleuintNew file handle or noFileHandle if the file could not be opened
lengthlongLength of the file
Returns
- bool
If the packet could be written
WritePrintFileInfo(GCodeFileInfo)
Notify the firmware that a file print has started
bool WritePrintFileInfo(GCodeFileInfo info)
Parameters
infoGCodeFileInfoInformation about the file being printed
Returns
- bool
True if the packet could be written
WritePrintStopped(PrintStoppedReason)
Notify that a file print has been stopped
bool WritePrintStopped(PrintStoppedReason reason)
Parameters
reasonPrintStoppedReasonReason why the print has been stopped
Returns
- bool
True if the packet could be written
WriteReset()
Request a firmware reset
bool WriteReset()
Returns
- bool
True if the packet could be written
WriteSetLastCodeResult(CodeChannel, CodeResult)
Write the last code result for a specific code channel
bool WriteSetLastCodeResult(CodeChannel channel, CodeResult result)
Parameters
channelCodeChannelCode channel
resultCodeResultLast code result
Returns
- bool
If the packet could be written
WriteSetVariable(CodeChannel, bool, string, string)
Set a global or local variable
bool WriteSetVariable(CodeChannel channel, bool createVariable, string varName, string expression)
Parameters
channelCodeChannelG-code channel
createVariableboolWhether the variable should be created or updated
varNamestringName of the variable including global or var prefix
expressionstringNew value of the variable
Returns
- bool
True if the packet could be written
WriteUnlock(CodeChannel)
Release all acquired locks again
bool WriteUnlock(CodeChannel channel)
Parameters
channelCodeChannelCode channel that releases the locks
Returns
- bool
True if the packet could be written