Comparing version 1.1.2 to 1.2.0
@@ -0,1 +1,7 @@ | ||
1.2.0 / Jan 06 2017 | ||
=================== | ||
* added forceAccess option which allows access to devices even if they are already in use by a driver | ||
* upgrade to nan v2.5.0, lodash v4.17.4 and async v2.1.4 | ||
1.1.2 / Oct 05 2016 | ||
@@ -2,0 +8,0 @@ =================== |
@@ -10,8 +10,11 @@ 'use strict'; | ||
function Bus(busNumber) { | ||
function Bus(busNumber, options) { | ||
if (!(this instanceof Bus)) { | ||
return new Bus(busNumber); | ||
return new Bus(busNumber, options); | ||
} | ||
options = options || {}; | ||
this._busNumber = busNumber; | ||
this._forceAccess = !!options.forceAccess || false; | ||
this._peripherals = []; | ||
@@ -44,5 +47,14 @@ } | ||
function open(busNumber, cb) { | ||
var bus = new Bus(busNumber); | ||
function open(busNumber, options, cb) { | ||
var bus; | ||
if (typeof options === 'function') { | ||
cb = options; | ||
options = undefined; | ||
} | ||
bus = new Bus(busNumber, options); | ||
setImmediate(cb, null); | ||
return bus; | ||
@@ -52,4 +64,4 @@ } | ||
function openSync(busNumber) { | ||
return new Bus(busNumber); | ||
function openSync(busNumber, options) { | ||
return new Bus(busNumber, options); | ||
} | ||
@@ -69,3 +81,3 @@ module.exports.openSync = openSync; | ||
i2c.setAddrAsync(device, addr, function (err) { | ||
i2c.setAddrAsync(device, addr, bus._forceAccess, function (err) { | ||
if (err) { | ||
@@ -89,3 +101,3 @@ return cb(err); | ||
bus._peripherals[addr] = peripheral; | ||
i2c.setAddrSync(peripheral, addr); | ||
i2c.setAddrSync(peripheral, addr, bus._forceAccess); | ||
} | ||
@@ -348,3 +360,3 @@ | ||
scanBus = open(this._busNumber, function (err) { | ||
scanBus = open(this._busNumber, {forceAccess: this._forceAccess}, function (err) { | ||
if (err) { | ||
@@ -376,3 +388,3 @@ return cb(err); | ||
Bus.prototype.scanSync = function () { | ||
var scanBus = openSync(this._busNumber), | ||
var scanBus = openSync(this._busNumber, {forceAccess: this._forceAccess}), | ||
addresses = [], | ||
@@ -379,0 +391,0 @@ addr; |
{ | ||
"name": "i2c-bus", | ||
"version": "1.1.2", | ||
"description": "I2C serial bus access with JavaScript", | ||
"version": "1.2.0", | ||
"description": "I2C serial bus access with Node.js", | ||
"main": "i2c-bus.js", | ||
@@ -23,7 +23,7 @@ "directories": { | ||
"bindings": "~1.2.1", | ||
"nan": "~2.4.0" | ||
"nan": "~2.5.0" | ||
}, | ||
"devDependencies": { | ||
"async": "~2.0.1", | ||
"lodash": "~4.16.3" | ||
"async": "~2.1.4", | ||
"lodash": "~4.17.4" | ||
}, | ||
@@ -30,0 +30,0 @@ "keywords": [ |
## i2c-bus | ||
I2C serial bus access with **Node.js** on Linux boards like the Raspberry Pi | ||
Zero, 1, 2, or 3, BeagleBone, BeagleBone Black, or Intel Edison. All methods | ||
have asynchronous and synchronous forms. | ||
I2C serial bus access with **Node.js** on Linux boards like the Raspberry Pi, | ||
C.H.I.P., BeagleBone or Intel Edison. All methods have asynchronous and | ||
synchronous forms. | ||
@@ -219,4 +219,4 @@ ## Installation | ||
- [open(busNumber, cb)](https://github.com/fivdi/i2c-bus#openbusnumber-cb) | ||
- [openSync(busNumber)](https://github.com/fivdi/i2c-bus#opensyncbusnumber) | ||
- [open(busNumber [, options], cb)](https://github.com/fivdi/i2c-bus#openbusnumber--options-cb) | ||
- [openSync(busNumber [, options])](https://github.com/fivdi/i2c-bus#opensyncbusnumber--options) | ||
@@ -281,4 +281,5 @@ ### Class Bus | ||
### open(busNumber, cb) | ||
### open(busNumber [, options], cb) | ||
- busNumber - the number of the I2C bus/adapter to open, 0 for /dev/i2c-0, 1 for /dev/i2c-1, ... | ||
- options - an optional options object | ||
- cb - completion callback | ||
@@ -288,7 +289,20 @@ | ||
### openSync(busNumber) | ||
The following options are supported: | ||
- forceAccess - A boolean value specifying whether access to devices on the | ||
I2C bus should be allowed even if they are already in use by a driver. The | ||
valid values for forceAccess are true and false. Optional, the default value | ||
is false. | ||
### openSync(busNumber [, options]) | ||
- busNumber - the number of the I2C bus/adapter to open, 0 for /dev/i2c-0, 1 for /dev/i2c-1, ... | ||
- options - an optional options object | ||
Synchronous open. Returns a new Bus object. | ||
The following options are supported: | ||
- forceAccess - A boolean value specifying whether access to devices on the | ||
I2C bus should be allowed even if they are already in use by a driver. The | ||
valid values for forceAccess are true and false. Optional, the default value | ||
is false. | ||
### bus.close(cb) | ||
@@ -295,0 +309,0 @@ - cb - completion callback |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
668160
1455
584
+ Addednan@2.5.1(transitive)
- Removednan@2.4.0(transitive)
Updatednan@~2.5.0