GpioController.TryOpenPin(Int32, GpioSharingMode, GpioPin, GpioOpenStatus) GpioController.TryOpenPin(Int32, GpioSharingMode, GpioPin, GpioOpenStatus) GpioController.TryOpenPin(Int32, GpioSharingMode, GpioPin, GpioOpenStatus) GpioController.TryOpenPin(Int32, GpioSharingMode, GpioPin, GpioOpenStatus) GpioController.TryOpenPin(Int32, GpioSharingMode, GpioPin, GpioOpenStatus) Method

Definition

Opens the specified general-purpose I/O (GPIO) pin in the specified mode, and gets a status value that you can use to handle a failure to open the pin programmatically.

public : Platform::Boolean TryOpenPin(int pinNumber, GpioSharingMode sharingMode, GpioPin pin, GpioOpenStatus openStatus)
bool TryOpenPin(int32_t pinNumber, GpioSharingMode sharingMode, GpioPin const& pin, GpioOpenStatus const& openStatus) const;
public bool TryOpenPin(Int32 pinNumber, GpioSharingMode sharingMode, GpioPin pin, GpioOpenStatus openStatus)
Public Function TryOpenPin(pinNumber As Int32, sharingMode As GpioSharingMode, pin As GpioPin, openStatus As GpioOpenStatus) As bool
var bool = gpioController.tryOpenPin(pinNumber, sharingMode, pin, openStatus);

Parameters

pinNumber
Int32 Int32 Int32

The pin number of the GPIO pin that you want to open. Some pins may not be available in user mode. For information about how the pin numbers correspond to physical pins, see the documentation for your circuit board.

sharingMode
GpioSharingMode GpioSharingMode GpioSharingMode

The mode in which you want to open the GPIO pin, which determines whether other connections to the pin can be opened while you have the pin open.

pin
GpioPin GpioPin GpioPin

The opened GPIO pin if the return value is true; otherwise null.

openStatus
GpioOpenStatus GpioOpenStatus GpioOpenStatus

An enumeration value that indicates either that the attempt to open the GPIO pin succeeded, or the reason that the attempt to open the GPIO pin failed.

Returns

bool bool bool

True if the method successfully opened the pin; otherwise false.

If the method returns true, the pin parameter receives an instance of a GpioPin, and the openStatus parameter receives GpioOpenStatus.PinOpened. If the method returns false, the pin parameter is null and the openStatus parameter receives the reason that the operation failed.

Additional features and requirements

Capabilities
<DeviceCapability name="lowLevel" />

See also