GpioChangeReader Class

Definition

Represents a shared circular buffer between kernel mode and user mode into which high-resolution timestamps are placed when a general-purpose I/O (GPIO) pin changes value.

public ref class GpioChangeReader sealed : IClosable
/// [Windows.Foundation.Metadata.Activatable(Windows.Devices.Gpio.IGpioChangeReaderFactory, 196608, "Windows.Devices.DevicesLowLevelContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Devices.DevicesLowLevelContract, 196608)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class GpioChangeReader final : IClosable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Devices.Gpio.IGpioChangeReaderFactory), 196608, "Windows.Devices.DevicesLowLevelContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Devices.DevicesLowLevelContract), 196608)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class GpioChangeReader : System.IDisposable
function GpioChangeReader(pin, minCapacity)
Public NotInheritable Class GpioChangeReader
Implements IDisposable
Inheritance
Object Platform::Object IInspectable GpioChangeReader
Attributes
Implements

Windows requirements

Device family
Windows 10 Creators Update (introduced in 10.0.15063.0)
API contract
Windows.Devices.DevicesLowLevelContract (introduced in v3.0)

Remarks

Kernel mode places a timestamp into the buffer when a pin changes value, and user mode removes items from the buffer. An overflow occurs when there is no longer sufficient room in the buffer to place additional timestamps. Upon overflow, further events are not recorded, and the IsOverflowed property will return true.

This class is not thread-safe. Calling functions of this class concurrently from multiple threads will have unpredictable results.

Constructors

GpioChangeReader(GpioPin)

Creates a new GpioChangeReader associated with the specified pin. Only a single GpioChangeReader may be associated with a pin at any given time.

GpioChangeReader(GpioPin, Int32)

Creates a new GpioChangeReader associated with the specified pin and with the specified minimum capacity for change records. Only a single GpioChangeReader may be associated with a pin at any given time.

Properties

Capacity

Gets the maximum number of change records that the GpioChangeReader can store at one time.

IsEmpty

Gets whether there are currently zero change records in the reader.

IsOverflowed

Gets whether an attempt to place a change record into the reader's buffer has failed due to the buffer being full.

IsStarted

Gets whether pin change recording is currently active.

Length

Gets the number of records currently in the change reader.

Polarity

Gets or sets the polarity of transitions that will be recorded. The polarity may only be changed when pin change recording is not started.

Methods

Clear()

Discards all change records from the reader's buffer.

Close()

Closes the change reader, releasing the associated memory buffer and disassociating the reader from its pin.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

GetAllItems()

Removes and returns all items current in the reader's buffer.

GetNextItem()

Retrieves and removes the earliest inserted change record from the reader's buffer.

PeekNextItem()

Retrieves the earlier inserted change record from the reader's buffer, without removing it.

Start()

Starts recording changes in pin polarity. This method may only be called when change recording is not already active.

Stop()

Stop recording changes in pin polarity. This method may only be called when change recording is currently active.

WaitForItemsAsync(Int32)

Waits for the buffer to fill with at least count number of items, at which point the async action will complete. This action is cancelable.

Applies to