linux_gpio: check if pin is already exported

Signed-off-by: Nicolae Rosia <nicolae.rosia@gmail.com>
This commit is contained in:
Nicolae Rosia
2017-05-18 23:09:44 +02:00
committed by Lorenz Meier
parent b82a0f988e
commit 99d4f70ef8
+5
View File
@@ -78,6 +78,11 @@ int LinuxGPIO::_exportPin(unsigned int pin)
int ret;
int bytes_to_write;
if (_readValue(pin) != -1) {
/* GPIO is already exported */
return 0;
}
fd = open("/sys/class/gpio/export", O_WRONLY);
if (fd == -1) {