![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
linux-device
Advanced tools
Readme
Native addon to communicate with linux devices (can also be used for sockets or FIFOs). All read and write operations are done in separate threads, resulting in higher performance compared to NodeJS filesystem functions
Install with npm
:
$ npm install linux-device
new DeviceHandle(String path, Boolean enableWrite, Number objectSize, [Number minimalObjectSize,] Function callback(Error err, Buffer data) )
Creates a new DeviceHandle instance.
Path
A path to a file or deviceenableWrite
True if file should be opened in write modeobjectSize
Maximal size in bytes for each callback eventminimalObjectSize
Minimal size in bytes for each callback event (defaults to ObjectSize)callback(Error err, Buffer data)
Callback function that is invoked whenever data of objectSize
is available.DeviceHandle.write(Buffer data [, Object opts], Function callback(Error err) )
Writes data to the device or file.
data
A buffer containing the data to write (append)opts
[optional] An object containing write options. Supported values are repetitions
and interval
callback(Error err)
Callback function containing an optional error while writing.DeviceHandle.ioctl(Number direction, Number type, Number cmd [, Buffer buffer])
Performs an ioctl
on the open device. Linux only.
direction
Either DeviceHandle.IOCTL_READ
, DeviceHandle.IOCTL_WRITE
, DeviceHandle.IOCTL_RW
or DeviceHandle.IOCTL_NONE
type
The type of the ioctlcmd
The command number of the ioctlbuffer
[optional] A buffer containing in and/or output of the ioctlDeviceHandle.ioctl_raw(Number cmd [, Buffer buffer])
Performs a raw ioctl
on the open device. Usage is discouraged. Linux only.
cmd
The command number of the ioctl, including direction, type and cmdbuffer
[optional] A buffer containing in and/or output of the ioctlDeviceHandle.close([Function callback()])
Closes the current device and invoke callback when the device is closed.
callback()
[optional] A callback functionvar DeviceHandle = require('linux-device');
var LIRC_IOCTL_TYPE = "i".charCodeAt(0);
var LIRC_IOCTL_SET_SEND_CARRIER = 0x13;
var LIRC_INTERVAL_SIZE = 4;
//Open device
var device = new DeviceHandle('/dev/lirc0', true, LIRC_INTERVAL_SIZE, function(err, data) {
if(err) return console.log("ERROR:", err);
console.log("received interval:", data.readUInt32LE(0).toString(16));
});
//Sets the IR carrier frequency
function setCarrier(carrier) {
var buffer = new Buffer(4);
buffer.writeUInt32LE(carrier, 0);
try {
device.ioctl(DeviceHandle.IOCTL_WRITE,
LIRC_IOCTL_TYPE, LIRC_IOCTL_SET_SEND_CARRIER, buffer);
} catch(e) {
console.log("An error occurred while performing lirc ioctl:", e);
}
}
//Transmits IR data through LIRC
function writeLircData(data, callback) {
if(!(data instanceof Buffer)) {
throw new Error("data must be an instance of Buffer");
}
var buffer = new Buffer(data.length*LIRC_INTERVAL_SIZE);
data.forEach(function(interval, i) {
buffer.writeUInt32LE(interval, i*LIRC_INTERVAL_SIZE);
}
device.write(data, callback);
}
//set the IR carrier frequency
setCarrier(38000);
//Transmit an IR beam every 2 seconds
var interval = setInterval(function() {
writeLircData([100,200,100,200,100], function() {
console.log("IR beam transmitted!");
});
}, 2000);
//close the device after 20 seconds
setTimeout(function() {
clearInterval(interval);
console.log("Closing device...");
device.close(function() {
console.log("Device closed!");
});
}, 20000);
FAQs
Native addon to communicate with linux devices (can also be used for sockets or FIFOs)
The npm package linux-device receives a total of 12 weekly downloads. As such, linux-device popularity was classified as not popular.
We found that linux-device demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.