diff --git a/src/PhpGpio/Gpio.php b/src/PhpGpio/Gpio.php index eb79e1e..79b910a 100644 --- a/src/PhpGpio/Gpio.php +++ b/src/PhpGpio/Gpio.php @@ -98,6 +98,9 @@ public function setup($pinNo, $direction) // Export pin file_put_contents(GpioInterface::PATH_EXPORT, $pinNo); + // wait until pin is ready + while(!is_writable(GpioInterface::PATH_GPIO.$pinNo)) { /* empty */ } + // if valid direction then set direction if ($this->isValidDirection($direction)) { file_put_contents(GpioInterface::PATH_GPIO.$pinNo.'/direction', $direction);