Class CommandPart
A part that is not there, answering commands with the replies it was given.
public sealed class CommandPart : SimulatedPart, IDisposable
- Inheritance
-
CommandPart
- Implements
- Inherited Members
Remarks
A write sends a command and any arguments after it; a read then takes the reply that
command left, once, padded with 0xFF the way an idle bus reads. A command given no
reply leaves none, and a read then is not acknowledged, which is what a real part does when
asked for data it does not have.
Constructors
CommandPart(NativeHandle)
Wraps a part a native call made, such as a simulated sensor from another package.
public CommandPart(NativeHandle handle)
Parameters
handleNativeHandleThe part's handle, released with
pamoja_i2c_part_free.
CommandPart(byte, int)
Creates a part answering at one address that has been given no replies yet.
public CommandPart(byte address, int width = 2)
Parameters
addressbyteThe 7-bit address it answers to.
widthintHow many bytes a command takes: two for Sensirion's 16-bit commands.
Properties
Received
Every write the part has received, oldest first: a command and any arguments after it.
public IReadOnlyList<byte[]> Received { get; }
Property Value
Methods
Answer(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Answers one command with a reply from now on.
public void Answer(ReadOnlySpan<byte> command, ReadOnlySpan<byte> reply)
Parameters
commandReadOnlySpan<byte>The command's bytes.
replyReadOnlySpan<byte>What a read after it returns, in place of any reply given before.
Answering(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
Answers one command with a reply from now on, and returns the part.
public CommandPart Answering(ReadOnlySpan<byte> command, ReadOnlySpan<byte> reply)
Parameters
commandReadOnlySpan<byte>The command's bytes.
replyReadOnlySpan<byte>What a read after it returns, in place of any reply given before.
Returns
- CommandPart
This part, so calls chain.