This PR fixes the Segmentation Fault occuring when a wrong gpioChip is passed to the libgpiod driver.
In a Raspberry PI this is typically 0 whichi is the default but on other boards there may be the need to specify a different number or even more than one (different I/Os are mapped on different chips).
The problem was related to the SafeHandle being non-null but invalid, therefore any following PInvoke to the native libgpiod library resulted in the fault.
After the change, the application calling the driver with a wrong gpioChip receive this exception message which can be handled in a catch statement.
System.IO.IOException: Unable to find a chip, error code: 2
The libgpiod V2 manages the gpioChip differently and it should already ok.
Fixes #2313
This PR fixes the Segmentation Fault occuring when a wrong gpioChip is passed to the
libgpiod
driver. In a Raspberry PI this is typically0
whichi is the default but on other boards there may be the need to specify a different number or even more than one (different I/Os are mapped on different chips).The problem was related to the
SafeHandle
being non-null but invalid, therefore any following PInvoke to the nativelibgpiod
library resulted in the fault.After the change, the application calling the driver with a wrong
gpioChip
receive this exception message which can be handled in acatch
statement.The
libgpiod
V2 manages thegpioChip
differently and it should already ok.Microsoft Reviewers: Open in CodeFlow