Armed the gpio class
This commit is contained in:
1 parent
429932bf4b
commit
bd5728062e
3 files changed
+56
-21
No files matched your search
+8
-6
@@ -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