Armed the gpio class
This commit is contained in:
14
lib/Gpio.php
14
lib/Gpio.php
@ -28,13 +28,15 @@ class Gpio implements \ArrayAccess
|
||||
/** @var NoccyLabs\Gpio\GpioMapperInterface */
|
||||
protected $mapper;
|
||||
|
||||
public function __construct()
|
||||
public function __construct($force=false)
|
||||
{
|
||||
if (!file_exists("/sys/class/gpio")) {
|
||||
throw new HardwareException("gpio sysfs is not available");
|
||||
}
|
||||
if (!is_writable("/sys/class/gpio/export")) {
|
||||
throw new HardwareException("gpio sysfs is not writable");
|
||||
if (!$force) {
|
||||
if (!file_exists("/sys/class/gpio")) {
|
||||
throw new HardwareException("gpio sysfs is not available");
|
||||
}
|
||||
if (!is_writable("/sys/class/gpio/export")) {
|
||||
throw new HardwareException("gpio sysfs is not writable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user