GpioController.TryOpenPin 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:
 virtual bool TryOpenPin(int pinNumber, GpioSharingMode sharingMode, [Out] GpioPin ^ & pin, [Out] GpioOpenStatus & openStatus) = TryOpenPin;
bool TryOpenPin(int const& pinNumber, GpioSharingMode const& sharingMode, [Out] GpioPin const& & pin, [Out] GpioOpenStatus & openStatus);
public bool TryOpenPin(int pinNumber, GpioSharingMode sharingMode, out GpioPin pin, out GpioOpenStatus openStatus);
Public Function TryOpenPin (pinNumber As Integer, sharingMode As GpioSharingMode, ByRef pin As GpioPin, ByRef openStatus As GpioOpenStatus) As Boolean

Parameters

pinNumber
Int32

int

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

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

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

openStatus
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

Boolean

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.

Windows requirements

App capabilities
lowLevel

Applies to

See also