Class: DeviceHandle

DeviceHandle(options)

JS Representation of a device inode

Constructor

new DeviceHandle(options)

Parameters:
Name Type Description
options object
Properties
Name Type Attributes Description
path string The path to the device
mode Number <optional>
The mode in which to open this device, defaults to constants.O_RDWR
absoluteSize Number <optional>
The object size of the read data, limits the buffer size to this size
autoOpen boolean <optional>
Set to true to automatically open this device upon construction

Extends

Members

(static) constants

DeviceHandle constants

Methods

(async, static) gpio(gpio, value)

Sets a GPIO output pin
Parameters:
Name Type Description
gpio number The gpio number
value Buffer Either true or false

(async) close()

Closes the device

(async) gpio()

Alias for DeviceHandle.gpio

(async) ioctl(direction, type, cmd, data)

Performs an ioctl on the device
Parameters:
Name Type Description
direction number Either constants.IOCTL_NONE, IOCTL_READ, IOCTL_WRITE, IOCTL_RW
type number The ioctl type
cmd number The ioctl command
data Buffer The ioctl data, the data may be changed by the ioctl

(async) ioctlRaw(cmd, data)

Performs a raw ioctl on the device
Parameters:
Name Type Description
cmd number The ioctl command
data Buffer The ioctl data, the data may be changed by the ioctl

isOpen() → {boolean}

Checks if the device is open
Returns:
True when the device is open, false otherwise
Type
boolean

(async) open() → {number}

Opens the device
Returns:
Device fd
Type
number