Table of Contents

Class CommandPart

Namespace
Pamoja.Hal
Assembly
Pamoja.Hal.dll

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

handle NativeHandle

The 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

address byte

The 7-bit address it answers to.

width int

How 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

IReadOnlyList<byte[]>

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

command ReadOnlySpan<byte>

The command's bytes.

reply ReadOnlySpan<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

command ReadOnlySpan<byte>

The command's bytes.

reply ReadOnlySpan<byte>

What a read after it returns, in place of any reply given before.

Returns

CommandPart

This part, so calls chain.