@johan-sports/subdevil
v0.1.0
Published
Cross-platform USB metadata
Downloads
1
Readme
Subdevil
Cross-platform USB metadata. Inspired by CargoSense's USBDriver.
Platforms
- OSX
- Windows
- ~~Linux~~
Requirements
- Node.js >= v5.x
Install
From NPM:
$ npm install subdevil
From git:
$ npm install git://github.com/johan-sports/subdevil
Usage
Include the subdevil library:
var subdevil = require('subdevil');
Poll and print available USB devices:
subdevil.poll().then(function(devices) {
console.log(devices.length + ' USB devices connected.');
devices.forEach(function(dev) {
console.log('====================');
console.log(dev);
console.log('====================');
}):
}).catch(function(error){
console.log('Something went wrong: ' + error);
});
Get a specific USB device by ID:
subdevil.get('0x22B3-0xEF23-IDQ21AS23AB').then(function(dev) {
console.log('Device found: ' + dev)
});
Unmount a device (if mounted):
subdevil.unmount('0x22B3-0xEF23-IDQ21AS23AB').then(function() {
console.log('Device unmounted successfully');
}).catch(function() {
console.log('Device unmount failed');
});
Set the log file to use for debug information:
subdevil.setLogFile('subdevil-debug.log');
A device is represented as an object containing these attributes:
{
id: '0x22B3-0xEF23-IDQ21AS23AB', // Unique ID for attached device
vendorCode: '0x22B3', // Hex for USB vendor ID
productCode: '0xEF23', // Hex for USB product ID
manufacturer: 'Foo Bar Technologies', // Name of manufacturer, if available
product: 'Code-o-meter 3000', // Name of product, if available
serialNumber: 'IDQ21AS23AB', // Serial number of device, if available
mount: '/Volumes/MY_FILES' // Path to volume mount point, if available
}
Test
npm test
Contributing
Contributions are more than welcome. Make sure the tests pass, open a PR and add yourself to the CONTRIBUTORS file.
License
See LICENSE