Armed the gpio class

This commit is contained in:
2014-06-12 01:53:57 +02:00
parent 429932bf4b
commit bd5728062e
3 changed files with 56 additions and 21 deletions

View File

@ -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");
}
}
}