mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
linux_gpio: check if pin is already exported
Signed-off-by: Nicolae Rosia <nicolae.rosia@gmail.com>
This commit is contained in:
committed by
Lorenz Meier
parent
b82a0f988e
commit
99d4f70ef8
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user