Dia antes primera install
This commit is contained in:
308
node_modules/i2c-bus/History.md
generated
vendored
Normal file
308
node_modules/i2c-bus/History.md
generated
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
5.2.3 / Aug 06 2023
|
||||
===================
|
||||
|
||||
* update dependencies
|
||||
* update information related to supported versions
|
||||
|
||||
5.2.2 / Apr 29 2021
|
||||
===================
|
||||
|
||||
* remove news and updates section of readme
|
||||
* drop support for node.js 8 and 13, add support for node.js 15 & 16
|
||||
* update dependencies
|
||||
|
||||
5.2.1 / Oct 11 2020
|
||||
===================
|
||||
|
||||
* add directories section to package.json
|
||||
|
||||
5.2.0 / Apr 24 2020
|
||||
===================
|
||||
|
||||
* add unit tests for PromisifiedBus
|
||||
* update dependencies
|
||||
* drop support for node.js 6, add support for node.js 14
|
||||
|
||||
5.1.0 / Oct 03 2019
|
||||
===================
|
||||
|
||||
* add bus.promisifiedBus and promisifiedBus.bus
|
||||
|
||||
5.0.0 / Sep 17 2019
|
||||
===================
|
||||
|
||||
* drop support for node.js v4
|
||||
* add promise support
|
||||
* ensure that the properties of i2cFuncs objects are booleans rather than numbers
|
||||
|
||||
4.0.11 / Sep 07 2019
|
||||
====================
|
||||
|
||||
* update dependencies (async v3.1.0, coveralls v3.0.6, lodash v4.17.15, mocha v6.2.0, sinon v7.4.2)
|
||||
|
||||
4.0.10 / Jun 16 2019
|
||||
====================
|
||||
|
||||
* update dependencies
|
||||
* update npm keywords
|
||||
|
||||
4.0.9 / Mar 14 2019
|
||||
===================
|
||||
|
||||
* add unit tests
|
||||
* update dependencies (nan v2.13.0, jshint v2.10.2)
|
||||
|
||||
4.0.8 / Mar 01 2019
|
||||
===================
|
||||
|
||||
* add travis build
|
||||
* lint with jshint
|
||||
* update dependencies (bindings v1.5.0, async v2.6.2)
|
||||
* document node 11 support
|
||||
* add .npmignore and .npmrc
|
||||
|
||||
4.0.7 / Dec 19 2018
|
||||
===================
|
||||
|
||||
* update dependencies (nan v2.12.1, bindings v1.3.1)
|
||||
|
||||
4.0.6 / Nov 18 2018
|
||||
===================
|
||||
|
||||
* fix macOS installation
|
||||
|
||||
4.0.5 / Oct 14 2018
|
||||
===================
|
||||
|
||||
* suppress warnings complaining about casting between incompatible function types (see https://github.com/nodejs/nan/issues/807)
|
||||
|
||||
4.0.4 / Oct 13 2018
|
||||
===================
|
||||
|
||||
* always compile c++ code
|
||||
|
||||
4.0.3 / Oct 13 2018
|
||||
===================
|
||||
|
||||
* fix deprecation warnings on node.js v10.12 (see https://github.com/nodejs/nan/pull/811)
|
||||
|
||||
4.0.2 / Sep 30 2018
|
||||
===================
|
||||
|
||||
* update dependencies (nan v2.11.1, async v2.6.1, lodash v4.17.11)
|
||||
* adapt to V8 7.0: replace v8Value->Int32Value() with Nan::To<int32_t>(v8Value).FromJust()
|
||||
* adapt to V8 7.0: replace v8Value->Uint32Value() with Nan::To<uint32_t>(v8Value).FromJust()
|
||||
* adapt to V8 7.0: replace v8Value->BooleanValue() with Nan::To<bool>(v8Value).FromJust()
|
||||
|
||||
4.0.1 / Jul 28 2018
|
||||
===================
|
||||
|
||||
* code style
|
||||
|
||||
4.0.0 / Jul 25 2018
|
||||
===================
|
||||
|
||||
* modernize codebase
|
||||
* drop initial windows support as i can't extend and maintain it
|
||||
|
||||
3.2.0 / Apr 21 2018
|
||||
===================
|
||||
|
||||
* add deviceId and deviceIdSync methods
|
||||
|
||||
3.1.0 / Mar 24 2018
|
||||
===================
|
||||
|
||||
* allow scan address range to be specified
|
||||
* update dependencies (nan v2.10.0)
|
||||
|
||||
3.0.0 / Feb 25 2018
|
||||
===================
|
||||
|
||||
* update dependencies (nan v2.9.2)
|
||||
* fix deprecations
|
||||
* drop support for node.js v0.10, v0.12, v5 and v7
|
||||
|
||||
2.0.0 / Feb 11 2018
|
||||
===================
|
||||
|
||||
* check parameters passed to api at api surface [#42](https://github.com/fivdi/i2c-bus/issues/42)
|
||||
* update dependencies (async v2.6.0, lodash 4.17.5)
|
||||
|
||||
1.2.5 / Dec 24 2017
|
||||
===================
|
||||
|
||||
* don't suppress deprecated-declaration warnings
|
||||
* update dependencies
|
||||
|
||||
1.2.4 / Nov 04 2017
|
||||
===================
|
||||
|
||||
* suppress deprecated-declaration warnings
|
||||
* document node 9 support
|
||||
|
||||
1.2.3 / Oct 15 2017
|
||||
===================
|
||||
|
||||
* update dependencies (bindings v1.3.0, nan v2.7.0)
|
||||
|
||||
1.2.2 / May 01 2017
|
||||
===================
|
||||
|
||||
* update dependencies
|
||||
* document supported node versions
|
||||
* fix writeQuick argument check
|
||||
|
||||
1.2.1 / Feb 12 2017
|
||||
===================
|
||||
|
||||
* documentation for forceAccess option improved
|
||||
* upgrade to nan v2.5.1
|
||||
|
||||
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
|
||||
===================
|
||||
|
||||
* allow scan and scanSync to continue scanning on all errors
|
||||
* upgrade to lodash v4.16.3 and async v2.0.1
|
||||
|
||||
1.1.1 / Jul 22 2016
|
||||
===================
|
||||
|
||||
* examples SI1145-sync.js and two-devices-win.js added
|
||||
* nan 2.4.0, lodash 4.13.1, async 2.0.0
|
||||
|
||||
1.1.0 / May 23 2016
|
||||
===================
|
||||
|
||||
* initial windows support
|
||||
|
||||
1.0.3 / Apr 27 2016
|
||||
===================
|
||||
|
||||
* nan v2.3.2, lodash 4.11.1
|
||||
|
||||
1.0.2 / Jan 29 2016
|
||||
===================
|
||||
|
||||
* nan 2.2.0, async 1.5.2, lodash 4.1.0
|
||||
|
||||
1.0.1 / Dec 05 2015
|
||||
===================
|
||||
|
||||
* prevent Nan::ErrnoException related segmentation faults in v0.10.29
|
||||
|
||||
1.0.0 / Oct 10 2015
|
||||
===================
|
||||
|
||||
* prevent leaking of fds for busy devices [#13](https://github.com/fivdi/i2c-bus/issues/13)
|
||||
* refactored error objects [#12](https://github.com/fivdi/i2c-bus/issues/12)
|
||||
* nan 2.1.0
|
||||
|
||||
0.12.0 / Oct 06 2015
|
||||
====================
|
||||
|
||||
* added scan and scanSync [#11](https://github.com/fivdi/i2c-bus/issues/11)
|
||||
* nan 2.0.9
|
||||
|
||||
0.11.3 / Sep 02 2015
|
||||
====================
|
||||
* nan1 to nan2 migration for iojs v3
|
||||
* documented configuration on edison arduino base board
|
||||
* documented configuration on the pi
|
||||
|
||||
0.11.2 / May 07 2015
|
||||
====================
|
||||
* io.js v2.0.0+ compatibility [#7](https://github.com/fivdi/i2c-bus/issues/7)
|
||||
|
||||
0.11.1 / Mar 28 2015
|
||||
====================
|
||||
|
||||
* Simplify concurrent asynchronous access to multiple devices [#4](https://github.com/fivdi/i2c-bus/issues/4)
|
||||
* nan 1.7.0
|
||||
|
||||
0.11.0 / Feb 01 2015
|
||||
====================
|
||||
|
||||
* added writeBlock and writeBlockSync - UNTESTED and undocumented due to lack of supporting hardware
|
||||
* added readBlock and readBlockSync - UNTESTED and undocumented due to lack of supporting hardware
|
||||
|
||||
0.10.0 / Jan 24 2015
|
||||
====================
|
||||
|
||||
* added async example
|
||||
* strerror replaced with strerror_r
|
||||
* nan 1.5.3
|
||||
* added async access to multiple devices concurrently example
|
||||
|
||||
0.9.0 / Dec 22 2014
|
||||
===================
|
||||
|
||||
* callback for writeI2cBlock now gets 3 arguments (err, bytesWritten, buffer)
|
||||
* added writeQuick and writeQuickSync
|
||||
* added example i2cquickscan to scan a bus for devices like 'i2cdetect -y -q 1'
|
||||
* fixed i2cscan example on the pi
|
||||
|
||||
0.8.0 / Dec 19 2014
|
||||
===================
|
||||
|
||||
* added a plain i2c performance test
|
||||
* added i2cFuncs and i2cFuncsSync
|
||||
* added an example that does the same as command 'i2cdetect -F 1'
|
||||
* renamed readBytes to readI2cBlock
|
||||
* renamed readBytesSync to readI2cBlockSync
|
||||
* renamed writeBytes to writeI2cBlock
|
||||
* renamed writeBytesSync to writeI2cBlockSync
|
||||
* added an example that scans a bus for devices like 'i2cdetect -y -r 1'
|
||||
|
||||
0.7.0 / Dec 16 2014
|
||||
===================
|
||||
|
||||
* faster compile
|
||||
* added plain i2cRead, i2cReadSync, i2cWrite, and i2cWriteSync methods
|
||||
|
||||
0.6.0 / Dec 15 2014
|
||||
===================
|
||||
|
||||
* use __u8, __u16, and __s32 where appropriate
|
||||
* added brute force memory leak tests
|
||||
* added performance tests
|
||||
* added an example using two devices on the same bus
|
||||
* renamed all public api methods
|
||||
|
||||
0.5.0 / Dec 14 2014
|
||||
===================
|
||||
|
||||
* added block operations
|
||||
|
||||
0.4.0 / Dec 13 2014
|
||||
===================
|
||||
|
||||
* check for valid arguments in addon methods
|
||||
* added sync and async tests
|
||||
|
||||
0.3.0 / Dec 13 2014
|
||||
===================
|
||||
|
||||
* improved example
|
||||
|
||||
0.2.0 / Dec 13 2014
|
||||
===================
|
||||
|
||||
* corrected initial release date
|
||||
* use callbacks rather than events for asychronous open method
|
||||
* documentation
|
||||
* return this in synchronous write methods
|
||||
* added close and closeSync methods
|
||||
* added example
|
||||
|
||||
0.1.0 / Dec 09 2014
|
||||
===================
|
||||
|
||||
* initial release
|
||||
|
||||
20
node_modules/i2c-bus/LICENSE
generated
vendored
Normal file
20
node_modules/i2c-bus/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 fivdi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
796
node_modules/i2c-bus/README.md
generated
vendored
Normal file
796
node_modules/i2c-bus/README.md
generated
vendored
Normal file
@@ -0,0 +1,796 @@
|
||||
[](https://app.travis-ci.com/github/fivdi/i2c-bus)
|
||||
[](https://coveralls.io/github/fivdi/i2c-bus)
|
||||
[](https://www.npmjs.com/package/i2c-bus)
|
||||
[](https://www.npmjs.com/package/i2c-bus)
|
||||
[](https://github.com/sindresorhus/awesome-nodejs#hardware)
|
||||
|
||||
# i2c-bus
|
||||
|
||||
I2C serial bus access with **Node.js** on Linux boards like the Raspberry Pi
|
||||
or BeagleBone. The i2c-bus API supports promises and async/await, asynchronous
|
||||
callbacks and synchronous execution.
|
||||
|
||||
i2c-bus supports Node.js versions 10, 12, 14, 16, 18 and 20.
|
||||
|
||||
## Contents
|
||||
|
||||
* [Installation](#installation)
|
||||
* [Usage](#usage)
|
||||
* [API](#api)
|
||||
* [TypeScript Type Definitions](#typescript-type-definitions)
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install i2c-bus
|
||||
```
|
||||
|
||||
The way in which I2C is configured varies from board to board. Sometimes no
|
||||
configuraton is required, but sometimes it is:
|
||||
|
||||
* [Configuring I2C on the Raspberry Pi](doc/raspberry-pi-i2c.md)
|
||||
* [Configuring Software I2C on the Raspberry Pi](doc/raspberry-pi-software-i2c.md)
|
||||
* Consider software I2C when there are issues communicating with a device on a Raspberry Pi
|
||||
|
||||
## Usage
|
||||
|
||||
The example programs below show how to use a
|
||||
[MCP9808 I2C temperature sensor](https://www.adafruit.com/product/1782)
|
||||
to determine the temperature.
|
||||
|
||||
**MCP9808 I2C temperature sensor connected to a Raspberry Pi**
|
||||

|
||||
|
||||
### Example 1 - Promises
|
||||
|
||||
Determine the temperature with a MCP9808 I2C temperature sensor using
|
||||
promises.
|
||||
|
||||
```js
|
||||
const i2c = require('i2c-bus');
|
||||
|
||||
const MCP9808_ADDR = 0x18;
|
||||
const TEMP_REG = 0x05;
|
||||
|
||||
const toCelsius = rawData => {
|
||||
rawData = (rawData >> 8) + ((rawData & 0xff) << 8);
|
||||
let celsius = (rawData & 0x0fff) / 16;
|
||||
if (rawData & 0x1000) {
|
||||
celsius -= 256;
|
||||
}
|
||||
return celsius;
|
||||
};
|
||||
|
||||
i2c.openPromisified(1).
|
||||
then(i2c1 => i2c1.readWord(MCP9808_ADDR, TEMP_REG).
|
||||
then(rawData => console.log(toCelsius(rawData))).
|
||||
then(_ => i2c1.close())
|
||||
).catch(console.log);
|
||||
```
|
||||
|
||||
### Example 2 - Promises, Plain I2C and Buffers
|
||||
|
||||
Determine the temperature with a MCP9808 I2C temperature sensor using
|
||||
promises, plain I2C and Buffer objects.
|
||||
|
||||
```js
|
||||
const i2c = require('i2c-bus');
|
||||
|
||||
const MCP9808_ADDR = 0x18;
|
||||
const TEMP_REG = 0x05;
|
||||
|
||||
const toCelsius = rawData => {
|
||||
let celsius = (rawData & 0x0fff) / 16;
|
||||
if (rawData & 0x1000) {
|
||||
celsius -= 256;
|
||||
}
|
||||
return celsius;
|
||||
};
|
||||
|
||||
const wbuf = Buffer.from([TEMP_REG]);
|
||||
const rbuf = Buffer.alloc(2);
|
||||
|
||||
i2c.openPromisified(1).
|
||||
then(i2c1 => i2c1.i2cWrite(MCP9808_ADDR, wbuf.length, wbuf).
|
||||
then(_ => i2c1.i2cRead(MCP9808_ADDR, rbuf.length, rbuf)).
|
||||
then(data => console.log(toCelsius(data.buffer.readUInt16BE()))).
|
||||
then(_ => i2c1.close())
|
||||
).catch(console.log);
|
||||
```
|
||||
|
||||
### Example 3 - Asynchronous Callbacks
|
||||
|
||||
Determine the temperature with a MCP9808 I2C temperature sensor using
|
||||
asynchronous callbacks.
|
||||
|
||||
```js
|
||||
const i2c = require('i2c-bus');
|
||||
|
||||
const MCP9808_ADDR = 0x18;
|
||||
const TEMP_REG = 0x05;
|
||||
|
||||
const toCelsius = rawData => {
|
||||
rawData = (rawData >> 8) + ((rawData & 0xff) << 8);
|
||||
let celsius = (rawData & 0x0fff) / 16;
|
||||
if (rawData & 0x1000) {
|
||||
celsius -= 256;
|
||||
}
|
||||
return celsius;
|
||||
};
|
||||
|
||||
const i2c1 = i2c.open(1, err => {
|
||||
if (err) throw err;
|
||||
|
||||
i2c1.readWord(MCP9808_ADDR, TEMP_REG, (err, rawData) => {
|
||||
if (err) throw err;
|
||||
|
||||
console.log(toCelsius(rawData));
|
||||
|
||||
i2c1.close(err => {
|
||||
if (err) throw err;
|
||||
});
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### Example 4 - Synchronous Methods
|
||||
|
||||
Determine the temperature with a MCP9808 I2C temperature sensor using
|
||||
synchronous methods.
|
||||
|
||||
```js
|
||||
const i2c = require('i2c-bus');
|
||||
|
||||
const MCP9808_ADDR = 0x18;
|
||||
const TEMP_REG = 0x05;
|
||||
|
||||
const toCelsius = rawData => {
|
||||
rawData = (rawData >> 8) + ((rawData & 0xff) << 8);
|
||||
let celsius = (rawData & 0x0fff) / 16;
|
||||
if (rawData & 0x1000) {
|
||||
celsius -= 256;
|
||||
}
|
||||
return celsius;
|
||||
};
|
||||
|
||||
const i2c1 = i2c.openSync(1);
|
||||
const rawData = i2c1.readWordSync(MCP9808_ADDR, TEMP_REG);
|
||||
console.log(toCelsius(rawData));
|
||||
i2c1.closeSync();
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
* [Functions](#functions)
|
||||
* [Class Bus](#class-bus)
|
||||
* [Class PromisifiedBus](#class-promisifiedbus)
|
||||
* [Class I2cFuncs](#class-i2cfuncs)
|
||||
|
||||
### Functions
|
||||
|
||||
- [open(busNumber [, options], cb)](#openbusnumber--options-cb)
|
||||
- [openSync(busNumber [, options])](#opensyncbusnumber--options)
|
||||
- [openPromisified(busNumber [, options])](#openpromisifiedbusnumber--options)
|
||||
|
||||
### Class Bus
|
||||
|
||||
All methods in class Bus have asynchronous callback and synchronous forms. For
|
||||
promise support see [class PromisifiedBus](#class-promisifiedbus).
|
||||
|
||||
The asynchronous callback form always take a completion callback as its last
|
||||
argument. The arguments passed to the completion callback depend on the
|
||||
method, but the first argument is always reserved for an exception. If the
|
||||
operation was completed successfully, then the first argument will be null or
|
||||
undefined.
|
||||
|
||||
When using the synchronous form any exceptions are immediately thrown. You can
|
||||
use try/catch to handle exceptions or allow them to bubble up.
|
||||
|
||||
- Free resources
|
||||
- [bus.close(cb)](#busclosecb)
|
||||
- [bus.closeSync()](#busclosesync)
|
||||
|
||||
- Information
|
||||
- [bus.i2cFuncs(cb)](#busi2cfuncscb)
|
||||
- [bus.i2cFuncsSync()](#busi2cfuncssync)
|
||||
- [bus.scan([startAddr,] [endAddr,] cb)](#busscanstartaddr-endaddr-cb)
|
||||
- [bus.scanSync([startAddr,] [endAddr])](#busscansyncstartaddr-endaddr)
|
||||
- [bus.deviceId(addr, cb)](#busdeviceidaddr-cb)
|
||||
- [bus.deviceIdSync(addr)](#busdeviceidsyncaddr)
|
||||
|
||||
- Plain I2C
|
||||
- [bus.i2cRead(addr, length, buffer, cb)](#busi2creadaddr-length-buffer-cb)
|
||||
- [bus.i2cReadSync(addr, length, buffer)](#busi2creadsyncaddr-length-buffer)
|
||||
- [bus.i2cWrite(addr, length, buffer, cb)](#busi2cwriteaddr-length-buffer-cb)
|
||||
- [bus.i2cWriteSync(addr, length, buffer)](#busi2cwritesyncaddr-length-buffer)
|
||||
|
||||
- SMBus
|
||||
- [bus.readByte(addr, cmd, cb)](#busreadbyteaddr-cmd-cb)
|
||||
- [bus.readByteSync(addr, cmd)](#busreadbytesyncaddr-cmd)
|
||||
- [bus.readWord(addr, cmd, cb)](#busreadwordaddr-cmd-cb)
|
||||
- [bus.readWordSync(addr, cmd)](#busreadwordsyncaddr-cmd)
|
||||
- [bus.readI2cBlock(addr, cmd, length, buffer, cb)](#busreadi2cblockaddr-cmd-length-buffer-cb)
|
||||
- [bus.readI2cBlockSync(addr, cmd, length, buffer)](#busreadi2cblocksyncaddr-cmd-length-buffer)
|
||||
- [bus.receiveByte(addr, cb)](#busreceivebyteaddr-cb)
|
||||
- [bus.receiveByteSync(addr)](#busreceivebytesyncaddr)
|
||||
- [bus.sendByte(addr, byte, cb)](#bussendbyteaddr-byte-cb)
|
||||
- [bus.sendByteSync(addr, byte)](#bussendbytesyncaddr-byte)
|
||||
- [bus.writeByte(addr, cmd, byte, cb)](#buswritebyteaddr-cmd-byte-cb)
|
||||
- [bus.writeByteSync(addr, cmd, byte)](#buswritebytesyncaddr-cmd-byte)
|
||||
- [bus.writeWord(addr, cmd, word, cb)](#buswritewordaddr-cmd-word-cb)
|
||||
- [bus.writeWordSync(addr, cmd, word)](#buswritewordsyncaddr-cmd-word)
|
||||
- [bus.writeQuick(addr, bit, cb)](#buswritequickaddr-bit-cb)
|
||||
- [bus.writeQuickSync(addr, bit)](#buswritequicksyncaddr-bit)
|
||||
- [bus.writeI2cBlock(addr, cmd, length, buffer, cb)](#buswritei2cblockaddr-cmd-length-buffer-cb)
|
||||
- [bus.writeI2cBlockSync(addr, cmd, length, buffer)](#buswritei2cblocksyncaddr-cmd-length-buffer)
|
||||
|
||||
- Promises
|
||||
- [bus.promisifiedBus()](#buspromisifiedbus)
|
||||
|
||||
### Class PromisifiedBus
|
||||
|
||||
All methods in class PromisifiedBus have the asynchronous promise form. For
|
||||
asynchronous callback and synchronous forms see [class Bus](#class-bus).
|
||||
|
||||
- Free resources
|
||||
- [promisifiedBus.close()](#promisifiedbusclose)
|
||||
|
||||
- Information
|
||||
- [promisifiedBus.i2cFuncs()](#promisifiedbusi2cfuncs)
|
||||
- [promisifiedBus.scan([startAddr,] [endAddr])](#promisifiedbusscanstartaddr-endaddr)
|
||||
- [promisifiedBus.deviceId(addr)](#promisifiedbusdeviceidaddr)
|
||||
|
||||
- Plain I2C
|
||||
- [promisifiedBus.i2cRead(addr, length, buffer)](#promisifiedbusi2creadaddr-length-buffer)
|
||||
- [promisifiedBus.i2cWrite(addr, length, buffer)](#promisifiedbusi2cwriteaddr-length-buffer)
|
||||
|
||||
- SMBus
|
||||
- [promisifiedBus.readByte(addr, cmd)](#promisifiedbusreadbyteaddr-cmd)
|
||||
- [promisifiedBus.readWord(addr, cmd)](#promisifiedbusreadwordaddr-cmd)
|
||||
- [promisifiedBus.readI2cBlock(addr, cmd, length, buffer)](#promisifiedbusreadi2cblockaddr-cmd-length-buffer)
|
||||
- [promisifiedBus.receiveByte(addr)](#promisifiedbusreceivebyteaddr)
|
||||
- [promisifiedBus.sendByte(addr, byte)](#promisifiedbussendbyteaddr-byte)
|
||||
- [promisifiedBus.writeByte(addr, cmd, byte)](#promisifiedbuswritebyteaddr-cmd-byte)
|
||||
- [promisifiedBus.writeWord(addr, cmd, word)](#promisifiedbuswritewordaddr-cmd-word)
|
||||
- [promisifiedBus.writeQuick(addr, bit)](#promisifiedbuswritequickaddr-bit)
|
||||
- [promisifiedBus.writeI2cBlock(addr, cmd, length, buffer)](#promisifiedbuswritei2cblockaddr-cmd-length-buffer)
|
||||
|
||||
- Asynchronous callbacks and synchronous execution
|
||||
- [promisifiedBus.bus()](#promisifiedbusbus)
|
||||
|
||||
### Class I2cFuncs
|
||||
|
||||
- [funcs.i2c](#funcsi2c---boolean)
|
||||
- [funcs.tenBitAddr](#funcstenbitaddr---boolean)
|
||||
- [funcs.protocolMangling](#funcsprotocolmangling---boolean)
|
||||
- [funcs.smbusPec](#funcssmbuspec---boolean)
|
||||
- [funcs.smbusBlockProcCall](#funcssmbusblockproccall---boolean)
|
||||
- [funcs.smbusQuick](#funcssmbusquick---boolean)
|
||||
- [funcs.smbusReceiveByte](#funcssmbusreceivebyte---boolean)
|
||||
- [funcs.smbusSendByte](#funcssmbussendbyte---boolean)
|
||||
- [funcs.smbusReadByte](#funcssmbusreadbyte---boolean)
|
||||
- [funcs.smbusWriteByte](#funcssmbuswritebyte---boolean)
|
||||
- [funcs.smbusReadWord](#funcssmbusreadword---boolean)
|
||||
- [funcs.smbusWriteWord](#funcssmbuswriteword---boolean)
|
||||
- [funcs.smbusProcCall](#funcssmbusproccall---boolean)
|
||||
- [funcs.smbusReadBlock](#funcssmbusreadblock---boolean)
|
||||
- [funcs.smbusWriteBlock](#funcssmbuswriteblock---boolean)
|
||||
- [funcs.smbusReadI2cBlock](#funcssmbusreadi2cblock---boolean)
|
||||
- [funcs.smbusWriteI2cBlock](#funcssmbuswritei2cblock---boolean)
|
||||
|
||||
### 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
|
||||
|
||||
Asynchronous open. Returns a new Bus object. The callback gets one argument (err).
|
||||
|
||||
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 kernel
|
||||
driver/module. Corresponds to I2C_SLAVE_FORCE on Linux. 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 kernel
|
||||
driver/module. Corresponds to I2C_SLAVE_FORCE on Linux. The valid values for
|
||||
forceAccess are true and false. Optional, the default value is false.
|
||||
|
||||
### openPromisified(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
|
||||
|
||||
Asynchronous open. Returns a Promise that, when resolved, yields a PromisifiedBus 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 kernel
|
||||
driver/module. Corresponds to I2C_SLAVE_FORCE on Linux. The valid values for
|
||||
forceAccess are true and false. Optional, the default value is false.
|
||||
|
||||
### bus.close(cb)
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous close. Frees system resources used by this instance. The callback
|
||||
gets one argument (err).
|
||||
|
||||
### bus.closeSync()
|
||||
|
||||
Synchronous close. Frees system resources used by this instance.
|
||||
|
||||
### bus.i2cFuncs(cb)
|
||||
- cb - completion callback
|
||||
|
||||
Determine functionality of the bus/adapter asynchronously. The callback gets
|
||||
two argument (err, funcs). funcs is a frozen
|
||||
[I2cFuncs](#class-i2cfuncs)
|
||||
object describing the functionality available.
|
||||
See also [I2C functionality](https://www.kernel.org/doc/Documentation/i2c/functionality).
|
||||
|
||||
### bus.i2cFuncsSync()
|
||||
|
||||
Determine functionality of the bus/adapter Synchronously. Returns a frozen
|
||||
[I2cFuncs](#class-i2cfuncs)
|
||||
object describing the functionality available.
|
||||
See also [I2C functionality](https://www.kernel.org/doc/Documentation/i2c/functionality).
|
||||
|
||||
### bus.scan([startAddr,] [endAddr,] cb)
|
||||
- startAddr - an integer specifying the start address of the scan range, optional
|
||||
- endAddr - an integer specifying the end addrerss of the scan range, optional
|
||||
- cb - completion callback
|
||||
|
||||
bus.scan(cb) - scan for I2C devices in address range 0x03 through 0x77 <br/>
|
||||
bus.scan(addr, cb) - scan for an I2C device at address addr <br/>
|
||||
bus.scan(startAddr, endAddr, cb) - scan for I2C devices in address range startAddr through endAddr <br/>
|
||||
|
||||
Scans the I2C bus asynchronously for devices. The default address range 0x03
|
||||
through 0x77 is the same as the default address range used by the `i2cdetect`
|
||||
command line tool. The callback gets two arguments (err, devices). devices is
|
||||
an array of numbers where each number represents the I2C address of a device
|
||||
which was detected.
|
||||
|
||||
### bus.scanSync([startAddr,] [endAddr])
|
||||
- startAddr - an integer specifying the start address of the scan range, optional
|
||||
- endAddr - an integer specifying the end addrerss of the scan range, optional
|
||||
|
||||
bus.scan() - scan for I2C devices in address range 0x03 through 0x77 <br/>
|
||||
bus.scan(addr) - scan for an I2C device at address addr <br/>
|
||||
bus.scan(startAddr, endAddr) - scan for I2C devices in address range startAddr through endAddr <br/>
|
||||
|
||||
Scans the I2C bus synchronously for devices. The default address range 0x03
|
||||
through 0x77 is the same as the default address range used by the `i2cdetect`
|
||||
command line tool. Returns an array of numbers where each number represents
|
||||
the I2C address of a device which was detected.
|
||||
|
||||
### bus.deviceId(addr, cb)
|
||||
- addr - I2C device address
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous I2C device Id. The callback gets two arguments (err, id). id is
|
||||
an object with the properties `manufacturer`, `product` and if known a human
|
||||
readable `name` for the associated manufacturer. `manufacturer` and `product`
|
||||
are numbers, `name` is a string.
|
||||
|
||||
### bus.deviceIdSync(addr)
|
||||
- addr - I2C device address
|
||||
|
||||
Synchronous I2C device Id. Returns an object with the properties
|
||||
`manufacturer`, `product` and if known a human readable `name` for the
|
||||
associated manufacturer. `manufacturer` and `product` are numbers, `name` is a
|
||||
string.
|
||||
|
||||
### bus.i2cRead(addr, length, buffer, cb)
|
||||
- addr - I2C device address
|
||||
- length - an integer specifying the number of bytes to read
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance that the data will be written to (must conatin at least length bytes)
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous plain I2C read. The callback gets three argument (err, bytesRead, buffer).
|
||||
bytesRead is the number of bytes read.
|
||||
|
||||
### bus.i2cReadSync(addr, length, buffer)
|
||||
- addr - I2C device address
|
||||
- length - an integer specifying the number of bytes to read
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance that the data will be written to (must conatin at least length bytes)
|
||||
|
||||
Synchronous plain I2C read. Returns the number of bytes read.
|
||||
|
||||
### bus.i2cWrite(addr, length, buffer, cb)
|
||||
- addr - I2C device address
|
||||
- length - an integer specifying the number of bytes to write
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance containing the data to write (must conatin at least length bytes)
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous plain I2C write. The callback gets three argument (err, bytesWritten, buffer).
|
||||
bytesWritten is the number of bytes written.
|
||||
|
||||
### bus.i2cWriteSync(addr, length, buffer)
|
||||
- addr - I2C device address
|
||||
- length - an integer specifying the number of bytes to write
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html) instance
|
||||
containing the data to write (must conatin at least length bytes)
|
||||
|
||||
Synchronous plain I2C write. Returns the number of bytes written.
|
||||
|
||||
### bus.readByte(addr, cmd, cb)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous SMBus read byte. The callback gets two arguments (err, byte).
|
||||
byte is an unsigned integer in the range 0 to 255.
|
||||
|
||||
### bus.readByteSync(addr, cmd)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
|
||||
Synchronous SMBus read byte. Returns the byte read. byte is an unsigned
|
||||
integer in the range 0 to 255.
|
||||
|
||||
### bus.readWord(addr, cmd, cb)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous SMBus read word. The callback gets two arguments (err, word).
|
||||
word is an unsigned integer in the range 0 to 65535.
|
||||
|
||||
### bus.readWordSync(addr, cmd)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
|
||||
Synchronous SMBus read word. Returns the word read. word is an unsigned
|
||||
integer in the range 0 to 65535.
|
||||
|
||||
### bus.readI2cBlock(addr, cmd, length, buffer, cb)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- length - an integer specifying the number of bytes to read (max 32)
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance that the data will be written to (must conatin at least length bytes)
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous I2C block read (not defined by the SMBus specification). Reads a
|
||||
block of bytes from a device, from a designated register that is specified by
|
||||
cmd. The callback gets three arguments (err, bytesRead, buffer). bytesRead is
|
||||
the number of bytes read.
|
||||
|
||||
### bus.readI2cBlockSync(addr, cmd, length, buffer)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- length - an integer specifying the number of bytes to read (max 32)
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance that the data will be written to (must conatin at least length bytes)
|
||||
|
||||
Synchronous I2C block read (not defined by the SMBus specification). Reads a
|
||||
block of bytes from a device, from a designated register that is specified by
|
||||
cmd. Returns the number of bytes read.
|
||||
|
||||
### bus.receiveByte(addr, cb)
|
||||
- addr - I2C device address
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous SMBus receive byte. The callback gets two arguments (err, byte).
|
||||
byte is an unsigned integer in the range 0 to 255.
|
||||
|
||||
### bus.receiveByteSync(addr)
|
||||
- addr - I2C device address
|
||||
|
||||
Synchronous SMBus receive byte. Returns the byte received. byte is an unsigned
|
||||
integer in the range 0 to 255.
|
||||
|
||||
### bus.sendByte(addr, byte, cb)
|
||||
- addr - I2C device address
|
||||
- byte - data byte. byte is an unsigned integer in the range 0 to 255.
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous SMBus send byte. The callback gets one argument (err).
|
||||
|
||||
### bus.sendByteSync(addr, byte)
|
||||
- addr - I2C device address
|
||||
- byte - data byte. byte is an unsigned integer in the range 0 to 255.
|
||||
|
||||
Synchronous SMBus send byte.
|
||||
|
||||
### bus.writeByte(addr, cmd, byte, cb)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- byte - data byte. byte is an unsigned integer in the range 0 to 255.
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous SMBus write byte. The callback gets one argument (err).
|
||||
|
||||
### bus.writeByteSync(addr, cmd, byte)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- byte - data byte. byte is an unsigned integer in the range 0 to 255.
|
||||
|
||||
Synchronous SMBus write byte.
|
||||
|
||||
### bus.writeWord(addr, cmd, word, cb)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- word - data word. word is an unsigned integer in the range 0 to 65535.
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous SMBus write word. The callback gets one argument (err).
|
||||
|
||||
### bus.writeWordSync(addr, cmd, word)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- word - data word. word is an unsigned integer in the range 0 to 65535.
|
||||
|
||||
Synchronous SMBus write word.
|
||||
|
||||
### bus.writeQuick(addr, bit, cb)
|
||||
- addr - I2C device address
|
||||
- bit - bit to write (0 or 1)
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous SMBus quick command. Writes a single bit to the device.
|
||||
The callback gets one argument (err).
|
||||
|
||||
### bus.writeQuickSync(addr, bit)
|
||||
- addr - I2C device address
|
||||
- bit - bit to write (0 or 1)
|
||||
|
||||
Synchronous SMBus quick command. Writes a single bit to the device.
|
||||
|
||||
### bus.writeI2cBlock(addr, cmd, length, buffer, cb)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- length - an integer specifying the number of bytes to write (max 32)
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance containing the data to write (must conatin at least length bytes)
|
||||
- cb - completion callback
|
||||
|
||||
Asynchronous I2C block write (not defined by the SMBus specification). Writes a
|
||||
block of bytes to a device, to a designated register that is specified by cmd.
|
||||
The callback gets three argument (err, bytesWritten, buffer). bytesWritten is
|
||||
the number of bytes written.
|
||||
|
||||
### bus.writeI2cBlockSync(addr, cmd, length, buffer)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- length - an integer specifying the number of bytes to write (max 32)
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance containing the data to write (must conatin at least length bytes)
|
||||
|
||||
Synchronous I2C block write (not defined by the SMBus specification). Writes a
|
||||
block of bytes to a device, to a designated register that is specified by cmd.
|
||||
|
||||
### bus.promisifiedBus()
|
||||
Return the PromisifiedBus instance for this Bus instance.
|
||||
|
||||
### promisifiedBus.close()
|
||||
|
||||
Asynchronous close. Returns a Promise that will be resolved with no arguments
|
||||
once the underlying resources have been released, or will be rejected if an
|
||||
error occurs while closing.
|
||||
|
||||
### promisifiedBus.i2cFuncs()
|
||||
|
||||
Determine functionality of the bus/adapter asynchronously. Returns a Promise
|
||||
that on success will be resolved with a frozen [I2cFuncs](#class-i2cfuncs)
|
||||
object describing the functionality available. The returned Promise will be
|
||||
rejected if an error occurs.
|
||||
See also [I2C functionality](https://www.kernel.org/doc/Documentation/i2c/functionality).
|
||||
|
||||
### promisifiedBus.scan([startAddr,] [endAddr])
|
||||
- startAddr - an integer specifying the start address of the scan range, optional
|
||||
- endAddr - an integer specifying the end addrerss of the scan range, optional
|
||||
|
||||
bus.scan() - scan for I2C devices in address range 0x03 through 0x77 <br/>
|
||||
bus.scan(addr) - scan for an I2C device at address addr <br/>
|
||||
bus.scan(startAddr, endAddr) - scan for I2C devices in address range startAddr through endAddr <br/>
|
||||
|
||||
Scans the I2C bus asynchronously for devices. The default address range 0x03
|
||||
through 0x77 is the same as the default address range used by the `i2cdetect`
|
||||
command line tool. Returns a Promise that on success will be resolved with an
|
||||
array of numbers where each number represents the I2C address of a device
|
||||
which was detected. The returned Promise will be rejected if an error occurs.
|
||||
|
||||
### promisifiedBus.deviceId(addr)
|
||||
- addr - I2C device address
|
||||
|
||||
Asynchronous I2C device Id. Returns a Promise that will be resolved with an id
|
||||
object on success, or will be rejected if an error occurs. id is an object
|
||||
with the properties `manufacturer`, `product` and if known a human readable
|
||||
`name` for the associated manufacturer. `manufacturer` and `product` are
|
||||
numbers, `name` is a string.
|
||||
|
||||
### promisifiedBus.i2cRead(addr, length, buffer)
|
||||
- addr - I2C device address
|
||||
- length - an integer specifying the number of bytes to read
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance that the data will be written to (must conatin at least length bytes)
|
||||
|
||||
Asynchronous plain I2C read. Returns a Promise that on success will be
|
||||
resolved with an object with a bytesRead property identifying the number of
|
||||
bytes read, and a buffer property that is a reference to the passed in buffer
|
||||
argument. The returned Promise will be rejected if an error occurs.
|
||||
|
||||
### promisifiedBus.i2cWrite(addr, length, buffer)
|
||||
- addr - I2C device address
|
||||
- length - an integer specifying the number of bytes to write
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance containing the data to write (must conatin at least length bytes)
|
||||
|
||||
Asynchronous plain I2C write. Returns a Promise that on success will be
|
||||
resolved with an object with a bytesWritten property identifying the number of
|
||||
bytes written, and a buffer property that is a reference to the passed in
|
||||
buffer argument. The returned promise will be rejected if an error occurs.
|
||||
|
||||
### promisifiedBus.readByte(addr, cmd)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
|
||||
Asynchronous SMBus read byte. Returns a Promise that will be resolved with a
|
||||
number representing the byte read on success, or will be rejected if an error
|
||||
occurs. byte is an unsigned integer in the range 0 to 255.
|
||||
|
||||
### promisifiedBus.readWord(addr, cmd)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
|
||||
Asynchronous SMBus read word. Returns a Promise that will be resolved with a
|
||||
number representing the word read on success, or will be rejected if an error
|
||||
occurs. word is an unsigned integer in the range 0 to 65535.
|
||||
|
||||
### promisifiedBus.readI2cBlock(addr, cmd, length, buffer)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- length - an integer specifying the number of bytes to read (max 32)
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance that the data will be written to (must conatin at least length bytes)
|
||||
|
||||
Asynchronous I2C block read (not defined by the SMBus specification). Reads a
|
||||
block of bytes from a device, from a designated register that is specified by
|
||||
cmd. Returns a Promise that on success will be resolved with an object with a
|
||||
bytesRead property identifying the number of bytes read, and a buffer property
|
||||
that is a reference to the passed in buffer argument. The returned Promise
|
||||
will be rejected if an error occurs.
|
||||
|
||||
### promisifiedBus.receiveByte(addr)
|
||||
- addr - I2C device address
|
||||
|
||||
Asynchronous SMBus receive byte. Returns a Promise that will be resolved with
|
||||
a number representing the byte received on success, or will be rejected if an
|
||||
error occurs. byte is an unsigned integer in the range 0 to 255.
|
||||
|
||||
### promisifiedBus.sendByte(addr, byte)
|
||||
- addr - I2C device address
|
||||
- byte - data byte. byte is an unsigned integer in the range 0 to 255.
|
||||
|
||||
Asynchronous SMBus send byte. Returns a Promise that will be resolved with no
|
||||
arguments on success, or will be rejected if an error occurs.
|
||||
|
||||
### promisifiedBus.writeByte(addr, cmd, byte)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- byte - data byte. byte is an unsigned integer in the range 0 to 255.
|
||||
|
||||
Asynchronous SMBus write byte. Returns a Promise that will be resolved with no
|
||||
arguments on success, or will be rejected if an error occurs.
|
||||
|
||||
### promisifiedBus.writeWord(addr, cmd, word)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- word - data word. word is an unsigned integer in the range 0 to 65535.
|
||||
|
||||
Asynchronous SMBus write word. Returns a Promise that will be resolved with no
|
||||
arguments on success, or will be rejected if an error occurs.
|
||||
|
||||
### promisifiedBus.writeQuick(addr, bit)
|
||||
- addr - I2C device address
|
||||
- bit - bit to write (0 or 1)
|
||||
|
||||
Asynchronous SMBus quick command. Writes a single bit to the device. Returns a
|
||||
Promise that will be resolved with no arguments on success, or will be
|
||||
rejected if an error occurs.
|
||||
|
||||
### promisifiedBus.writeI2cBlock(addr, cmd, length, buffer)
|
||||
- addr - I2C device address
|
||||
- cmd - command code
|
||||
- length - an integer specifying the number of bytes to write (max 32)
|
||||
- buffer - the [Buffer](https://nodejs.org/dist/latest/docs/api/buffer.html)
|
||||
instance containing the data to write (must conatin at least length bytes)
|
||||
|
||||
Asynchronous I2C block write (not defined by the SMBus specification). Writes a
|
||||
block of bytes to a device, to a designated register that is specified by cmd.
|
||||
Returns a Promise that on success will be resolved with an object with a
|
||||
bytesWritten property identifying the number of bytes written, and a buffer
|
||||
property that is a reference to the passed in buffer argument. The returned
|
||||
promise will be rejected if an error occurs.
|
||||
|
||||
### promisifiedBus.bus()
|
||||
Return the Bus instance for this PromisifiedBus instance.
|
||||
|
||||
### funcs.i2c - boolean
|
||||
Specifies whether or not the adapter handles plain I2C-level commands (Pure
|
||||
SMBus adapters typically can not do these,
|
||||
I2C_FUNC_I2C).
|
||||
|
||||
### funcs.tenBitAddr - boolean
|
||||
Specifies whether or not the adapter handles the 10-bit address extensions
|
||||
(I2C_FUNC_10BIT_ADDR).
|
||||
|
||||
### funcs.protocolMangling - boolean
|
||||
Specifies whether or not the adapter knows about the I2C_M_IGNORE_NAK,
|
||||
I2C_M_REV_DIR_ADDR and I2C_M_NO_RD_ACK flags (which modify the I2C protocol!
|
||||
I2C_FUNC_PROTOCOL_MANGLING).
|
||||
|
||||
### funcs.smbusPec - boolean
|
||||
Specifies whether or not the adapter handles packet error checking
|
||||
(I2C_FUNC_SMBUS_PEC).
|
||||
|
||||
### funcs.smbusBlockProcCall - boolean
|
||||
Specifies whether or not the adapter handles the SMBus block process call
|
||||
command
|
||||
(I2C_FUNC_SMBUS_BLOCK_PROC_CALL).
|
||||
|
||||
### funcs.smbusQuick - boolean
|
||||
Specifies whether or not the adapter handles the SMBus quick command
|
||||
(I2C_FUNC_SMBUS_QUICK).
|
||||
|
||||
### funcs.smbusReceiveByte - boolean
|
||||
Specifies whether or not the adapter handles the SMBus receive byte command
|
||||
(I2C_FUNC_SMBUS_READ_BYTE).
|
||||
|
||||
### funcs.smbusSendByte - boolean
|
||||
Specifies whether or not the adapter handles the SMBus send byte command
|
||||
(I2C_FUNC_SMBUS_WRITE_BYTE).
|
||||
|
||||
### funcs.smbusReadByte - boolean
|
||||
Specifies whether or not the adapter handles the SMBus read byte command
|
||||
(I2C_FUNC_SMBUS_READ_BYTE_DATA).
|
||||
|
||||
### funcs.smbusWriteByte - boolean
|
||||
Specifies whether or not the adapter handles the SMBus write byte command
|
||||
(I2C_FUNC_SMBUS_WRITE_BYTE_DATA).
|
||||
|
||||
### funcs.smbusReadWord - boolean
|
||||
Specifies whether or not the adapter handles the SMBus read word command
|
||||
(I2C_FUNC_SMBUS_READ_WORD_DATA).
|
||||
|
||||
### funcs.smbusWriteWord - boolean
|
||||
Specifies whether or not the adapter handles the SMBus write word command
|
||||
(I2C_FUNC_SMBUS_WRITE_WORD_DATA).
|
||||
|
||||
### funcs.smbusProcCall - boolean
|
||||
Specifies whether or not the adapter handles the SMBus process call command
|
||||
(I2C_FUNC_SMBUS_PROC_CALL).
|
||||
|
||||
### funcs.smbusReadBlock - boolean
|
||||
Specifies whether or not the adapter handles the SMBus read block command
|
||||
(I2C_FUNC_SMBUS_READ_BLOCK_DATA).
|
||||
|
||||
### funcs.smbusWriteBlock - boolean
|
||||
Specifies whether or not the adapter handles the SMBus write block command
|
||||
(I2C_FUNC_SMBUS_WRITE_BLOCK_DATA).
|
||||
|
||||
### funcs.smbusReadI2cBlock - boolean
|
||||
Specifies whether or not the adapter handles the SMBus read I2C block command
|
||||
(I2C_FUNC_SMBUS_READ_I2C_BLOCK).
|
||||
|
||||
### funcs.smbusWriteI2cBlock - boolean
|
||||
Specifies whether or not the adapter handles the SMBus write i2c block command
|
||||
(I2C_FUNC_SMBUS_WRITE_I2C_BLOCK).
|
||||
|
||||
## TypeScript Type Definitions
|
||||
|
||||
TypeScript type definitions for i2c-bus can be found in the Definitely Typed
|
||||
repository at
|
||||
https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/i2c-bus.
|
||||
|
||||
24
node_modules/i2c-bus/binding.gyp
generated
vendored
Normal file
24
node_modules/i2c-bus/binding.gyp
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"targets": [{
|
||||
"target_name": "i2c",
|
||||
"include_dirs" : [
|
||||
"<!(node -e \"require('nan')\")"
|
||||
],
|
||||
"conditions": [[
|
||||
'OS == "linux"', {
|
||||
"sources": [
|
||||
"./src/i2c.cc"
|
||||
],
|
||||
"conditions": [[
|
||||
'"<!(echo $V)" != "1"', {
|
||||
"cflags": [
|
||||
"-Wno-deprecated-declarations",
|
||||
"-Wno-cast-function-type"
|
||||
]
|
||||
}]
|
||||
]
|
||||
}]
|
||||
]
|
||||
}]
|
||||
}
|
||||
|
||||
324
node_modules/i2c-bus/build/Makefile
generated
vendored
Normal file
324
node_modules/i2c-bus/build/Makefile
generated
vendored
Normal file
@@ -0,0 +1,324 @@
|
||||
# We borrow heavily from the kernel build setup, though we are simpler since
|
||||
# we don't have Kconfig tweaking settings on us.
|
||||
|
||||
# The implicit make rules have it looking for RCS files, among other things.
|
||||
# We instead explicitly write all the rules we care about.
|
||||
# It's even quicker (saves ~200ms) to pass -r on the command line.
|
||||
MAKEFLAGS=-r
|
||||
|
||||
# The source directory tree.
|
||||
srcdir := ..
|
||||
abs_srcdir := $(abspath $(srcdir))
|
||||
|
||||
# The name of the builddir.
|
||||
builddir_name ?= .
|
||||
|
||||
# The V=1 flag on command line makes us verbosely print command lines.
|
||||
ifdef V
|
||||
quiet=
|
||||
else
|
||||
quiet=quiet_
|
||||
endif
|
||||
|
||||
# Specify BUILDTYPE=Release on the command line for a release build.
|
||||
BUILDTYPE ?= Release
|
||||
|
||||
# Directory all our build output goes into.
|
||||
# Note that this must be two directories beneath src/ for unit tests to pass,
|
||||
# as they reach into the src/ directory for data with relative paths.
|
||||
builddir ?= $(builddir_name)/$(BUILDTYPE)
|
||||
abs_builddir := $(abspath $(builddir))
|
||||
depsdir := $(builddir)/.deps
|
||||
|
||||
# Object output directory.
|
||||
obj := $(builddir)/obj
|
||||
abs_obj := $(abspath $(obj))
|
||||
|
||||
# We build up a list of every single one of the targets so we can slurp in the
|
||||
# generated dependency rule Makefiles in one pass.
|
||||
all_deps :=
|
||||
|
||||
|
||||
|
||||
CC.target ?= $(CC)
|
||||
CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS)
|
||||
CXX.target ?= $(CXX)
|
||||
CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS)
|
||||
LINK.target ?= $(LINK)
|
||||
LDFLAGS.target ?= $(LDFLAGS)
|
||||
AR.target ?= $(AR)
|
||||
|
||||
# C++ apps need to be linked with g++.
|
||||
LINK ?= $(CXX.target)
|
||||
|
||||
# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
|
||||
# to replicate this environment fallback in make as well.
|
||||
CC.host ?= gcc
|
||||
CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host)
|
||||
CXX.host ?= g++
|
||||
CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host)
|
||||
LINK.host ?= $(CXX.host)
|
||||
LDFLAGS.host ?= $(LDFLAGS_host)
|
||||
AR.host ?= ar
|
||||
|
||||
# Define a dir function that can handle spaces.
|
||||
# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
|
||||
# "leading spaces cannot appear in the text of the first argument as written.
|
||||
# These characters can be put into the argument value by variable substitution."
|
||||
empty :=
|
||||
space := $(empty) $(empty)
|
||||
|
||||
# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
|
||||
replace_spaces = $(subst $(space),?,$1)
|
||||
unreplace_spaces = $(subst ?,$(space),$1)
|
||||
dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))
|
||||
|
||||
# Flags to make gcc output dependency info. Note that you need to be
|
||||
# careful here to use the flags that ccache and distcc can understand.
|
||||
# We write to a dep file on the side first and then rename at the end
|
||||
# so we can't end up with a broken dep file.
|
||||
depfile = $(depsdir)/$(call replace_spaces,$@).d
|
||||
DEPFLAGS = -MMD -MF $(depfile).raw
|
||||
|
||||
# We have to fixup the deps output in a few ways.
|
||||
# (1) the file output should mention the proper .o file.
|
||||
# ccache or distcc lose the path to the target, so we convert a rule of
|
||||
# the form:
|
||||
# foobar.o: DEP1 DEP2
|
||||
# into
|
||||
# path/to/foobar.o: DEP1 DEP2
|
||||
# (2) we want missing files not to cause us to fail to build.
|
||||
# We want to rewrite
|
||||
# foobar.o: DEP1 DEP2 \
|
||||
# DEP3
|
||||
# to
|
||||
# DEP1:
|
||||
# DEP2:
|
||||
# DEP3:
|
||||
# so if the files are missing, they're just considered phony rules.
|
||||
# We have to do some pretty insane escaping to get those backslashes
|
||||
# and dollar signs past make, the shell, and sed at the same time.
|
||||
# Doesn't work with spaces, but that's fine: .d files have spaces in
|
||||
# their names replaced with other characters.
|
||||
define fixup_dep
|
||||
# The depfile may not exist if the input file didn't have any #includes.
|
||||
touch $(depfile).raw
|
||||
# Fixup path as in (1).
|
||||
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
|
||||
# Add extra rules as in (2).
|
||||
# We remove slashes and replace spaces with new lines;
|
||||
# remove blank lines;
|
||||
# delete the first line and append a colon to the remaining lines.
|
||||
sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
|
||||
grep -v '^$$' |\
|
||||
sed -e 1d -e 's|$$|:|' \
|
||||
>> $(depfile)
|
||||
rm $(depfile).raw
|
||||
endef
|
||||
|
||||
# Command definitions:
|
||||
# - cmd_foo is the actual command to run;
|
||||
# - quiet_cmd_foo is the brief-output summary of the command.
|
||||
|
||||
quiet_cmd_cc = CC($(TOOLSET)) $@
|
||||
cmd_cc = $(CC.$(TOOLSET)) -o $@ $< $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c
|
||||
|
||||
quiet_cmd_cxx = CXX($(TOOLSET)) $@
|
||||
cmd_cxx = $(CXX.$(TOOLSET)) -o $@ $< $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c
|
||||
|
||||
quiet_cmd_touch = TOUCH $@
|
||||
cmd_touch = touch $@
|
||||
|
||||
quiet_cmd_copy = COPY $@
|
||||
# send stderr to /dev/null to ignore messages when linking directories.
|
||||
cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@")
|
||||
|
||||
quiet_cmd_alink = AR($(TOOLSET)) $@
|
||||
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)
|
||||
|
||||
quiet_cmd_alink_thin = AR($(TOOLSET)) $@
|
||||
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)
|
||||
|
||||
# Due to circular dependencies between libraries :(, we wrap the
|
||||
# special "figure out circular dependencies" flags around the entire
|
||||
# input list during linking.
|
||||
quiet_cmd_link = LINK($(TOOLSET)) $@
|
||||
cmd_link = $(LINK.$(TOOLSET)) -o $@ $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,--start-group $(LD_INPUTS) $(LIBS) -Wl,--end-group
|
||||
|
||||
# We support two kinds of shared objects (.so):
|
||||
# 1) shared_library, which is just bundling together many dependent libraries
|
||||
# into a link line.
|
||||
# 2) loadable_module, which is generating a module intended for dlopen().
|
||||
#
|
||||
# They differ only slightly:
|
||||
# In the former case, we want to package all dependent code into the .so.
|
||||
# In the latter case, we want to package just the API exposed by the
|
||||
# outermost module.
|
||||
# This means shared_library uses --whole-archive, while loadable_module doesn't.
|
||||
# (Note that --whole-archive is incompatible with the --start-group used in
|
||||
# normal linking.)
|
||||
|
||||
# Other shared-object link notes:
|
||||
# - Set SONAME to the library filename so our binaries don't reference
|
||||
# the local, absolute paths used on the link command-line.
|
||||
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
|
||||
cmd_solink = $(LINK.$(TOOLSET)) -o $@ -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS)
|
||||
|
||||
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
|
||||
cmd_solink_module = $(LINK.$(TOOLSET)) -o $@ -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
|
||||
|
||||
|
||||
# Define an escape_quotes function to escape single quotes.
|
||||
# This allows us to handle quotes properly as long as we always use
|
||||
# use single quotes and escape_quotes.
|
||||
escape_quotes = $(subst ','\'',$(1))
|
||||
# This comment is here just to include a ' to unconfuse syntax highlighting.
|
||||
# Define an escape_vars function to escape '$' variable syntax.
|
||||
# This allows us to read/write command lines with shell variables (e.g.
|
||||
# $LD_LIBRARY_PATH), without triggering make substitution.
|
||||
escape_vars = $(subst $$,$$$$,$(1))
|
||||
# Helper that expands to a shell command to echo a string exactly as it is in
|
||||
# make. This uses printf instead of echo because printf's behaviour with respect
|
||||
# to escape sequences is more portable than echo's across different shells
|
||||
# (e.g., dash, bash).
|
||||
exact_echo = printf '%s\n' '$(call escape_quotes,$(1))'
|
||||
|
||||
# Helper to compare the command we're about to run against the command
|
||||
# we logged the last time we ran the command. Produces an empty
|
||||
# string (false) when the commands match.
|
||||
# Tricky point: Make has no string-equality test function.
|
||||
# The kernel uses the following, but it seems like it would have false
|
||||
# positives, where one string reordered its arguments.
|
||||
# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
|
||||
# $(filter-out $(cmd_$@), $(cmd_$(1))))
|
||||
# We instead substitute each for the empty string into the other, and
|
||||
# say they're equal if both substitutions produce the empty string.
|
||||
# .d files contain ? instead of spaces, take that into account.
|
||||
command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
|
||||
$(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))
|
||||
|
||||
# Helper that is non-empty when a prerequisite changes.
|
||||
# Normally make does this implicitly, but we force rules to always run
|
||||
# so we can check their command lines.
|
||||
# $? -- new prerequisites
|
||||
# $| -- order-only dependencies
|
||||
prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))
|
||||
|
||||
# Helper that executes all postbuilds until one fails.
|
||||
define do_postbuilds
|
||||
@E=0;\
|
||||
for p in $(POSTBUILDS); do\
|
||||
eval $$p;\
|
||||
E=$$?;\
|
||||
if [ $$E -ne 0 ]; then\
|
||||
break;\
|
||||
fi;\
|
||||
done;\
|
||||
if [ $$E -ne 0 ]; then\
|
||||
rm -rf "$@";\
|
||||
exit $$E;\
|
||||
fi
|
||||
endef
|
||||
|
||||
# do_cmd: run a command via the above cmd_foo names, if necessary.
|
||||
# Should always run for a given target to handle command-line changes.
|
||||
# Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
|
||||
# Third argument, if non-zero, makes it do POSTBUILDS processing.
|
||||
# Note: We intentionally do NOT call dirx for depfile, since it contains ? for
|
||||
# spaces already and dirx strips the ? characters.
|
||||
define do_cmd
|
||||
$(if $(or $(command_changed),$(prereq_changed)),
|
||||
@$(call exact_echo, $($(quiet)cmd_$(1)))
|
||||
@mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
|
||||
$(if $(findstring flock,$(word 1,$(cmd_$1))),
|
||||
@$(cmd_$(1))
|
||||
@echo " $(quiet_cmd_$(1)): Finished",
|
||||
@$(cmd_$(1))
|
||||
)
|
||||
@$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
|
||||
@$(if $(2),$(fixup_dep))
|
||||
$(if $(and $(3), $(POSTBUILDS)),
|
||||
$(call do_postbuilds)
|
||||
)
|
||||
)
|
||||
endef
|
||||
|
||||
# Declare the "all" target first so it is the default,
|
||||
# even though we don't have the deps yet.
|
||||
.PHONY: all
|
||||
all:
|
||||
|
||||
# make looks for ways to re-generate included makefiles, but in our case, we
|
||||
# don't have a direct way. Explicitly telling make that it has nothing to do
|
||||
# for them makes it go faster.
|
||||
%.d: ;
|
||||
|
||||
# Use FORCE_DO_CMD to force a target to run. Should be coupled with
|
||||
# do_cmd.
|
||||
.PHONY: FORCE_DO_CMD
|
||||
FORCE_DO_CMD:
|
||||
|
||||
TOOLSET := target
|
||||
# Suffix rules, putting all outputs into $(obj).
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
|
||||
# Try building from generated source, too.
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD
|
||||
@$(call do_cmd,cc,1)
|
||||
|
||||
|
||||
ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
|
||||
$(findstring $(join ^,$(prefix)),\
|
||||
$(join ^,i2c.target.mk)))),)
|
||||
include i2c.target.mk
|
||||
endif
|
||||
|
||||
quiet_cmd_regen_makefile = ACTION Regenerating $@
|
||||
cmd_regen_makefile = cd $(srcdir); /home/mdares/.node-red/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/mdares/.cache/node-gyp/20.19.5" "-Dnode_gyp_dir=/home/mdares/.node-red/node_modules/node-gyp" "-Dnode_lib_file=/home/mdares/.cache/node-gyp/20.19.5/<(target_arch)/node.lib" "-Dmodule_root_dir=/home/mdares/.node-red/node_modules/i2c-bus" "-Dnode_engine=v8" "--depth=." "-Goutput_dir=." "--generator-output=build" -I/home/mdares/.node-red/node_modules/i2c-bus/build/config.gypi -I/home/mdares/.node-red/node_modules/node-gyp/addon.gypi -I/home/mdares/.cache/node-gyp/20.19.5/include/node/common.gypi "--toplevel-dir=." binding.gyp
|
||||
Makefile: $(srcdir)/build/config.gypi $(srcdir)/../../../.cache/node-gyp/20.19.5/include/node/common.gypi $(srcdir)/../node-gyp/addon.gypi $(srcdir)/binding.gyp
|
||||
$(call do_cmd,regen_makefile)
|
||||
|
||||
# "all" is a concatenation of the "all" targets from all the included
|
||||
# sub-makefiles. This is just here to clarify.
|
||||
all:
|
||||
|
||||
# Add in dependency-tracking rules. $(all_deps) is the list of every single
|
||||
# target in our tree. Only consider the ones with .d (dependency) info:
|
||||
d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
|
||||
ifneq ($(d_files),)
|
||||
include $(d_files)
|
||||
endif
|
||||
1
node_modules/i2c-bus/build/Release/.deps/Release/i2c.node.d
generated
vendored
Normal file
1
node_modules/i2c-bus/build/Release/.deps/Release/i2c.node.d
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
cmd_Release/i2c.node := ln -f "Release/obj.target/i2c.node" "Release/i2c.node" 2>/dev/null || (rm -rf "Release/i2c.node" && cp -af "Release/obj.target/i2c.node" "Release/i2c.node")
|
||||
1
node_modules/i2c-bus/build/Release/.deps/Release/obj.target/i2c.node.d
generated
vendored
Normal file
1
node_modules/i2c-bus/build/Release/.deps/Release/obj.target/i2c.node.d
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
cmd_Release/obj.target/i2c.node := g++ -o Release/obj.target/i2c.node -shared -pthread -rdynamic -Wl,-soname=i2c.node -Wl,--start-group Release/obj.target/i2c/src/i2c.o -Wl,--end-group
|
||||
217
node_modules/i2c-bus/build/Release/.deps/Release/obj.target/i2c/src/i2c.o.d
generated
vendored
Normal file
217
node_modules/i2c-bus/build/Release/.deps/Release/obj.target/i2c/src/i2c.o.d
generated
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
cmd_Release/obj.target/i2c/src/i2c.o := g++ -o Release/obj.target/i2c/src/i2c.o ../src/i2c.cc '-DNODE_GYP_MODULE_NAME=i2c' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_FILE_OFFSET_BITS=64' '-D_LARGEFILE_SOURCE' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DBUILDING_NODE_EXTENSION' -I/home/mdares/.cache/node-gyp/20.19.5/include/node -I/home/mdares/.cache/node-gyp/20.19.5/src -I/home/mdares/.cache/node-gyp/20.19.5/deps/openssl/config -I/home/mdares/.cache/node-gyp/20.19.5/deps/openssl/openssl/include -I/home/mdares/.cache/node-gyp/20.19.5/deps/uv/include -I/home/mdares/.cache/node-gyp/20.19.5/deps/zlib -I/home/mdares/.cache/node-gyp/20.19.5/deps/v8/include -I../../nan -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -Wno-cast-function-type -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++17 -MMD -MF ./Release/.deps/Release/obj.target/i2c/src/i2c.o.d.raw -c
|
||||
Release/obj.target/i2c/src/i2c.o: ../src/i2c.cc \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/cppgc/common.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8config.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-array-buffer.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-local-handle.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-internal.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-version.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8config.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-object.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-maybe.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-persistent-handle.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-weak-callback-info.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-primitive.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-data.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-value.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-traced-handle.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-container.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-context.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-snapshot.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-date.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-debug.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-script.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-callbacks.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-promise.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-message.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-exception.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-extension.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-external.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-function.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-function-callback.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-template.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-memory-span.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-initialization.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-isolate.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-embedder-heap.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-microtask.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-statistics.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-unwinder.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-embedder-state-scope.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-platform.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-json.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-locker.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-microtask-queue.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-primitive-object.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-proxy.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-regexp.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-typed-array.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-value-serializer.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-wasm.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_version.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_api.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/js_native_api.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/js_native_api_types.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_api_types.h \
|
||||
../../nan/nan.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_version.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/errno.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/version.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/unix.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/threadpool.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/linux.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_buffer.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node.h \
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_object_wrap.h \
|
||||
../../nan/nan_callbacks.h ../../nan/nan_callbacks_12_inl.h \
|
||||
../../nan/nan_maybe_43_inl.h ../../nan/nan_converters.h \
|
||||
../../nan/nan_converters_43_inl.h ../../nan/nan_new.h \
|
||||
../../nan/nan_implementation_12_inl.h ../../nan/nan_persistent_12_inl.h \
|
||||
../../nan/nan_weak.h ../../nan/nan_object_wrap.h ../../nan/nan_private.h \
|
||||
../../nan/nan_typedarray_contents.h ../../nan/nan_json.h \
|
||||
../../nan/nan_scriptorigin.h ../src/./i2cfuncs.h ../src/./deviceid.h \
|
||||
../src/./readbyte.h ../src/./readword.h ../src/./readblock.h \
|
||||
../src/./readi2cblock.h ../src/./receivebyte.h ../src/./sendbyte.h \
|
||||
../src/./setaddr.h ../src/./writebyte.h ../src/./writeword.h \
|
||||
../src/./writeblock.h ../src/./writei2cblock.h ../src/./writequick.h \
|
||||
../src/./i2c-dev.h ../src/./i2cfuncs.cc ../src/././i2c-dev.h \
|
||||
../src/././i2cfuncs.h ../src/././util.h ../src/./deviceid.cc \
|
||||
../src/././deviceid.h ../src/./readbyte.cc ../src/././readbyte.h \
|
||||
../src/./readword.cc ../src/././readword.h ../src/./readblock.cc \
|
||||
../src/././readblock.h ../src/./readi2cblock.cc \
|
||||
../src/././readi2cblock.h ../src/./receivebyte.cc \
|
||||
../src/././receivebyte.h ../src/./sendbyte.cc ../src/././sendbyte.h \
|
||||
../src/./setaddr.cc ../src/././setaddr.h ../src/./writebyte.cc \
|
||||
../src/././writebyte.h ../src/./writeword.cc ../src/././writeword.h \
|
||||
../src/./writeblock.cc ../src/././writeblock.h ../src/./writei2cblock.cc \
|
||||
../src/././writei2cblock.h ../src/./writequick.cc \
|
||||
../src/././writequick.h
|
||||
../src/i2c.cc:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/cppgc/common.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8config.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-array-buffer.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-local-handle.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-internal.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-version.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8config.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-object.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-maybe.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-persistent-handle.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-weak-callback-info.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-primitive.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-data.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-value.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-traced-handle.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-container.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-context.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-snapshot.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-date.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-debug.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-script.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-callbacks.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-promise.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-message.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-exception.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-extension.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-external.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-function.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-function-callback.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-template.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-memory-span.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-initialization.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-isolate.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-embedder-heap.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-microtask.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-statistics.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-unwinder.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-embedder-state-scope.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-platform.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-json.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-locker.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-microtask-queue.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-primitive-object.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-proxy.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-regexp.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-typed-array.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-value-serializer.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/v8-wasm.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_version.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_api.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/js_native_api.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/js_native_api_types.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_api_types.h:
|
||||
../../nan/nan.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_version.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/errno.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/version.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/unix.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/threadpool.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/uv/linux.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_buffer.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node.h:
|
||||
/home/mdares/.cache/node-gyp/20.19.5/include/node/node_object_wrap.h:
|
||||
../../nan/nan_callbacks.h:
|
||||
../../nan/nan_callbacks_12_inl.h:
|
||||
../../nan/nan_maybe_43_inl.h:
|
||||
../../nan/nan_converters.h:
|
||||
../../nan/nan_converters_43_inl.h:
|
||||
../../nan/nan_new.h:
|
||||
../../nan/nan_implementation_12_inl.h:
|
||||
../../nan/nan_persistent_12_inl.h:
|
||||
../../nan/nan_weak.h:
|
||||
../../nan/nan_object_wrap.h:
|
||||
../../nan/nan_private.h:
|
||||
../../nan/nan_typedarray_contents.h:
|
||||
../../nan/nan_json.h:
|
||||
../../nan/nan_scriptorigin.h:
|
||||
../src/./i2cfuncs.h:
|
||||
../src/./deviceid.h:
|
||||
../src/./readbyte.h:
|
||||
../src/./readword.h:
|
||||
../src/./readblock.h:
|
||||
../src/./readi2cblock.h:
|
||||
../src/./receivebyte.h:
|
||||
../src/./sendbyte.h:
|
||||
../src/./setaddr.h:
|
||||
../src/./writebyte.h:
|
||||
../src/./writeword.h:
|
||||
../src/./writeblock.h:
|
||||
../src/./writei2cblock.h:
|
||||
../src/./writequick.h:
|
||||
../src/./i2c-dev.h:
|
||||
../src/./i2cfuncs.cc:
|
||||
../src/././i2c-dev.h:
|
||||
../src/././i2cfuncs.h:
|
||||
../src/././util.h:
|
||||
../src/./deviceid.cc:
|
||||
../src/././deviceid.h:
|
||||
../src/./readbyte.cc:
|
||||
../src/././readbyte.h:
|
||||
../src/./readword.cc:
|
||||
../src/././readword.h:
|
||||
../src/./readblock.cc:
|
||||
../src/././readblock.h:
|
||||
../src/./readi2cblock.cc:
|
||||
../src/././readi2cblock.h:
|
||||
../src/./receivebyte.cc:
|
||||
../src/././receivebyte.h:
|
||||
../src/./sendbyte.cc:
|
||||
../src/././sendbyte.h:
|
||||
../src/./setaddr.cc:
|
||||
../src/././setaddr.h:
|
||||
../src/./writebyte.cc:
|
||||
../src/././writebyte.h:
|
||||
../src/./writeword.cc:
|
||||
../src/././writeword.h:
|
||||
../src/./writeblock.cc:
|
||||
../src/././writeblock.h:
|
||||
../src/./writei2cblock.cc:
|
||||
../src/././writei2cblock.h:
|
||||
../src/./writequick.cc:
|
||||
../src/././writequick.h:
|
||||
BIN
node_modules/i2c-bus/build/Release/i2c.node
generated
vendored
Executable file
BIN
node_modules/i2c-bus/build/Release/i2c.node
generated
vendored
Executable file
Binary file not shown.
BIN
node_modules/i2c-bus/build/Release/obj.target/i2c.node
generated
vendored
Executable file
BIN
node_modules/i2c-bus/build/Release/obj.target/i2c.node
generated
vendored
Executable file
Binary file not shown.
BIN
node_modules/i2c-bus/build/Release/obj.target/i2c/src/i2c.o
generated
vendored
Normal file
BIN
node_modules/i2c-bus/build/Release/obj.target/i2c/src/i2c.o
generated
vendored
Normal file
Binary file not shown.
6
node_modules/i2c-bus/build/binding.Makefile
generated
vendored
Normal file
6
node_modules/i2c-bus/build/binding.Makefile
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# This file is generated by gyp; do not edit.
|
||||
|
||||
export builddir_name ?= ./build/.
|
||||
.PHONY: all
|
||||
all:
|
||||
$(MAKE) i2c
|
||||
444
node_modules/i2c-bus/build/config.gypi
generated
vendored
Normal file
444
node_modules/i2c-bus/build/config.gypi
generated
vendored
Normal file
@@ -0,0 +1,444 @@
|
||||
# Do not edit. File was generated by node-gyp's "configure" step
|
||||
{
|
||||
"target_defaults": {
|
||||
"cflags": [],
|
||||
"default_configuration": "Release",
|
||||
"defines": [],
|
||||
"include_dirs": [],
|
||||
"libraries": [],
|
||||
"msvs_configuration_platform": "ARM64",
|
||||
"xcode_configuration_platform": "arm64"
|
||||
},
|
||||
"variables": {
|
||||
"arm_fpu": "neon",
|
||||
"asan": 0,
|
||||
"clang": 0,
|
||||
"coverage": "false",
|
||||
"dcheck_always_on": 0,
|
||||
"debug_nghttp2": "false",
|
||||
"debug_node": "false",
|
||||
"enable_lto": "false",
|
||||
"enable_pgo_generate": "false",
|
||||
"enable_pgo_use": "false",
|
||||
"error_on_warn": "false",
|
||||
"force_dynamic_crt": 0,
|
||||
"gas_version": "2.35",
|
||||
"host_arch": "arm64",
|
||||
"icu_data_in": "../../deps/icu-tmp/icudt77l.dat",
|
||||
"icu_endianness": "l",
|
||||
"icu_gyp_path": "tools/icu/icu-generic.gyp",
|
||||
"icu_path": "deps/icu-small",
|
||||
"icu_small": "false",
|
||||
"icu_ver_major": "77",
|
||||
"is_debug": 0,
|
||||
"libdir": "lib",
|
||||
"llvm_version": "0.0",
|
||||
"napi_build_version": "9",
|
||||
"node_builtin_shareable_builtins": [
|
||||
"deps/cjs-module-lexer/lexer.js",
|
||||
"deps/cjs-module-lexer/dist/lexer.js",
|
||||
"deps/undici/undici.js"
|
||||
],
|
||||
"node_byteorder": "little",
|
||||
"node_debug_lib": "false",
|
||||
"node_enable_d8": "false",
|
||||
"node_enable_v8_vtunejit": "false",
|
||||
"node_fipsinstall": "false",
|
||||
"node_install_corepack": "true",
|
||||
"node_install_npm": "true",
|
||||
"node_library_files": [
|
||||
"lib/_http_agent.js",
|
||||
"lib/_http_client.js",
|
||||
"lib/_http_common.js",
|
||||
"lib/_http_incoming.js",
|
||||
"lib/_http_outgoing.js",
|
||||
"lib/_http_server.js",
|
||||
"lib/_stream_duplex.js",
|
||||
"lib/_stream_passthrough.js",
|
||||
"lib/_stream_readable.js",
|
||||
"lib/_stream_transform.js",
|
||||
"lib/_stream_wrap.js",
|
||||
"lib/_stream_writable.js",
|
||||
"lib/_tls_common.js",
|
||||
"lib/_tls_wrap.js",
|
||||
"lib/assert.js",
|
||||
"lib/assert/strict.js",
|
||||
"lib/async_hooks.js",
|
||||
"lib/buffer.js",
|
||||
"lib/child_process.js",
|
||||
"lib/cluster.js",
|
||||
"lib/console.js",
|
||||
"lib/constants.js",
|
||||
"lib/crypto.js",
|
||||
"lib/dgram.js",
|
||||
"lib/diagnostics_channel.js",
|
||||
"lib/dns.js",
|
||||
"lib/dns/promises.js",
|
||||
"lib/domain.js",
|
||||
"lib/events.js",
|
||||
"lib/fs.js",
|
||||
"lib/fs/promises.js",
|
||||
"lib/http.js",
|
||||
"lib/http2.js",
|
||||
"lib/https.js",
|
||||
"lib/inspector.js",
|
||||
"lib/inspector/promises.js",
|
||||
"lib/internal/abort_controller.js",
|
||||
"lib/internal/assert.js",
|
||||
"lib/internal/assert/assertion_error.js",
|
||||
"lib/internal/assert/calltracker.js",
|
||||
"lib/internal/assert/utils.js",
|
||||
"lib/internal/async_hooks.js",
|
||||
"lib/internal/blob.js",
|
||||
"lib/internal/blocklist.js",
|
||||
"lib/internal/bootstrap/node.js",
|
||||
"lib/internal/bootstrap/realm.js",
|
||||
"lib/internal/bootstrap/shadow_realm.js",
|
||||
"lib/internal/bootstrap/switches/does_not_own_process_state.js",
|
||||
"lib/internal/bootstrap/switches/does_own_process_state.js",
|
||||
"lib/internal/bootstrap/switches/is_main_thread.js",
|
||||
"lib/internal/bootstrap/switches/is_not_main_thread.js",
|
||||
"lib/internal/bootstrap/web/exposed-wildcard.js",
|
||||
"lib/internal/bootstrap/web/exposed-window-or-worker.js",
|
||||
"lib/internal/buffer.js",
|
||||
"lib/internal/child_process.js",
|
||||
"lib/internal/child_process/serialization.js",
|
||||
"lib/internal/cli_table.js",
|
||||
"lib/internal/cluster/child.js",
|
||||
"lib/internal/cluster/primary.js",
|
||||
"lib/internal/cluster/round_robin_handle.js",
|
||||
"lib/internal/cluster/shared_handle.js",
|
||||
"lib/internal/cluster/utils.js",
|
||||
"lib/internal/cluster/worker.js",
|
||||
"lib/internal/console/constructor.js",
|
||||
"lib/internal/console/global.js",
|
||||
"lib/internal/constants.js",
|
||||
"lib/internal/crypto/aes.js",
|
||||
"lib/internal/crypto/certificate.js",
|
||||
"lib/internal/crypto/cfrg.js",
|
||||
"lib/internal/crypto/cipher.js",
|
||||
"lib/internal/crypto/diffiehellman.js",
|
||||
"lib/internal/crypto/ec.js",
|
||||
"lib/internal/crypto/hash.js",
|
||||
"lib/internal/crypto/hashnames.js",
|
||||
"lib/internal/crypto/hkdf.js",
|
||||
"lib/internal/crypto/keygen.js",
|
||||
"lib/internal/crypto/keys.js",
|
||||
"lib/internal/crypto/mac.js",
|
||||
"lib/internal/crypto/pbkdf2.js",
|
||||
"lib/internal/crypto/random.js",
|
||||
"lib/internal/crypto/rsa.js",
|
||||
"lib/internal/crypto/scrypt.js",
|
||||
"lib/internal/crypto/sig.js",
|
||||
"lib/internal/crypto/util.js",
|
||||
"lib/internal/crypto/webcrypto.js",
|
||||
"lib/internal/crypto/webidl.js",
|
||||
"lib/internal/crypto/x509.js",
|
||||
"lib/internal/debugger/inspect.js",
|
||||
"lib/internal/debugger/inspect_client.js",
|
||||
"lib/internal/debugger/inspect_repl.js",
|
||||
"lib/internal/dgram.js",
|
||||
"lib/internal/dns/callback_resolver.js",
|
||||
"lib/internal/dns/promises.js",
|
||||
"lib/internal/dns/utils.js",
|
||||
"lib/internal/encoding.js",
|
||||
"lib/internal/error_serdes.js",
|
||||
"lib/internal/errors.js",
|
||||
"lib/internal/event_target.js",
|
||||
"lib/internal/events/abort_listener.js",
|
||||
"lib/internal/events/symbols.js",
|
||||
"lib/internal/file.js",
|
||||
"lib/internal/fixed_queue.js",
|
||||
"lib/internal/freelist.js",
|
||||
"lib/internal/freeze_intrinsics.js",
|
||||
"lib/internal/fs/cp/cp-sync.js",
|
||||
"lib/internal/fs/cp/cp.js",
|
||||
"lib/internal/fs/dir.js",
|
||||
"lib/internal/fs/promises.js",
|
||||
"lib/internal/fs/read/context.js",
|
||||
"lib/internal/fs/recursive_watch.js",
|
||||
"lib/internal/fs/rimraf.js",
|
||||
"lib/internal/fs/streams.js",
|
||||
"lib/internal/fs/sync_write_stream.js",
|
||||
"lib/internal/fs/utils.js",
|
||||
"lib/internal/fs/watchers.js",
|
||||
"lib/internal/heap_utils.js",
|
||||
"lib/internal/histogram.js",
|
||||
"lib/internal/http.js",
|
||||
"lib/internal/http2/compat.js",
|
||||
"lib/internal/http2/core.js",
|
||||
"lib/internal/http2/util.js",
|
||||
"lib/internal/inspector_async_hook.js",
|
||||
"lib/internal/inspector_network_tracking.js",
|
||||
"lib/internal/js_stream_socket.js",
|
||||
"lib/internal/legacy/processbinding.js",
|
||||
"lib/internal/linkedlist.js",
|
||||
"lib/internal/main/check_syntax.js",
|
||||
"lib/internal/main/embedding.js",
|
||||
"lib/internal/main/eval_stdin.js",
|
||||
"lib/internal/main/eval_string.js",
|
||||
"lib/internal/main/inspect.js",
|
||||
"lib/internal/main/mksnapshot.js",
|
||||
"lib/internal/main/print_help.js",
|
||||
"lib/internal/main/prof_process.js",
|
||||
"lib/internal/main/repl.js",
|
||||
"lib/internal/main/run_main_module.js",
|
||||
"lib/internal/main/test_runner.js",
|
||||
"lib/internal/main/watch_mode.js",
|
||||
"lib/internal/main/worker_thread.js",
|
||||
"lib/internal/mime.js",
|
||||
"lib/internal/modules/cjs/loader.js",
|
||||
"lib/internal/modules/esm/assert.js",
|
||||
"lib/internal/modules/esm/create_dynamic_module.js",
|
||||
"lib/internal/modules/esm/fetch_module.js",
|
||||
"lib/internal/modules/esm/formats.js",
|
||||
"lib/internal/modules/esm/get_format.js",
|
||||
"lib/internal/modules/esm/hooks.js",
|
||||
"lib/internal/modules/esm/initialize_import_meta.js",
|
||||
"lib/internal/modules/esm/load.js",
|
||||
"lib/internal/modules/esm/loader.js",
|
||||
"lib/internal/modules/esm/module_job.js",
|
||||
"lib/internal/modules/esm/module_map.js",
|
||||
"lib/internal/modules/esm/package_config.js",
|
||||
"lib/internal/modules/esm/resolve.js",
|
||||
"lib/internal/modules/esm/shared_constants.js",
|
||||
"lib/internal/modules/esm/translators.js",
|
||||
"lib/internal/modules/esm/utils.js",
|
||||
"lib/internal/modules/esm/worker.js",
|
||||
"lib/internal/modules/helpers.js",
|
||||
"lib/internal/modules/package_json_reader.js",
|
||||
"lib/internal/modules/run_main.js",
|
||||
"lib/internal/navigator.js",
|
||||
"lib/internal/net.js",
|
||||
"lib/internal/options.js",
|
||||
"lib/internal/per_context/domexception.js",
|
||||
"lib/internal/per_context/messageport.js",
|
||||
"lib/internal/per_context/primordials.js",
|
||||
"lib/internal/perf/event_loop_delay.js",
|
||||
"lib/internal/perf/event_loop_utilization.js",
|
||||
"lib/internal/perf/nodetiming.js",
|
||||
"lib/internal/perf/observe.js",
|
||||
"lib/internal/perf/performance.js",
|
||||
"lib/internal/perf/performance_entry.js",
|
||||
"lib/internal/perf/resource_timing.js",
|
||||
"lib/internal/perf/timerify.js",
|
||||
"lib/internal/perf/usertiming.js",
|
||||
"lib/internal/perf/utils.js",
|
||||
"lib/internal/policy/manifest.js",
|
||||
"lib/internal/policy/sri.js",
|
||||
"lib/internal/priority_queue.js",
|
||||
"lib/internal/process/execution.js",
|
||||
"lib/internal/process/per_thread.js",
|
||||
"lib/internal/process/permission.js",
|
||||
"lib/internal/process/policy.js",
|
||||
"lib/internal/process/pre_execution.js",
|
||||
"lib/internal/process/promises.js",
|
||||
"lib/internal/process/report.js",
|
||||
"lib/internal/process/signal.js",
|
||||
"lib/internal/process/task_queues.js",
|
||||
"lib/internal/process/warning.js",
|
||||
"lib/internal/process/worker_thread_only.js",
|
||||
"lib/internal/promise_hooks.js",
|
||||
"lib/internal/querystring.js",
|
||||
"lib/internal/readline/callbacks.js",
|
||||
"lib/internal/readline/emitKeypressEvents.js",
|
||||
"lib/internal/readline/interface.js",
|
||||
"lib/internal/readline/promises.js",
|
||||
"lib/internal/readline/utils.js",
|
||||
"lib/internal/repl.js",
|
||||
"lib/internal/repl/await.js",
|
||||
"lib/internal/repl/history.js",
|
||||
"lib/internal/repl/utils.js",
|
||||
"lib/internal/socket_list.js",
|
||||
"lib/internal/socketaddress.js",
|
||||
"lib/internal/source_map/prepare_stack_trace.js",
|
||||
"lib/internal/source_map/source_map.js",
|
||||
"lib/internal/source_map/source_map_cache.js",
|
||||
"lib/internal/source_map/source_map_cache_map.js",
|
||||
"lib/internal/stream_base_commons.js",
|
||||
"lib/internal/streams/add-abort-signal.js",
|
||||
"lib/internal/streams/compose.js",
|
||||
"lib/internal/streams/destroy.js",
|
||||
"lib/internal/streams/duplex.js",
|
||||
"lib/internal/streams/duplexify.js",
|
||||
"lib/internal/streams/duplexpair.js",
|
||||
"lib/internal/streams/end-of-stream.js",
|
||||
"lib/internal/streams/from.js",
|
||||
"lib/internal/streams/lazy_transform.js",
|
||||
"lib/internal/streams/legacy.js",
|
||||
"lib/internal/streams/operators.js",
|
||||
"lib/internal/streams/passthrough.js",
|
||||
"lib/internal/streams/pipeline.js",
|
||||
"lib/internal/streams/readable.js",
|
||||
"lib/internal/streams/state.js",
|
||||
"lib/internal/streams/transform.js",
|
||||
"lib/internal/streams/utils.js",
|
||||
"lib/internal/streams/writable.js",
|
||||
"lib/internal/test/binding.js",
|
||||
"lib/internal/test/transfer.js",
|
||||
"lib/internal/test_runner/coverage.js",
|
||||
"lib/internal/test_runner/harness.js",
|
||||
"lib/internal/test_runner/mock/loader.js",
|
||||
"lib/internal/test_runner/mock/mock.js",
|
||||
"lib/internal/test_runner/mock/mock_timers.js",
|
||||
"lib/internal/test_runner/reporter/dot.js",
|
||||
"lib/internal/test_runner/reporter/junit.js",
|
||||
"lib/internal/test_runner/reporter/lcov.js",
|
||||
"lib/internal/test_runner/reporter/spec.js",
|
||||
"lib/internal/test_runner/reporter/tap.js",
|
||||
"lib/internal/test_runner/reporter/utils.js",
|
||||
"lib/internal/test_runner/reporter/v8-serializer.js",
|
||||
"lib/internal/test_runner/runner.js",
|
||||
"lib/internal/test_runner/test.js",
|
||||
"lib/internal/test_runner/tests_stream.js",
|
||||
"lib/internal/test_runner/utils.js",
|
||||
"lib/internal/timers.js",
|
||||
"lib/internal/tls/secure-context.js",
|
||||
"lib/internal/tls/secure-pair.js",
|
||||
"lib/internal/trace_events_async_hooks.js",
|
||||
"lib/internal/tty.js",
|
||||
"lib/internal/url.js",
|
||||
"lib/internal/util.js",
|
||||
"lib/internal/util/colors.js",
|
||||
"lib/internal/util/comparisons.js",
|
||||
"lib/internal/util/debuglog.js",
|
||||
"lib/internal/util/inspect.js",
|
||||
"lib/internal/util/inspector.js",
|
||||
"lib/internal/util/parse_args/parse_args.js",
|
||||
"lib/internal/util/parse_args/utils.js",
|
||||
"lib/internal/util/types.js",
|
||||
"lib/internal/v8/startup_snapshot.js",
|
||||
"lib/internal/v8_prof_polyfill.js",
|
||||
"lib/internal/v8_prof_processor.js",
|
||||
"lib/internal/validators.js",
|
||||
"lib/internal/vm.js",
|
||||
"lib/internal/vm/module.js",
|
||||
"lib/internal/wasm_web_api.js",
|
||||
"lib/internal/watch_mode/files_watcher.js",
|
||||
"lib/internal/watchdog.js",
|
||||
"lib/internal/webidl.js",
|
||||
"lib/internal/webstreams/adapters.js",
|
||||
"lib/internal/webstreams/compression.js",
|
||||
"lib/internal/webstreams/encoding.js",
|
||||
"lib/internal/webstreams/queuingstrategies.js",
|
||||
"lib/internal/webstreams/readablestream.js",
|
||||
"lib/internal/webstreams/transfer.js",
|
||||
"lib/internal/webstreams/transformstream.js",
|
||||
"lib/internal/webstreams/util.js",
|
||||
"lib/internal/webstreams/writablestream.js",
|
||||
"lib/internal/worker.js",
|
||||
"lib/internal/worker/io.js",
|
||||
"lib/internal/worker/js_transferable.js",
|
||||
"lib/internal/worker/messaging.js",
|
||||
"lib/module.js",
|
||||
"lib/net.js",
|
||||
"lib/os.js",
|
||||
"lib/path.js",
|
||||
"lib/path/posix.js",
|
||||
"lib/path/win32.js",
|
||||
"lib/perf_hooks.js",
|
||||
"lib/process.js",
|
||||
"lib/punycode.js",
|
||||
"lib/querystring.js",
|
||||
"lib/readline.js",
|
||||
"lib/readline/promises.js",
|
||||
"lib/repl.js",
|
||||
"lib/sea.js",
|
||||
"lib/stream.js",
|
||||
"lib/stream/consumers.js",
|
||||
"lib/stream/promises.js",
|
||||
"lib/stream/web.js",
|
||||
"lib/string_decoder.js",
|
||||
"lib/sys.js",
|
||||
"lib/test.js",
|
||||
"lib/test/reporters.js",
|
||||
"lib/timers.js",
|
||||
"lib/timers/promises.js",
|
||||
"lib/tls.js",
|
||||
"lib/trace_events.js",
|
||||
"lib/tty.js",
|
||||
"lib/url.js",
|
||||
"lib/util.js",
|
||||
"lib/util/types.js",
|
||||
"lib/v8.js",
|
||||
"lib/vm.js",
|
||||
"lib/wasi.js",
|
||||
"lib/worker_threads.js",
|
||||
"lib/zlib.js"
|
||||
],
|
||||
"node_module_version": 115,
|
||||
"node_no_browser_globals": "false",
|
||||
"node_prefix": "/",
|
||||
"node_release_urlbase": "https://nodejs.org/download/release/",
|
||||
"node_section_ordering_info": "",
|
||||
"node_shared": "false",
|
||||
"node_shared_ada": "false",
|
||||
"node_shared_brotli": "false",
|
||||
"node_shared_cares": "false",
|
||||
"node_shared_http_parser": "false",
|
||||
"node_shared_libuv": "false",
|
||||
"node_shared_nghttp2": "false",
|
||||
"node_shared_nghttp3": "false",
|
||||
"node_shared_ngtcp2": "false",
|
||||
"node_shared_openssl": "false",
|
||||
"node_shared_simdjson": "false",
|
||||
"node_shared_simdutf": "false",
|
||||
"node_shared_uvwasi": "false",
|
||||
"node_shared_zlib": "false",
|
||||
"node_tag": "",
|
||||
"node_target_type": "executable",
|
||||
"node_use_bundled_v8": "true",
|
||||
"node_use_node_code_cache": "true",
|
||||
"node_use_node_snapshot": "true",
|
||||
"node_use_openssl": "true",
|
||||
"node_use_v8_platform": "true",
|
||||
"node_with_ltcg": "false",
|
||||
"node_without_node_options": "false",
|
||||
"node_write_snapshot_as_array_literals": "false",
|
||||
"openssl_is_fips": "false",
|
||||
"openssl_quic": "false",
|
||||
"ossfuzz": "false",
|
||||
"shlib_suffix": "so.115",
|
||||
"single_executable_application": "true",
|
||||
"target_arch": "arm64",
|
||||
"ubsan": 0,
|
||||
"use_prefix_to_find_headers": "false",
|
||||
"v8_enable_31bit_smis_on_64bit_arch": 0,
|
||||
"v8_enable_extensible_ro_snapshot": 0,
|
||||
"v8_enable_external_code_space": 0,
|
||||
"v8_enable_gdbjit": 0,
|
||||
"v8_enable_hugepage": 0,
|
||||
"v8_enable_i18n_support": 1,
|
||||
"v8_enable_inspector": 1,
|
||||
"v8_enable_javascript_promise_hooks": 1,
|
||||
"v8_enable_lite_mode": 0,
|
||||
"v8_enable_maglev": 0,
|
||||
"v8_enable_object_print": 1,
|
||||
"v8_enable_pointer_compression": 0,
|
||||
"v8_enable_pointer_compression_shared_cage": 0,
|
||||
"v8_enable_sandbox": 0,
|
||||
"v8_enable_shared_ro_heap": 1,
|
||||
"v8_enable_v8_checks": 0,
|
||||
"v8_enable_webassembly": 1,
|
||||
"v8_no_strict_aliasing": 1,
|
||||
"v8_optimized_debug": 1,
|
||||
"v8_promise_internal_field_count": 1,
|
||||
"v8_random_seed": 0,
|
||||
"v8_trace_maps": 0,
|
||||
"v8_use_siphash": 1,
|
||||
"want_separate_host_toolset": 0,
|
||||
"nodedir": "/home/mdares/.cache/node-gyp/20.19.5",
|
||||
"standalone_static_library": 1,
|
||||
"user_agent": "npm/10.8.2 node/v20.19.5 linux arm64 workspaces/false",
|
||||
"userconfig": "/home/mdares/.npmrc",
|
||||
"local_prefix": "/home/mdares/.node-red",
|
||||
"prefix": "/usr",
|
||||
"npm_version": "10.8.2",
|
||||
"cache": "/home/mdares/.npm",
|
||||
"node_gyp": "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",
|
||||
"update_notifier": "",
|
||||
"globalconfig": "/usr/etc/npmrc",
|
||||
"init_module": "/home/mdares/.npm-init.js",
|
||||
"global_prefix": "/usr"
|
||||
}
|
||||
}
|
||||
156
node_modules/i2c-bus/build/i2c.target.mk
generated
vendored
Normal file
156
node_modules/i2c-bus/build/i2c.target.mk
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
# This file is generated by gyp; do not edit.
|
||||
|
||||
TOOLSET := target
|
||||
TARGET := i2c
|
||||
DEFS_Debug := \
|
||||
'-DNODE_GYP_MODULE_NAME=i2c' \
|
||||
'-DUSING_UV_SHARED=1' \
|
||||
'-DUSING_V8_SHARED=1' \
|
||||
'-DV8_DEPRECATION_WARNINGS=1' \
|
||||
'-D_GLIBCXX_USE_CXX11_ABI=1' \
|
||||
'-D_FILE_OFFSET_BITS=64' \
|
||||
'-D_LARGEFILE_SOURCE' \
|
||||
'-D__STDC_FORMAT_MACROS' \
|
||||
'-DOPENSSL_NO_PINSHARED' \
|
||||
'-DOPENSSL_THREADS' \
|
||||
'-DBUILDING_NODE_EXTENSION' \
|
||||
'-DDEBUG' \
|
||||
'-D_DEBUG'
|
||||
|
||||
# Flags passed to all source files.
|
||||
CFLAGS_Debug := \
|
||||
-fPIC \
|
||||
-pthread \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wno-unused-parameter \
|
||||
-Wno-deprecated-declarations \
|
||||
-Wno-cast-function-type \
|
||||
-g \
|
||||
-O0
|
||||
|
||||
# Flags passed to only C files.
|
||||
CFLAGS_C_Debug :=
|
||||
|
||||
# Flags passed to only C++ files.
|
||||
CFLAGS_CC_Debug := \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-std=gnu++17
|
||||
|
||||
INCS_Debug := \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/include/node \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/src \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/openssl/config \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/openssl/openssl/include \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/uv/include \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/zlib \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/v8/include \
|
||||
-I$(srcdir)/../nan
|
||||
|
||||
DEFS_Release := \
|
||||
'-DNODE_GYP_MODULE_NAME=i2c' \
|
||||
'-DUSING_UV_SHARED=1' \
|
||||
'-DUSING_V8_SHARED=1' \
|
||||
'-DV8_DEPRECATION_WARNINGS=1' \
|
||||
'-D_GLIBCXX_USE_CXX11_ABI=1' \
|
||||
'-D_FILE_OFFSET_BITS=64' \
|
||||
'-D_LARGEFILE_SOURCE' \
|
||||
'-D__STDC_FORMAT_MACROS' \
|
||||
'-DOPENSSL_NO_PINSHARED' \
|
||||
'-DOPENSSL_THREADS' \
|
||||
'-DBUILDING_NODE_EXTENSION'
|
||||
|
||||
# Flags passed to all source files.
|
||||
CFLAGS_Release := \
|
||||
-fPIC \
|
||||
-pthread \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wno-unused-parameter \
|
||||
-Wno-deprecated-declarations \
|
||||
-Wno-cast-function-type \
|
||||
-O3 \
|
||||
-fno-omit-frame-pointer
|
||||
|
||||
# Flags passed to only C files.
|
||||
CFLAGS_C_Release :=
|
||||
|
||||
# Flags passed to only C++ files.
|
||||
CFLAGS_CC_Release := \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-std=gnu++17
|
||||
|
||||
INCS_Release := \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/include/node \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/src \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/openssl/config \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/openssl/openssl/include \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/uv/include \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/zlib \
|
||||
-I/home/mdares/.cache/node-gyp/20.19.5/deps/v8/include \
|
||||
-I$(srcdir)/../nan
|
||||
|
||||
OBJS := \
|
||||
$(obj).target/$(TARGET)/src/i2c.o
|
||||
|
||||
# Add to the list of files we specially track dependencies for.
|
||||
all_deps += $(OBJS)
|
||||
|
||||
# CFLAGS et al overrides must be target-local.
|
||||
# See "Target-specific Variable Values" in the GNU Make manual.
|
||||
$(OBJS): TOOLSET := $(TOOLSET)
|
||||
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
|
||||
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
|
||||
|
||||
# Suffix rules, putting all outputs into $(obj).
|
||||
|
||||
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
|
||||
# Try building from generated source, too.
|
||||
|
||||
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
|
||||
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
|
||||
@$(call do_cmd,cxx,1)
|
||||
|
||||
# End of this set of suffix rules
|
||||
### Rules for final target.
|
||||
LDFLAGS_Debug := \
|
||||
-pthread \
|
||||
-rdynamic
|
||||
|
||||
LDFLAGS_Release := \
|
||||
-pthread \
|
||||
-rdynamic
|
||||
|
||||
LIBS :=
|
||||
|
||||
$(obj).target/i2c.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
|
||||
$(obj).target/i2c.node: LIBS := $(LIBS)
|
||||
$(obj).target/i2c.node: TOOLSET := $(TOOLSET)
|
||||
$(obj).target/i2c.node: $(OBJS) FORCE_DO_CMD
|
||||
$(call do_cmd,solink_module)
|
||||
|
||||
all_deps += $(obj).target/i2c.node
|
||||
# Add target alias
|
||||
.PHONY: i2c
|
||||
i2c: $(builddir)/i2c.node
|
||||
|
||||
# Copy this to the executable output path.
|
||||
$(builddir)/i2c.node: TOOLSET := $(TOOLSET)
|
||||
$(builddir)/i2c.node: $(obj).target/i2c.node FORCE_DO_CMD
|
||||
$(call do_cmd,copy)
|
||||
|
||||
all_deps += $(builddir)/i2c.node
|
||||
# Short alias for building this executable.
|
||||
.PHONY: i2c.node
|
||||
i2c.node: $(obj).target/i2c.node $(builddir)/i2c.node
|
||||
|
||||
# Add executable to "all" target.
|
||||
.PHONY: all
|
||||
all: $(builddir)/i2c.node
|
||||
|
||||
20
node_modules/i2c-bus/doc/edison-adruino-base-board-i2c.md
generated
vendored
Normal file
20
node_modules/i2c-bus/doc/edison-adruino-base-board-i2c.md
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
## Configuring I2C on the Intel Edison Arduino Base Board
|
||||
|
||||
I2C bus 6 is broken out to the header pins labeled SDA and SCL on the Intel
|
||||
Edison Arduino base board. The
|
||||
[edison-i2c-config](https://github.com/fivdi/edison-i2c-config)
|
||||
package can be used to configure this I2C bus:
|
||||
|
||||
```js
|
||||
const i2cConfig = require('edison-i2c-config');
|
||||
|
||||
i2cConfig((err) => {
|
||||
if (err) {
|
||||
console.log('Sorry, something went wrong configuring I2C bus 6 :(');
|
||||
} else {
|
||||
console.log('Hey!, I2C bus 6 is ready for usage :)');
|
||||
console.log('Run "i2cdetect -y -r 6" to list the devices on bus 6');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
80
node_modules/i2c-bus/doc/raspberry-pi-i2c.md
generated
vendored
Normal file
80
node_modules/i2c-bus/doc/raspberry-pi-i2c.md
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
## Configuring I2C on the Raspberry Pi
|
||||
|
||||
This guide assumes that release 2015-01-31 or later of the Raspbian Operating
|
||||
System is being used.
|
||||
|
||||
An I2C bus is broken out to pins 3 (SDA) and 5 (SCL) on the P1 header. The
|
||||
number of steps that need to be performed to configure this I2C bus for usage
|
||||
by user `pi` on Raspbian without root privileges is highly dependent in the
|
||||
version of Raspbian being used.
|
||||
|
||||
### Configuring I2C with raspi-config
|
||||
|
||||
With Raspbian Jessie 2015-11-21 or later the complete configuration can be
|
||||
performed with the `raspi-config` software configuration tool which can be run
|
||||
from a terminal window as follows:
|
||||
|
||||
```
|
||||
sudo raspi-config
|
||||
```
|
||||
|
||||
In the `raspi-config` user interface navigate to `Interfacing Options >> I2C`
|
||||
and answer the question `"Would you like the ARM I2C interface to be enabled?"`
|
||||
with `<Yes>`. After the next reboot user `pi` will be able to use the I2C bus
|
||||
without root privileges.
|
||||
|
||||
### Configuring I2C Manually
|
||||
|
||||
On older versions of Raspbian (prior to Raspbian Jessie 2015-11-21) the
|
||||
`raspi-config` tool can still be used to configure the I2C bus, but additional
|
||||
steps typically need to be performed.
|
||||
|
||||
#### Step 1 - Enable I2C
|
||||
|
||||
To enable I2C ensure that `/boot/config.txt` contains the following line:
|
||||
|
||||
```
|
||||
dtparam=i2c_arm=on
|
||||
```
|
||||
|
||||
#### Step 2 - Enable user space access to I2C
|
||||
|
||||
To enable userspace access to I2C ensure that `/etc/modules` contains the
|
||||
following line:
|
||||
|
||||
```
|
||||
i2c-dev
|
||||
```
|
||||
|
||||
#### Step 3 - Setting the I2C baudrate
|
||||
|
||||
The default I2C baudrate is 100000. If required, this can be changed with the
|
||||
`i2c_arm_baudrate` parameter. For example, to set the baudrate to 400000, add
|
||||
the following line to `/boot/config.txt`:
|
||||
|
||||
```
|
||||
dtparam=i2c_arm_baudrate=400000
|
||||
```
|
||||
|
||||
#### Step 4 - I2C access without root privileges
|
||||
|
||||
If release 2015-05-05 or later of the Raspbian Operating System is being used,
|
||||
this step can be skipped as user `pi` can access the I2C bus without root
|
||||
privileges.
|
||||
|
||||
If an earlier release of the Raspbian Operating System is being used, create a
|
||||
file called `99-i2c.rules` in directory `/etc/udev/rules.d` with the following
|
||||
content:
|
||||
|
||||
```
|
||||
SUBSYSTEM=="i2c-dev", MODE="0666"
|
||||
```
|
||||
|
||||
This will give all users access to I2C and sudo need not be specified when
|
||||
executing programs using i2c-bus. A more selective rule should be used if
|
||||
required.
|
||||
|
||||
#### Step 5 - Reboot the Raspberry Pi
|
||||
|
||||
After performing the above steps, reboot the Raspberry Pi.
|
||||
|
||||
31
node_modules/i2c-bus/doc/raspberry-pi-software-i2c.md
generated
vendored
Normal file
31
node_modules/i2c-bus/doc/raspberry-pi-software-i2c.md
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
## Configuring Software I2C on the Raspberry Pi
|
||||
|
||||
Raspbian has a software I2C driver that can be enabled by adding the following
|
||||
line to `/boot/config.txt`:
|
||||
|
||||
```
|
||||
dtoverlay=i2c-gpio,bus=3
|
||||
```
|
||||
|
||||
This will create an I2C bus called `/dev/i2c-3`. SDA will be on GPIO23 and SCL
|
||||
will be on GPIO24 which are pins 16 and 18 on the GPIO header respectively.
|
||||
|
||||
For further information about `i2c-gpio` and the parameters it supports see
|
||||
`/boot/overlays/README` on the Raspberry Pi.
|
||||
|
||||
The advantage of software I2C over hardware I2C on the Raspberry Pi is that
|
||||
software I2C supports I2C clock stretching. Hardware I2C doesn't support I2C
|
||||
clock stretching due to a
|
||||
[hardware bug](http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html).
|
||||
|
||||
Some devices like the BNO055 9-axis absolute orientation sensor rely on I2C
|
||||
clock stretching and will not function correctly with hardware I2C on a
|
||||
Raspberry Pi. Using software I2C to communicate with the BNO055 will resolve
|
||||
this issue.
|
||||
|
||||
Another typical use case for software I2C is communication with AVR
|
||||
microcontrollers, for example, the ATmega328P microcontroller on an Arduino
|
||||
UNO. AVR microcontrollers are not particularly fast and it's relatively easy
|
||||
to implement AVR code that relies on I2C clock stretching. Using software I2C
|
||||
to communicate with the AVR will resolve I2C clock stretching issues.
|
||||
|
||||
87
node_modules/i2c-bus/example/ds1621-async-callback.js
generated
vendored
Normal file
87
node_modules/i2c-bus/example/ds1621-async-callback.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
|
||||
const async = require('async');
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_CONFIG = 0xac;
|
||||
const CMD_READ_TEMP = 0xaa;
|
||||
const CMD_START_CONVERT = 0xee;
|
||||
|
||||
const toCelsius = rawTemp => {
|
||||
const halfDegrees = ((rawTemp & 0xff) << 1) + (rawTemp >> 15);
|
||||
|
||||
if ((halfDegrees & 0x100) === 0) {
|
||||
return halfDegrees / 2; // Temp +ve
|
||||
}
|
||||
|
||||
return -((~halfDegrees & 0xff) / 2); // Temp -ve
|
||||
};
|
||||
|
||||
const displayTemperature = _ => {
|
||||
let i2c1;
|
||||
|
||||
async.series([
|
||||
cb => i2c1 = i2c.open(1, cb),
|
||||
|
||||
// Enter one shot mode (this is a non volatile setting)
|
||||
cb => i2c1.writeByte(DS1621_ADDR, CMD_ACCESS_CONFIG, 0x01, cb),
|
||||
|
||||
// Wait while non volatile memory busy
|
||||
cb => {
|
||||
const wait = _ => {
|
||||
i2c1.readByte(DS1621_ADDR, CMD_ACCESS_CONFIG, (err, config) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
if (config & 0x10) {
|
||||
return wait();
|
||||
}
|
||||
cb(null);
|
||||
});
|
||||
};
|
||||
|
||||
wait();
|
||||
},
|
||||
|
||||
// Start temperature conversion
|
||||
cb => i2c1.sendByte(DS1621_ADDR, CMD_START_CONVERT, cb),
|
||||
|
||||
// Wait for temperature conversion to complete
|
||||
cb => {
|
||||
const wait = _ => {
|
||||
i2c1.readByte(DS1621_ADDR, CMD_ACCESS_CONFIG, (err, config) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
if ((config & 0x80) === 0) {
|
||||
return wait();
|
||||
}
|
||||
cb(null);
|
||||
});
|
||||
};
|
||||
|
||||
wait();
|
||||
},
|
||||
|
||||
// Display temperature
|
||||
cb => {
|
||||
i2c1.readWord(DS1621_ADDR, CMD_READ_TEMP, (err, rawTemp) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
console.log('temp: ' + toCelsius(rawTemp));
|
||||
cb(null);
|
||||
});
|
||||
},
|
||||
|
||||
cb => i2c1.close(cb)
|
||||
], err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
displayTemperature();
|
||||
|
||||
BIN
node_modules/i2c-bus/example/ds1621-bb.png
generated
vendored
Normal file
BIN
node_modules/i2c-bus/example/ds1621-bb.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 222 KiB |
BIN
node_modules/i2c-bus/example/ds1621-pi.png
generated
vendored
Normal file
BIN
node_modules/i2c-bus/example/ds1621-pi.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 281 KiB |
45
node_modules/i2c-bus/example/ds1621-sync.js
generated
vendored
Normal file
45
node_modules/i2c-bus/example/ds1621-sync.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_CONFIG = 0xac;
|
||||
const CMD_READ_TEMP = 0xaa;
|
||||
const CMD_START_CONVERT = 0xee;
|
||||
|
||||
const toCelsius = rawTemp => {
|
||||
const halfDegrees = ((rawTemp & 0xff) << 1) + (rawTemp >> 15);
|
||||
|
||||
if ((halfDegrees & 0x100) === 0) {
|
||||
return halfDegrees / 2; // Temp +ve
|
||||
}
|
||||
|
||||
return -((~halfDegrees & 0xff) / 2); // Temp -ve
|
||||
};
|
||||
|
||||
const displayTemperature = _ => {
|
||||
const i2c1 = i2c.openSync(1);
|
||||
|
||||
// Enter one shot mode (this is a non volatile setting)
|
||||
i2c1.writeByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG, 0x01);
|
||||
|
||||
// Wait while non volatile memory busy
|
||||
while (i2c1.readByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG) & 0x10) {
|
||||
}
|
||||
|
||||
// Start temperature conversion
|
||||
i2c1.sendByteSync(DS1621_ADDR, CMD_START_CONVERT);
|
||||
|
||||
// Wait for temperature conversion to complete
|
||||
while ((i2c1.readByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG) & 0x80) === 0) {
|
||||
}
|
||||
|
||||
// Display temperature
|
||||
const rawTemp = i2c1.readWordSync(DS1621_ADDR, CMD_READ_TEMP);
|
||||
console.log('temp: ' + toCelsius(rawTemp));
|
||||
|
||||
i2c1.closeSync();
|
||||
};
|
||||
|
||||
displayTemperature();
|
||||
|
||||
16
node_modules/i2c-bus/example/i2c-list-busses.js
generated
vendored
Normal file
16
node_modules/i2c-bus/example/i2c-list-busses.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
// Determine the bus numbers of the I2C busses available on the current
|
||||
// machine and print those bus numbers to the screen.
|
||||
|
||||
const glob = require('glob');
|
||||
|
||||
const busNumbers = glob.sync('/dev/i2c-*').
|
||||
filter(fileName => fileName.match(/\/i2c-\d+$/) !== null).
|
||||
map(fileName => parseInt(fileName.match(/\d+$/)[0], 10));
|
||||
|
||||
console.log(busNumbers);
|
||||
|
||||
// Here glob is used synchronously but it can also be used asynchronously.
|
||||
// busNumbers is an array of numbers.
|
||||
|
||||
48
node_modules/i2c-bus/example/i2cdetect-quick.js
generated
vendored
Normal file
48
node_modules/i2c-bus/example/i2cdetect-quick.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
// When run, this program will output the same information as the
|
||||
// command 'i2cdetect -y -q 1'
|
||||
// An error message will be printed on the BeagleBone as it doesn't
|
||||
// support the SMBus quick command.
|
||||
// This program is similar to i2cdetect.js, but it uses writeQuickSync
|
||||
// rather than receiveByteSync to detect devices.
|
||||
const fs = require('fs');
|
||||
const i2c = require('../');
|
||||
const i2c1 = i2c.openSync(1);
|
||||
|
||||
const EBUSY = 16; /* Device or resource busy */
|
||||
|
||||
const scan = (first, last) => {
|
||||
fs.writeSync(0, ' 0 1 2 3 4 5 6 7 8 9 a b c d e f');
|
||||
|
||||
for (let addr = 0; addr <= 127; addr += 1) {
|
||||
if (addr % 16 === 0) {
|
||||
fs.writeSync(0, '\n' + (addr === 0 ? '0' : ''));
|
||||
fs.writeSync(0, addr.toString(16) + ':');
|
||||
}
|
||||
|
||||
if (addr < first || addr > last) {
|
||||
fs.writeSync(0, ' ');
|
||||
} else {
|
||||
try {
|
||||
i2c1.writeQuickSync(addr, 0);
|
||||
fs.writeSync(0, ' ' + addr.toString(16)); // device found, print addr
|
||||
} catch (e) {
|
||||
if (e.errno === EBUSY) {
|
||||
fs.writeSync(0, ' UU');
|
||||
} else {
|
||||
fs.writeSync(0, ' --');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeSync(0, '\n');
|
||||
};
|
||||
|
||||
if (!i2c1.i2cFuncsSync().smbusQuick) {
|
||||
console.log('Error: Can\'t use SMBus Quick Write command on this bus#');
|
||||
} else {
|
||||
scan(0x3, 0x77);
|
||||
}
|
||||
|
||||
40
node_modules/i2c-bus/example/i2cdetect.js
generated
vendored
Normal file
40
node_modules/i2c-bus/example/i2cdetect.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
// When run, this program will output the same information as the
|
||||
// command 'i2cdetect -y -r 1'
|
||||
const fs = require('fs');
|
||||
const i2c = require('../');
|
||||
const i2c1 = i2c.openSync(1);
|
||||
|
||||
const EBUSY = 16; /* Device or resource busy */
|
||||
|
||||
const scan = (first, last) => {
|
||||
fs.writeSync(0, ' 0 1 2 3 4 5 6 7 8 9 a b c d e f');
|
||||
|
||||
for (let addr = 0; addr <= 127; addr += 1) {
|
||||
if (addr % 16 === 0) {
|
||||
fs.writeSync(0, '\n' + (addr === 0 ? '0' : ''));
|
||||
fs.writeSync(0, addr.toString(16) + ':');
|
||||
}
|
||||
|
||||
if (addr < first || addr > last) {
|
||||
fs.writeSync(0, ' ');
|
||||
} else {
|
||||
try {
|
||||
i2c1.receiveByteSync(addr);
|
||||
fs.writeSync(0, ' ' + addr.toString(16)); // device found, print addr
|
||||
} catch (e) {
|
||||
if (e.errno === EBUSY) {
|
||||
fs.writeSync(0, ' UU');
|
||||
} else {
|
||||
fs.writeSync(0, ' --');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeSync(0, '\n');
|
||||
};
|
||||
|
||||
scan(0x3, 0x77);
|
||||
|
||||
37
node_modules/i2c-bus/example/i2cfuncs.js
generated
vendored
Normal file
37
node_modules/i2c-bus/example/i2cfuncs.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
// When run, this program will output the same information as the
|
||||
// command 'i2cdetect -F 1'
|
||||
const i2c = require('../');
|
||||
|
||||
const i2c1 = i2c.open(1, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
i2c1.i2cFuncs((err, i2cFuncs) => {
|
||||
const boolToYesNo = bool => bool ? 'yes' : 'no';
|
||||
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log('Functionalities implemented by /dev/i2c-1:');
|
||||
console.log('I2C ' + boolToYesNo(i2cFuncs.i2c));
|
||||
console.log('SMBus Quick Command ' + boolToYesNo(i2cFuncs.smbusQuick));
|
||||
console.log('SMBus Send Byte ' + boolToYesNo(i2cFuncs.smbusSendByte));
|
||||
console.log('SMBus Receive Byte ' + boolToYesNo(i2cFuncs.smbusReceiveByte));
|
||||
console.log('SMBus Write Byte ' + boolToYesNo(i2cFuncs.smbusWriteByte));
|
||||
console.log('SMBus Read Byte ' + boolToYesNo(i2cFuncs.smbusReadByte));
|
||||
console.log('SMBus Write Word ' + boolToYesNo(i2cFuncs.smbusWriteWord));
|
||||
console.log('SMBus Read Word ' + boolToYesNo(i2cFuncs.smbusReadWord));
|
||||
console.log('SMBus Process Call ' + boolToYesNo(i2cFuncs.smbusProcCall));
|
||||
console.log('SMBus Block Write ' + boolToYesNo(i2cFuncs.smbusWriteBlock));
|
||||
console.log('SMBus Block Read ' + boolToYesNo(i2cFuncs.smbusReadBlock));
|
||||
console.log('SMBus Block Process Call ' + boolToYesNo(i2cFuncs.smbusBlockProcCall));
|
||||
console.log('SMBus PEC ' + boolToYesNo(i2cFuncs.smbusPec));
|
||||
console.log('I2C Block Write ' + boolToYesNo(i2cFuncs.smbusWriteI2cBlock));
|
||||
console.log('I2C Block Read ' + boolToYesNo(i2cFuncs.smbusReadI2cBlock));
|
||||
});
|
||||
});
|
||||
|
||||
36
node_modules/i2c-bus/example/mcp9808-async-callback.js
generated
vendored
Normal file
36
node_modules/i2c-bus/example/mcp9808-async-callback.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const MCP9808_ADDR = 0x18;
|
||||
const TEMP_REG = 0x05;
|
||||
|
||||
const toCelsius = rawData => {
|
||||
rawData = (rawData >> 8) + ((rawData & 0xff) << 8);
|
||||
let celsius = (rawData & 0x0fff) / 16;
|
||||
if (rawData & 0x1000) {
|
||||
celsius -= 256;
|
||||
}
|
||||
return celsius;
|
||||
};
|
||||
|
||||
const i2c1 = i2c.open(1, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
i2c1.readWord(MCP9808_ADDR, TEMP_REG, (err, rawData) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log(toCelsius(rawData));
|
||||
|
||||
i2c1.close(err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
BIN
node_modules/i2c-bus/example/mcp9808-pi.png
generated
vendored
Normal file
BIN
node_modules/i2c-bus/example/mcp9808-pi.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
25
node_modules/i2c-bus/example/mcp9808-promise-plain-i2c-buffer.js
generated
vendored
Normal file
25
node_modules/i2c-bus/example/mcp9808-promise-plain-i2c-buffer.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const MCP9808_ADDR = 0x18;
|
||||
const TEMP_REG = 0x05;
|
||||
|
||||
const toCelsius = rawData => {
|
||||
let celsius = (rawData & 0x0fff) / 16;
|
||||
if (rawData & 0x1000) {
|
||||
celsius -= 256;
|
||||
}
|
||||
return celsius;
|
||||
};
|
||||
|
||||
const wbuf = Buffer.from([TEMP_REG]);
|
||||
const rbuf = Buffer.alloc(2);
|
||||
|
||||
i2c.openPromisified(1).
|
||||
then(i2c1 => i2c1.i2cWrite(MCP9808_ADDR, wbuf.length, wbuf).
|
||||
then(_ => i2c1.i2cRead(MCP9808_ADDR, rbuf.length, rbuf)).
|
||||
then(data => console.log(toCelsius(data.buffer.readUInt16BE()))).
|
||||
then(_ => i2c1.close())
|
||||
).catch(console.log);
|
||||
|
||||
22
node_modules/i2c-bus/example/mcp9808-promise.js
generated
vendored
Normal file
22
node_modules/i2c-bus/example/mcp9808-promise.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const MCP9808_ADDR = 0x18;
|
||||
const TEMP_REG = 0x05;
|
||||
|
||||
const toCelsius = rawData => {
|
||||
rawData = (rawData >> 8) + ((rawData & 0xff) << 8);
|
||||
let celsius = (rawData & 0x0fff) / 16;
|
||||
if (rawData & 0x1000) {
|
||||
celsius -= 256;
|
||||
}
|
||||
return celsius;
|
||||
};
|
||||
|
||||
i2c.openPromisified(1).
|
||||
then(i2c1 => i2c1.readWord(MCP9808_ADDR, TEMP_REG).
|
||||
then(rawData => console.log(toCelsius(rawData))).
|
||||
then(_ => i2c1.close())
|
||||
).catch(console.log);
|
||||
|
||||
21
node_modules/i2c-bus/example/mcp9808-sync.js
generated
vendored
Normal file
21
node_modules/i2c-bus/example/mcp9808-sync.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const MCP9808_ADDR = 0x18;
|
||||
const TEMP_REG = 0x05;
|
||||
|
||||
const toCelsius = rawData => {
|
||||
rawData = (rawData >> 8) + ((rawData & 0xff) << 8);
|
||||
let celsius = (rawData & 0x0fff) / 16;
|
||||
if (rawData & 0x1000) {
|
||||
celsius -= 256;
|
||||
}
|
||||
return celsius;
|
||||
};
|
||||
|
||||
const i2c1 = i2c.openSync(1);
|
||||
const rawData = i2c1.readWordSync(MCP9808_ADDR, TEMP_REG);
|
||||
console.log(toCelsius(rawData));
|
||||
i2c1.closeSync();
|
||||
|
||||
40
node_modules/i2c-bus/example/two-devices.js
generated
vendored
Normal file
40
node_modules/i2c-bus/example/two-devices.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const DS1621_CMD_ACCESS_TH = 0xa1;
|
||||
|
||||
const TSL2561_ADDR = 0x39;
|
||||
const TSL2561_CMD = 0x80;
|
||||
const TSL2561_REG_ID = 0x0a;
|
||||
|
||||
const i2c1 = i2c.open(1, err => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
const readDs1621TempHigh = _ => {
|
||||
i2c1.readWord(DS1621_ADDR, DS1621_CMD_ACCESS_TH, (err, tempHigh) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
console.log(tempHigh);
|
||||
readDs1621TempHigh();
|
||||
});
|
||||
};
|
||||
|
||||
const readTsl2561Id = _ => {
|
||||
i2c1.readByte(TSL2561_ADDR, TSL2561_CMD | TSL2561_REG_ID, (err, id) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
console.log(id);
|
||||
readTsl2561Id();
|
||||
});
|
||||
};
|
||||
|
||||
readDs1621TempHigh();
|
||||
readTsl2561Id();
|
||||
});
|
||||
|
||||
821
node_modules/i2c-bus/i2c-bus.js
generated
vendored
Normal file
821
node_modules/i2c-bus/i2c-bus.js
generated
vendored
Normal file
@@ -0,0 +1,821 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const i2c = require('bindings')('i2c.node');
|
||||
|
||||
const BUS_FILE_PREFIX = '/dev/i2c-';
|
||||
const FIRST_SCAN_ADDR = 0x03;
|
||||
const LAST_SCAN_ADDR = 0x77;
|
||||
|
||||
// Table 4.
|
||||
// https://www.nxp.com/docs/en/user-guide/UM10204.pdf
|
||||
const knownManufacturers = [
|
||||
{ value: 0x000, name: 'NXP Semiconductors' },
|
||||
{ value: 0x001, name: 'NXP Semiconductors (reserved)' },
|
||||
{ value: 0x002, name: 'NXP Semiconductors (reserved)' },
|
||||
{ value: 0x003, name: 'NXP Semiconductors (reserved)' },
|
||||
{ value: 0x004, name: 'Ramtron International' },
|
||||
{ value: 0x005, name: 'Analog Devices' },
|
||||
{ value: 0x006, name: 'STMicroelectronics' },
|
||||
{ value: 0x007, name: 'ON Semiconductor' },
|
||||
{ value: 0x008, name: 'Sprintek Corporation' },
|
||||
{ value: 0x009, name: 'ESPROS Photonics AG' },
|
||||
{ value: 0x00a, name: 'Fujitsu Semiconductor' },
|
||||
{ value: 0x00b, name: 'Flir' },
|
||||
{ value: 0x00c, name: 'O\u2082Micro' },
|
||||
{ value: 0x00d, name: 'Atmel' }
|
||||
];
|
||||
|
||||
const open = (busNumber, options, cb) => {
|
||||
if (typeof options === 'function') {
|
||||
cb = options;
|
||||
options = undefined;
|
||||
}
|
||||
|
||||
checkBusNumber(busNumber);
|
||||
checkCallback(cb);
|
||||
|
||||
const bus = new Bus(busNumber, options);
|
||||
|
||||
setImmediate(cb, null);
|
||||
|
||||
return bus;
|
||||
};
|
||||
|
||||
const openSync = (busNumber, options) => {
|
||||
checkBusNumber(busNumber);
|
||||
|
||||
return new Bus(busNumber, options);
|
||||
};
|
||||
|
||||
const openPromisified = (busNumber, options) => new Promise(
|
||||
(resolve, reject) => {
|
||||
const bus = open(busNumber, options,
|
||||
err => err ? reject(err) : resolve(bus.promisifiedBus())
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const checkBusNumber = busNumber => {
|
||||
if (!Number.isInteger(busNumber) || busNumber < 0) {
|
||||
throw new Error('Invalid I2C bus number ' + busNumber);
|
||||
}
|
||||
};
|
||||
|
||||
const checkAddress = addr => {
|
||||
if (!Number.isInteger(addr) || addr < 0 || addr > 0x7f) {
|
||||
throw new Error('Invalid I2C address ' + addr);
|
||||
}
|
||||
};
|
||||
|
||||
const checkCommand = cmd => {
|
||||
if (!Number.isInteger(cmd) || cmd < 0 || cmd > 0xff) {
|
||||
throw new Error('Invalid I2C command ' + cmd);
|
||||
}
|
||||
};
|
||||
|
||||
const checkCallback = cb => {
|
||||
if (typeof cb !== 'function') {
|
||||
throw new Error('Invalid callback ' + cb);
|
||||
}
|
||||
};
|
||||
|
||||
const checkBuffer = buffer => {
|
||||
if (!Buffer.isBuffer(buffer)) {
|
||||
throw new Error('Invalid buffer ' + buffer);
|
||||
}
|
||||
};
|
||||
|
||||
const checkBufferAndLength = (length, buffer, maxLength) => {
|
||||
if (!Number.isInteger(length) ||
|
||||
length < 0 ||
|
||||
(maxLength !== undefined && length > maxLength)) {
|
||||
throw new Error('Invalid buffer length ' + length);
|
||||
}
|
||||
|
||||
checkBuffer(buffer);
|
||||
|
||||
if (buffer.length < length) {
|
||||
throw new Error('Buffer must contain at least ' + length + ' bytes');
|
||||
}
|
||||
};
|
||||
|
||||
const checkByte = byte => {
|
||||
if (!Number.isInteger(byte) || byte < 0 || byte > 0xff) {
|
||||
throw new Error('Invalid byte ' + byte);
|
||||
}
|
||||
};
|
||||
|
||||
const checkWord = word => {
|
||||
if (!Number.isInteger(word) || word < 0 || word > 0xffff) {
|
||||
throw new Error('Invalid word ' + word);
|
||||
}
|
||||
};
|
||||
|
||||
const checkBit = bit => {
|
||||
if (!Number.isInteger(bit) || bit < 0 || bit > 1) {
|
||||
throw new Error('Invalid bit ' + bit);
|
||||
}
|
||||
};
|
||||
|
||||
const parseId = id => {
|
||||
// Figure 20. UM10204
|
||||
const manufacturer = id >> 12 & 0x0fff; // high 12bit
|
||||
const product = id & 0x0fff; // low 12bit
|
||||
|
||||
const known = knownManufacturers.find(man => man.value === manufacturer);
|
||||
const name = known !== undefined ? known.name : ('<0x' + manufacturer.toString(16) + '>');
|
||||
|
||||
return {
|
||||
manufacturer: manufacturer,
|
||||
product: product,
|
||||
name: name
|
||||
};
|
||||
};
|
||||
|
||||
const peripheral = (bus, addr, cb) => {
|
||||
const device = bus._peripherals[addr];
|
||||
|
||||
if (device === undefined) {
|
||||
fs.open(BUS_FILE_PREFIX + bus._busNumber, 'r+', (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
bus._peripherals[addr] = device;
|
||||
|
||||
i2c.setAddrAsync(device, addr, bus._forceAccess, err => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
cb(null, device);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
setImmediate(cb, null, device);
|
||||
}
|
||||
};
|
||||
|
||||
const peripheralSync = (bus, addr) => {
|
||||
let peripheral = bus._peripherals[addr];
|
||||
|
||||
if (peripheral === undefined) {
|
||||
peripheral = fs.openSync(BUS_FILE_PREFIX + bus._busNumber, 'r+');
|
||||
bus._peripherals[addr] = peripheral;
|
||||
i2c.setAddrSync(peripheral, addr, bus._forceAccess);
|
||||
}
|
||||
|
||||
return peripheral;
|
||||
};
|
||||
|
||||
class I2cFuncs {
|
||||
constructor(i2cFuncBits) {
|
||||
this.i2c = !!(i2cFuncBits & i2c.I2C_FUNC_I2C);
|
||||
this.tenBitAddr = !!(i2cFuncBits & i2c.I2C_FUNC_10BIT_ADDR);
|
||||
this.protocolMangling = !!(i2cFuncBits & i2c.I2C_FUNC_PROTOCOL_MANGLING);
|
||||
this.smbusPec = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_PEC);
|
||||
this.smbusBlockProcCall = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_BLOCK_PROC_CALL);
|
||||
this.smbusQuick = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_QUICK);
|
||||
this.smbusReceiveByte = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_READ_BYTE);
|
||||
this.smbusSendByte = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_WRITE_BYTE);
|
||||
this.smbusReadByte = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_READ_BYTE_DATA);
|
||||
this.smbusWriteByte = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_WRITE_BYTE_DATA);
|
||||
this.smbusReadWord = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_READ_WORD_DATA);
|
||||
this.smbusWriteWord = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_WRITE_WORD_DATA);
|
||||
this.smbusProcCall = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_PROC_CALL);
|
||||
this.smbusReadBlock = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_READ_BLOCK_DATA);
|
||||
this.smbusWriteBlock = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_WRITE_BLOCK_DATA);
|
||||
this.smbusReadI2cBlock = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_READ_I2C_BLOCK);
|
||||
this.smbusWriteI2cBlock = !!(i2cFuncBits & i2c.I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
class Bus {
|
||||
constructor(busNumber, options) {
|
||||
options = options || {};
|
||||
|
||||
this._busNumber = busNumber;
|
||||
this._forceAccess = !!options.forceAccess || false;
|
||||
this._peripherals = [];
|
||||
this._promisifiedBus = new PromisifiedBus(this);
|
||||
}
|
||||
|
||||
promisifiedBus() {
|
||||
return this._promisifiedBus;
|
||||
}
|
||||
|
||||
close(cb) {
|
||||
checkCallback(cb);
|
||||
|
||||
const peripherals = this._peripherals.filter(peripheral => {
|
||||
return peripheral !== undefined;
|
||||
});
|
||||
|
||||
const closePeripheral = _ => {
|
||||
if (peripherals.length === 0) {
|
||||
return setImmediate(cb, null);
|
||||
}
|
||||
|
||||
fs.close(peripherals.pop(), err => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
closePeripheral();
|
||||
});
|
||||
};
|
||||
|
||||
closePeripheral();
|
||||
}
|
||||
|
||||
closeSync() {
|
||||
this._peripherals.forEach(peripheral => {
|
||||
if (peripheral !== undefined) {
|
||||
fs.closeSync(peripheral);
|
||||
}
|
||||
});
|
||||
|
||||
this._peripherals = [];
|
||||
}
|
||||
|
||||
i2cFuncs(cb) {
|
||||
checkCallback(cb);
|
||||
|
||||
if (!this.funcs) {
|
||||
peripheral(this, 0, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.i2cFuncsAsync(device, (err, i2cFuncBits) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
this.funcs = Object.freeze(new I2cFuncs(i2cFuncBits));
|
||||
cb(null, this.funcs);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
setImmediate(cb, null, this.funcs);
|
||||
}
|
||||
}
|
||||
|
||||
i2cFuncsSync() {
|
||||
if (!this.funcs) {
|
||||
this.funcs = Object.freeze(new I2cFuncs(i2c.i2cFuncsSync(peripheralSync(this, 0))));
|
||||
}
|
||||
|
||||
return this.funcs;
|
||||
}
|
||||
|
||||
readByte(addr, cmd, cb) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.readByteAsync(device, cmd, cb);
|
||||
});
|
||||
}
|
||||
|
||||
readByteSync(addr, cmd) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
|
||||
return i2c.readByteSync(peripheralSync(this, addr), cmd);
|
||||
}
|
||||
|
||||
readWord(addr, cmd, cb) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.readWordAsync(device, cmd, cb);
|
||||
});
|
||||
}
|
||||
|
||||
readWordSync(addr, cmd) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
|
||||
return i2c.readWordSync(peripheralSync(this, addr), cmd);
|
||||
}
|
||||
|
||||
// UNTESTED and undocumented due to lack of supporting hardware
|
||||
readBlock(addr, cmd, buffer, cb) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkBuffer(buffer);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.readBlockAsync(device, cmd, buffer, cb);
|
||||
});
|
||||
}
|
||||
|
||||
// UNTESTED and undocumented due to lack of supporting hardware
|
||||
readBlockSync(addr, cmd, buffer) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkBuffer(buffer);
|
||||
|
||||
return i2c.readBlockSync(peripheralSync(this, addr), cmd, buffer);
|
||||
}
|
||||
|
||||
readI2cBlock(addr, cmd, length, buffer, cb) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkBufferAndLength(length, buffer, 32);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.readI2cBlockAsync(device, cmd, length, buffer, cb);
|
||||
});
|
||||
}
|
||||
|
||||
readI2cBlockSync(addr, cmd, length, buffer) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkBufferAndLength(length, buffer, 32);
|
||||
|
||||
return i2c.readI2cBlockSync(peripheralSync(this, addr), cmd, length, buffer);
|
||||
}
|
||||
|
||||
receiveByte(addr, cb) {
|
||||
checkAddress(addr);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.receiveByteAsync(device, cb);
|
||||
});
|
||||
}
|
||||
|
||||
receiveByteSync(addr) {
|
||||
checkAddress(addr);
|
||||
|
||||
return i2c.receiveByteSync(peripheralSync(this, addr));
|
||||
}
|
||||
|
||||
sendByte(addr, byte, cb) {
|
||||
checkAddress(addr);
|
||||
checkByte(byte);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.sendByteAsync(device, byte, cb);
|
||||
});
|
||||
}
|
||||
|
||||
sendByteSync(addr, byte) {
|
||||
checkAddress(addr);
|
||||
checkByte(byte);
|
||||
|
||||
i2c.sendByteSync(peripheralSync(this, addr), byte);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
writeByte(addr, cmd, byte, cb) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkByte(byte);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.writeByteAsync(device, cmd, byte, cb);
|
||||
});
|
||||
}
|
||||
|
||||
writeByteSync(addr, cmd, byte) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkByte(byte);
|
||||
|
||||
i2c.writeByteSync(peripheralSync(this, addr), cmd, byte);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
writeWord(addr, cmd, word, cb) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkWord(word);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.writeWordAsync(device, cmd, word, cb);
|
||||
});
|
||||
}
|
||||
|
||||
writeWordSync(addr, cmd, word) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkWord(word);
|
||||
|
||||
i2c.writeWordSync(peripheralSync(this, addr), cmd, word);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
writeQuick(addr, bit, cb) {
|
||||
checkAddress(addr);
|
||||
checkBit(bit);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.writeQuickAsync(device, bit, cb);
|
||||
});
|
||||
}
|
||||
|
||||
writeQuickSync(addr, bit) {
|
||||
checkAddress(addr);
|
||||
checkBit(bit);
|
||||
|
||||
i2c.writeQuickSync(peripheralSync(this, addr), bit);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// UNTESTED and undocumented due to lack of supporting hardware
|
||||
writeBlock(addr, cmd, length, buffer, cb) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkBufferAndLength(length, buffer);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.writeBlockAsync(device, cmd, length, buffer, cb);
|
||||
});
|
||||
}
|
||||
|
||||
// UNTESTED and undocumented due to lack of supporting hardware
|
||||
writeBlockSync(addr, cmd, length, buffer) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkBufferAndLength(length, buffer);
|
||||
|
||||
i2c.writeBlockSync(peripheralSync(this, addr), cmd, length, buffer);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
writeI2cBlock(addr, cmd, length, buffer, cb) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkBufferAndLength(length, buffer, 32);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.writeI2cBlockAsync(device, cmd, length, buffer, cb);
|
||||
});
|
||||
}
|
||||
|
||||
writeI2cBlockSync(addr, cmd, length, buffer) {
|
||||
checkAddress(addr);
|
||||
checkCommand(cmd);
|
||||
checkBufferAndLength(length, buffer, 32);
|
||||
|
||||
i2c.writeI2cBlockSync(peripheralSync(this, addr), cmd, length, buffer);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
i2cRead(addr, length, buffer, cb) {
|
||||
checkAddress(addr);
|
||||
checkBufferAndLength(length, buffer);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
fs.read(device, buffer, 0, length, 0, cb);
|
||||
});
|
||||
}
|
||||
|
||||
i2cReadSync(addr, length, buffer) {
|
||||
checkAddress(addr);
|
||||
checkBufferAndLength(length, buffer);
|
||||
|
||||
return fs.readSync(peripheralSync(this, addr), buffer, 0, length, 0);
|
||||
}
|
||||
|
||||
i2cWrite(addr, length, buffer, cb) {
|
||||
checkAddress(addr);
|
||||
checkBufferAndLength(length, buffer);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
fs.write(device, buffer, 0, length, 0, cb);
|
||||
});
|
||||
}
|
||||
|
||||
i2cWriteSync(addr, length, buffer) {
|
||||
checkAddress(addr);
|
||||
checkBufferAndLength(length, buffer);
|
||||
|
||||
return fs.writeSync(peripheralSync(this, addr), buffer, 0, length, 0);
|
||||
}
|
||||
|
||||
scan(startAddr, endAddr, cb) {
|
||||
if (typeof startAddr === 'function') {
|
||||
cb = startAddr;
|
||||
startAddr = FIRST_SCAN_ADDR;
|
||||
endAddr = LAST_SCAN_ADDR;
|
||||
} else if (typeof endAddr === 'function') {
|
||||
cb = endAddr;
|
||||
endAddr = startAddr;
|
||||
}
|
||||
|
||||
checkCallback(cb);
|
||||
checkAddress(startAddr);
|
||||
checkAddress(endAddr);
|
||||
|
||||
const scanBus = open(this._busNumber, {forceAccess: this._forceAccess}, err => {
|
||||
const addresses = [];
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
const next = addr => {
|
||||
if (addr > endAddr) {
|
||||
return scanBus.close(err => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
cb(null, addresses);
|
||||
});
|
||||
}
|
||||
|
||||
scanBus.receiveByte(addr, err => {
|
||||
if (!err) {
|
||||
addresses.push(addr);
|
||||
}
|
||||
|
||||
next(addr + 1);
|
||||
});
|
||||
};
|
||||
|
||||
next(startAddr);
|
||||
});
|
||||
}
|
||||
|
||||
scanSync(startAddr, endAddr) {
|
||||
if (typeof startAddr === 'undefined') {
|
||||
startAddr = FIRST_SCAN_ADDR;
|
||||
endAddr = LAST_SCAN_ADDR;
|
||||
} else if (typeof endAddr === 'undefined') {
|
||||
endAddr = startAddr;
|
||||
}
|
||||
|
||||
checkAddress(startAddr);
|
||||
checkAddress(endAddr);
|
||||
|
||||
const scanBus = openSync(this._busNumber, {forceAccess: this._forceAccess});
|
||||
const addresses = [];
|
||||
|
||||
for (let addr = startAddr; addr <= endAddr; addr += 1) {
|
||||
try {
|
||||
scanBus.receiveByteSync(addr);
|
||||
addresses.push(addr);
|
||||
} catch (ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
scanBus.closeSync();
|
||||
|
||||
return addresses;
|
||||
}
|
||||
|
||||
deviceId(addr, cb) {
|
||||
checkAddress(addr);
|
||||
checkCallback(cb);
|
||||
|
||||
peripheral(this, addr, (err, device) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
i2c.deviceIdAsync(device, addr, (err, id) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
cb(null, parseId(id));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
deviceIdSync(addr) {
|
||||
checkAddress(addr);
|
||||
|
||||
const mp = i2c.deviceIdSync(peripheralSync(this, addr), addr);
|
||||
|
||||
return parseId(mp);
|
||||
}
|
||||
}
|
||||
|
||||
class PromisifiedBus {
|
||||
constructor(bus) {
|
||||
this._bus = bus;
|
||||
}
|
||||
|
||||
bus() {
|
||||
return this._bus;
|
||||
}
|
||||
|
||||
close() {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.close(err => err ? reject(err) : resolve())
|
||||
);
|
||||
}
|
||||
|
||||
i2cFuncs() {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.i2cFuncs((err, funcs) => err ? reject(err) : resolve(funcs))
|
||||
);
|
||||
}
|
||||
|
||||
readByte(addr, cmd) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.readByte(addr, cmd,
|
||||
(err, byte) => err ? reject(err) : resolve(byte)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
readWord(addr, cmd) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.readWord(addr, cmd,
|
||||
(err, word) => err ? reject(err) : resolve(word)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// UNTESTED and undocumented due to lack of supporting hardware
|
||||
readBlock(addr, cmd, buffer) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.readBlock(addr, cmd, buffer,
|
||||
(err, bytesRead, buffer) =>
|
||||
err ? reject(err) : resolve({bytesRead: bytesRead, buffer: buffer})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
readI2cBlock(addr, cmd, length, buffer) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.readI2cBlock(addr, cmd, length, buffer,
|
||||
(err, bytesRead, buffer) =>
|
||||
err ? reject(err) : resolve({bytesRead: bytesRead, buffer: buffer})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
receiveByte(addr) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.receiveByte(addr,
|
||||
(err, byte) => err ? reject(err) : resolve(byte)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
sendByte(addr, byte) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.sendByte(addr, byte,
|
||||
err => err ? reject(err) : resolve()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
writeByte(addr, cmd, byte) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.writeByte(addr, cmd, byte,
|
||||
err => err ? reject(err) : resolve()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
writeWord(addr, cmd, word) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.writeWord(addr, cmd, word,
|
||||
err => err ? reject(err) : resolve()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
writeQuick(addr, bit) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.writeQuick(addr, bit,
|
||||
err => err ? reject(err) : resolve()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// UNTESTED and undocumented due to lack of supporting hardware
|
||||
writeBlock(addr, cmd, length, buffer) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.writeBlock(addr, cmd, length, buffer,
|
||||
(err, bytesWritten, buffer) =>
|
||||
err ? reject(err) : resolve({bytesWritten: bytesWritten, buffer: buffer})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
writeI2cBlock(addr, cmd, length, buffer) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.writeI2cBlock(addr, cmd, length, buffer,
|
||||
(err, bytesWritten, buffer) =>
|
||||
err ? reject(err) : resolve({bytesWritten: bytesWritten, buffer: buffer})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
i2cRead(addr, length, buffer) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.i2cRead(addr, length, buffer,
|
||||
(err, bytesRead, buffer) =>
|
||||
err ? reject(err) : resolve({bytesRead: bytesRead, buffer: buffer})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
i2cWrite(addr, length, buffer) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.i2cWrite(addr, length, buffer,
|
||||
(err, bytesWritten, buffer) =>
|
||||
err ? reject(err) : resolve({bytesWritten: bytesWritten, buffer: buffer})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
scan(...args) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.scan(...args,
|
||||
(err, devices) => err ? reject(err) : resolve(devices)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
deviceId(addr) {
|
||||
return new Promise((resolve, reject) =>
|
||||
this._bus.deviceId(addr, (err, id) => err ? reject(err) : resolve(id))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
open: open,
|
||||
openSync: openSync,
|
||||
openPromisified: openPromisified
|
||||
};
|
||||
|
||||
33
node_modules/i2c-bus/integration-test/async-brute-force-leak-check.js
generated
vendored
Normal file
33
node_modules/i2c-bus/integration-test/async-brute-force-leak-check.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
const leakTest = testRuns => {
|
||||
const tlbuf = Buffer.alloc(1000000);
|
||||
|
||||
i2c1.readI2cBlock(DS1621_ADDR, CMD_ACCESS_TL, 2, tlbuf, (err, bytesRead, buffer) => {
|
||||
assert(!err, 'can\'t read block data from tl');
|
||||
assert.strictEqual(bytesRead, 2, 'expected readI2cBlock to read 2 bytes');
|
||||
|
||||
if (testRuns % 1000 === 0) {
|
||||
console.log(testRuns);
|
||||
}
|
||||
|
||||
testRuns -= 1;
|
||||
if (testRuns === 0) {
|
||||
i2c1.closeSync();
|
||||
} else {
|
||||
leakTest(testRuns);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const i2c1 = i2c.open(1, err => {
|
||||
assert(!err, 'can\'t open i2c bus');
|
||||
leakTest(1000000);
|
||||
});
|
||||
|
||||
30
node_modules/i2c-bus/integration-test/async-performance.js
generated
vendored
Normal file
30
node_modules/i2c-bus/integration-test/async-performance.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const ITERATIONS = 5000;
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
let time;
|
||||
|
||||
const performanceTest = testRuns => {
|
||||
i2c1.readWord(DS1621_ADDR, CMD_ACCESS_TL, _ => {
|
||||
testRuns -= 1;
|
||||
if (testRuns === 0) {
|
||||
time = process.hrtime(time);
|
||||
const readsPerSec = Math.floor(ITERATIONS / (time[0] + time[1] / 1E9));
|
||||
i2c1.closeSync();
|
||||
console.log('ok - async-performance - ' + readsPerSec + ' reads per second');
|
||||
} else {
|
||||
performanceTest(testRuns);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const i2c1 = i2c.open(1, _ => {
|
||||
time = process.hrtime();
|
||||
performanceTest(ITERATIONS);
|
||||
});
|
||||
|
||||
31
node_modules/i2c-bus/integration-test/async-promise-performance.js
generated
vendored
Normal file
31
node_modules/i2c-bus/integration-test/async-promise-performance.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const ITERATIONS = 5000;
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
let time;
|
||||
|
||||
const performanceTest = (i2c1, testRuns) => {
|
||||
i2c1.readWord(DS1621_ADDR, CMD_ACCESS_TL).then(word => {
|
||||
testRuns -= 1;
|
||||
if (testRuns === 0) {
|
||||
time = process.hrtime(time);
|
||||
const readsPerSec = Math.floor(ITERATIONS / (time[0] + time[1] / 1E9));
|
||||
i2c1.close().then(_ =>
|
||||
console.log('ok - async-promise-performance - ' + readsPerSec + ' reads per second')
|
||||
);
|
||||
} else {
|
||||
performanceTest(i2c1, testRuns);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
i2c.openPromisified(1).then(i2c1 => {
|
||||
time = process.hrtime();
|
||||
performanceTest(i2c1, ITERATIONS);
|
||||
});
|
||||
|
||||
138
node_modules/i2c-bus/integration-test/async-promise.js
generated
vendored
Normal file
138
node_modules/i2c-bus/integration-test/async-promise.js
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_CONFIG = 0xac;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
// Wait while non volatile memory busy
|
||||
const waitForWrite = i2c1 => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const checkWriteFlag = _ => {
|
||||
i2c1.readByte(DS1621_ADDR, CMD_ACCESS_CONFIG).
|
||||
then(config => {
|
||||
if (config & 0x10) {
|
||||
checkWriteFlag();
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}).
|
||||
catch(reject);
|
||||
};
|
||||
|
||||
checkWriteFlag();
|
||||
});
|
||||
};
|
||||
|
||||
const finished = i2c1 =>
|
||||
i2c1.close().
|
||||
then(_ => console.log('ok - async-promise'));
|
||||
|
||||
const i2cFuncs = i2c1 =>
|
||||
i2c1.i2cFuncs().
|
||||
then(i2cFuncs => assert(i2cFuncs.smbusReadByte, 'expected it to be possible to read a byte'));
|
||||
|
||||
const scan = i2c1 =>
|
||||
i2c1.scan().
|
||||
then(devices => assert(
|
||||
devices.includes(DS1621_ADDR),
|
||||
'expected scan to find a ds1621 at address 0x' + DS1621_ADDR.toString(16)
|
||||
));
|
||||
|
||||
// Test i2cWrite & i2cRead
|
||||
// Change value of tl to 25 and verify that tl has been changed
|
||||
const i2cPlainReadWrite = i2c1 => {
|
||||
const cmdSetTL = Buffer.from([CMD_ACCESS_TL, 25, 0]);
|
||||
const cmdGetTL = Buffer.from([CMD_ACCESS_TL]);
|
||||
const tl = Buffer.alloc(2);
|
||||
|
||||
return i2c1.i2cWrite(DS1621_ADDR, cmdSetTL.length, cmdSetTL).
|
||||
then(block => {
|
||||
assert.strictEqual(block.bytesWritten, cmdSetTL.length, 'expected i2cWrite to write 3 bytes');
|
||||
assert.strictEqual(cmdSetTL, block.buffer, 'expected cmdSetTL to be block.buffer');
|
||||
}).
|
||||
then(_ => waitForWrite(i2c1)).
|
||||
then(_ => i2c1.i2cWrite(DS1621_ADDR, cmdGetTL.length, cmdGetTL)).
|
||||
then(block => {
|
||||
assert.strictEqual(block.bytesWritten, cmdGetTL.length, 'expected i2cWrite to write 1 byte');
|
||||
assert.strictEqual(cmdGetTL, block.buffer, 'expected cmdGetTL to be block.buffer');
|
||||
}).
|
||||
then(_ => i2c1.i2cRead(DS1621_ADDR, 2, tl)).
|
||||
then(block => {
|
||||
assert.strictEqual(block.bytesRead, 2, 'expected i2cRead to read 2 bytes');
|
||||
assert.strictEqual(tl.readUInt16LE(0), 25, 'expected i2cRead to read value 25');
|
||||
assert.strictEqual(tl, block.buffer, 'expected tl to be block.buffer');
|
||||
});
|
||||
};
|
||||
|
||||
// Test writeI2cBlock & readI2cBlock
|
||||
// Change value of tl to 22 and verify that tl has been changed
|
||||
const readWriteI2cBlock = i2c1 => {
|
||||
const newtl = Buffer.alloc(10);
|
||||
newtl.writeUInt16LE(22, 0);
|
||||
|
||||
return i2c1.writeI2cBlock(DS1621_ADDR, CMD_ACCESS_TL, 2, newtl).
|
||||
then(block => {
|
||||
assert.strictEqual(block.bytesWritten, 2, 'expected writeI2cBlock to write 2 bytes');
|
||||
assert.strictEqual(newtl, block.buffer, 'expected newtl to be block.buffer');
|
||||
}).
|
||||
then(_ => waitForWrite(i2c1)).
|
||||
then(_ => i2c1.readI2cBlock(DS1621_ADDR, CMD_ACCESS_TL, 2, newtl)).
|
||||
then(block => {
|
||||
assert.strictEqual(block.bytesRead, 2, 'expected readI2cBlock to read 2 bytes');
|
||||
assert.strictEqual(block.buffer.readUInt16LE(0), 22, 'expected readI2cBlock to read value 22');
|
||||
assert.strictEqual(newtl, block.buffer, 'expected newtl to be block.buffer');
|
||||
});
|
||||
};
|
||||
|
||||
// Test writeWord & readWord
|
||||
// Change value of tl and verify that tl has been changed
|
||||
const readWriteWord = i2c1 =>
|
||||
i2c1.readWord(DS1621_ADDR, CMD_ACCESS_TL).
|
||||
then(oldtl => {
|
||||
assert(typeof oldtl === 'number' && oldtl <= 0xffff, 'expeted readWord to read a word');
|
||||
const newtl = (oldtl === 24 ? 23 : 24);
|
||||
return i2c1.writeWord(DS1621_ADDR, CMD_ACCESS_TL, newtl).
|
||||
then(_ => i2c1.readWord(DS1621_ADDR, CMD_ACCESS_TL)).
|
||||
then(newtl2 => {
|
||||
assert(typeof newtl2 === 'number' && newtl2 <= 0xffff, 'expeted readWord to read a word');
|
||||
assert.strictEqual(newtl, newtl2, 'expected to read word written');
|
||||
});
|
||||
});
|
||||
|
||||
// Test sendByte & receiveByte
|
||||
// Read config and verify that it's epectedConfig
|
||||
const sendReceiveByte = (i2c1, epectedConfig) =>
|
||||
i2c1.sendByte(DS1621_ADDR, CMD_ACCESS_CONFIG).
|
||||
then(_ => i2c1.receiveByte(DS1621_ADDR)).
|
||||
then(config => {
|
||||
assert(typeof config === 'number' && config <= 0xff, 'expeted receiveByte to receive a byte');
|
||||
assert.strictEqual(config, epectedConfig, '1st and 2nd config read differ');
|
||||
});
|
||||
|
||||
// Test writeByte & readByte
|
||||
// Enter continuous mode and verify that continuous mode has been entered
|
||||
const readWriteByte = i2c1 =>
|
||||
i2c1.writeByte(DS1621_ADDR, CMD_ACCESS_CONFIG, 0x0).
|
||||
then(_ => waitForWrite(i2c1)).
|
||||
then(_ => i2c1.readByte(DS1621_ADDR, CMD_ACCESS_CONFIG)).
|
||||
then(config => {
|
||||
assert(typeof config === 'number' && config <= 0xff, 'expeted readByte to read a byte');
|
||||
assert.strictEqual(config & 0x1, 0, 'continuous mode not eneterd');
|
||||
return config;
|
||||
});
|
||||
|
||||
i2c.openPromisified(1).
|
||||
then(i2c1 => readWriteByte(i2c1).
|
||||
then(config => sendReceiveByte(i2c1, config)).
|
||||
then(_ => readWriteWord(i2c1)).
|
||||
then(_ => readWriteI2cBlock(i2c1)).
|
||||
then(_ => i2cPlainReadWrite(i2c1)).
|
||||
then(_ => scan(i2c1)).
|
||||
then(_ => i2cFuncs(i2c1)).
|
||||
then(_ => finished(i2c1))
|
||||
).
|
||||
catch(console.log);
|
||||
|
||||
138
node_modules/i2c-bus/integration-test/async.js
generated
vendored
Normal file
138
node_modules/i2c-bus/integration-test/async.js
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_CONFIG = 0xac;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
// Wait while non volatile memory busy
|
||||
const waitForWrite = cb => {
|
||||
i2c1.readByte(DS1621_ADDR, CMD_ACCESS_CONFIG, (err, config) => {
|
||||
assert(!err, 'can\'t read config to determine memory status');
|
||||
if (config & 0x10) {
|
||||
return waitForWrite(cb);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
const finished = _ => i2c1.close(_ => console.log('ok - async'));
|
||||
|
||||
const i2cPlainReadWrite = _ => {
|
||||
// Test i2cWrite & i2cRead
|
||||
// Change value of tl to 25 and verify that tl has been changed
|
||||
const cmdSetTL = Buffer.from([CMD_ACCESS_TL, 25, 0]);
|
||||
const cmdGetTL = Buffer.from([CMD_ACCESS_TL]);
|
||||
const tl = Buffer.alloc(2);
|
||||
|
||||
i2c1.i2cWrite(DS1621_ADDR, cmdSetTL.length, cmdSetTL, (err, bytesWritten, buffer) => {
|
||||
assert(!err, 'can\'t i2cWrite cmdSetTL');
|
||||
assert.strictEqual(bytesWritten, cmdSetTL.length, 'expected i2cWrite to write 3 bytes');
|
||||
assert.strictEqual(cmdSetTL, buffer, 'expected cmdSetTL to be passed to i2cWrite callback');
|
||||
|
||||
waitForWrite(_ => {
|
||||
i2c1.i2cWrite(DS1621_ADDR, cmdGetTL.length, cmdGetTL, (err, bytesWritten, buffer) => {
|
||||
assert(!err, 'can\'t i2cWrite cmdGetTL');
|
||||
assert.strictEqual(bytesWritten, cmdGetTL.length, 'expected i2cWrite to write 1 byte');
|
||||
assert.strictEqual(cmdGetTL, buffer, 'expected cmdGetTL to be passed to i2cWrite callback');
|
||||
|
||||
i2c1.i2cRead(DS1621_ADDR, 2, tl, (err, bytesRead, buffer) => {
|
||||
assert(!err, 'can\'t i2cRead tl');
|
||||
assert.strictEqual(bytesRead, 2, 'expected i2cRead to read 2 bytes');
|
||||
assert.strictEqual(tl.readUInt16LE(0), 25, 'expected i2cRead to read value 25');
|
||||
assert.strictEqual(tl, buffer, 'expected tl to be passed to i2cRead callback');
|
||||
|
||||
finished();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const readWriteI2cBlock = _ => {
|
||||
// Test writeI2cBlock & readI2cBlock
|
||||
// Change value of tl to 22 and verify that tl has been changed
|
||||
const newtl = Buffer.alloc(10);
|
||||
|
||||
newtl.writeUInt16LE(22, 0);
|
||||
i2c1.writeI2cBlock(DS1621_ADDR, CMD_ACCESS_TL, 2, newtl, (err, bytesWritten, buffer) => {
|
||||
assert(!err, 'can\'t writeI2cBlock to tl');
|
||||
assert.strictEqual(bytesWritten, 2, 'expected writeI2cBlock to write 2 bytes');
|
||||
assert.strictEqual(newtl, buffer, 'expected newtl to be passed to writeI2cBlock callback');
|
||||
|
||||
waitForWrite(_ => {
|
||||
i2c1.readI2cBlock(DS1621_ADDR, CMD_ACCESS_TL, 2, newtl, (err, bytesRead, buffer) => {
|
||||
assert(!err, 'can\'t readI2cBlock from tl');
|
||||
assert.strictEqual(bytesRead, 2, 'expected readI2cBlock to read 2 bytes');
|
||||
assert.strictEqual(buffer.readUInt16LE(0), 22, 'expected readI2cBlock to read value 22');
|
||||
assert.strictEqual(newtl, buffer, 'expected newtl to be passed to readI2cBlock callback');
|
||||
|
||||
i2cPlainReadWrite();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const readWriteWord = _ => {
|
||||
// Test writeWord & readWord
|
||||
// Change value of tl and verify that tl has been changed
|
||||
i2c1.readWord(DS1621_ADDR, CMD_ACCESS_TL, (err, oldtl) => {
|
||||
assert(!err, 'can\'t readWord from tl');
|
||||
assert(typeof oldtl === 'number' && oldtl <= 0xffff, 'expeted readWord to read a word');
|
||||
|
||||
const newtl = (oldtl === 24 ? 23 : 24);
|
||||
i2c1.writeWord(DS1621_ADDR, CMD_ACCESS_TL, newtl, err => {
|
||||
assert(!err, 'can\'t write word to tl');
|
||||
|
||||
i2c1.readWord(DS1621_ADDR, CMD_ACCESS_TL, (err, newtl2) => {
|
||||
assert(!err, 'can\'t read new word from tl');
|
||||
assert(typeof newtl2 === 'number' && newtl2 <= 0xffff, 'expeted readWord to read a word');
|
||||
assert.strictEqual(newtl, newtl2, 'expected to read word written');
|
||||
|
||||
readWriteI2cBlock();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const sendReceiveByte = epectedConfig => {
|
||||
// Test sendByte & receiveByte
|
||||
// Read config and verify that it's epectedConfig
|
||||
i2c1.sendByte(DS1621_ADDR, CMD_ACCESS_CONFIG, err => {
|
||||
assert(!err, 'can\'t send byte to config');
|
||||
|
||||
i2c1.receiveByte(DS1621_ADDR, (err, config) => {
|
||||
assert(!err, 'can\'t receive byte from config');
|
||||
assert(typeof config === 'number' && config <= 0xff, 'expeted receiveByte to receive a byte');
|
||||
assert.strictEqual(config, epectedConfig, '1st and 2nd config read differ');
|
||||
|
||||
readWriteWord();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const readWriteByte = _ => {
|
||||
// Test writeByte & readByte
|
||||
// Enter continuous mode and verify that continuous mode has been entered
|
||||
i2c1.writeByte(DS1621_ADDR, CMD_ACCESS_CONFIG, 0x0, err => {
|
||||
assert(!err, 'can\'t write byte to config');
|
||||
|
||||
waitForWrite(_ => {
|
||||
i2c1.readByte(DS1621_ADDR, CMD_ACCESS_CONFIG, (err, config) => {
|
||||
assert(!err, 'can\'t read byte from config');
|
||||
assert(typeof config === 'number' && config <= 0xff, 'expeted readByte to read a byte');
|
||||
assert.strictEqual(config & 0x1, 0, 'continuous mode not eneterd');
|
||||
|
||||
sendReceiveByte(config);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const i2c1 = i2c.open(1, err => {
|
||||
assert(!err, 'can\'t open i2c bus');
|
||||
readWriteByte();
|
||||
});
|
||||
|
||||
45
node_modules/i2c-bus/integration-test/busses.js
generated
vendored
Normal file
45
node_modules/i2c-bus/integration-test/busses.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
|
||||
const openPromisified = _ =>
|
||||
i2c.openPromisified(1).
|
||||
then(promisifiedBus => {
|
||||
assert.strictEqual(
|
||||
promisifiedBus, promisifiedBus.bus().promisifiedBus(),
|
||||
'expected promisifiedBus.bus().promisifiedBus() to return promisifiedBus'
|
||||
);
|
||||
|
||||
const bus = promisifiedBus.bus();
|
||||
assert.strictEqual(
|
||||
bus, bus.promisifiedBus().bus(),
|
||||
'expected bus.promisifiedBus().bus() to return bus'
|
||||
);
|
||||
|
||||
return promisifiedBus.close();
|
||||
}).
|
||||
then(_ => console.log('ok - busses')).
|
||||
catch(console.log);
|
||||
|
||||
const open = _ => {
|
||||
const bus = i2c.open(1, err => {
|
||||
assert(!err, 'can\'t open i2c bus');
|
||||
|
||||
assert.strictEqual(
|
||||
bus, bus.promisifiedBus().bus(),
|
||||
'expected bus.promisifiedBus().bus() to return bus'
|
||||
);
|
||||
|
||||
const promisifiedBus = bus.promisifiedBus();
|
||||
assert.strictEqual(
|
||||
promisifiedBus, promisifiedBus.bus().promisifiedBus(),
|
||||
'expected promisifiedBus.bus().promisifiedBus() to return promisifiedBus'
|
||||
);
|
||||
|
||||
openPromisified();
|
||||
});
|
||||
};
|
||||
|
||||
open();
|
||||
|
||||
17
node_modules/i2c-bus/integration-test/deviceid.js
generated
vendored
Normal file
17
node_modules/i2c-bus/integration-test/deviceid.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
const i2c1 = i2c.openSync(42);
|
||||
|
||||
const address = 0x50;
|
||||
|
||||
i2c1.deviceId(address, (err, id) => {
|
||||
if (err) {
|
||||
console.log('error', err);
|
||||
} else {
|
||||
console.log('id for address', '0x' + address.toString(16), id);
|
||||
}
|
||||
|
||||
i2c1.closeSync();
|
||||
});
|
||||
|
||||
338
node_modules/i2c-bus/integration-test/errors.js
generated
vendored
Normal file
338
node_modules/i2c-bus/integration-test/errors.js
generated
vendored
Normal file
@@ -0,0 +1,338 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
const i2c1 = i2c.openSync(1);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Methods
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// open(busNumber [, options], cb)
|
||||
assert.throws(_ => i2c.open('not an integer'), /Invalid I2C bus number/, 'open');
|
||||
assert.throws(_ => i2c.open(-1), /Invalid I2C bus number/, 'open');
|
||||
|
||||
// openSync(busNumber [, options])
|
||||
assert.throws(_ => i2c.openSync('not an integer'), /Invalid I2C bus number/, 'openSync');
|
||||
assert.throws(_ => i2c.openSync(-1), /Invalid I2C bus number/, 'openSync');
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Free resources
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// close(cb)
|
||||
assert.throws(_ => i2c1.close('not a cb'), /Invalid callback/, 'close');
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Information
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// i2cFuncs(cb)
|
||||
assert.throws(_ => i2c1.i2cFuncs('not a cb'), /Invalid callback/, 'i2cFuncs');
|
||||
|
||||
// scan(cb)
|
||||
assert.throws(_ => i2c1.scan('not a cb'), /Invalid callback/, 'scan');
|
||||
assert.throws(_ => i2c1.scan(0, 'not a cb'), /Invalid callback/, 'scan');
|
||||
assert.throws(_ => i2c1.scan(0, 0, 'not a cb'), /Invalid callback/, 'scan');
|
||||
assert.throws(_ => i2c1.scan('not an addr', 'not a cb'), /Invalid callback/, 'scan');
|
||||
assert.throws(_ => i2c1.scan('not an addr', 'not an addr', 'not a cb'), /Invalid callback/, 'scan');
|
||||
|
||||
assert.throws(_ => i2c1.scan('not an addr', _ => {}), /Invalid I2C address/, 'scan');
|
||||
assert.throws(_ => i2c1.scan(-1, _ => {}), /Invalid I2C address/, 'scan');
|
||||
assert.throws(_ => i2c1.scan(128, _ => {}), /Invalid I2C address/, 'scan');
|
||||
|
||||
assert.throws(_ => i2c1.scan(0, 'not an addr', _ => {}), /Invalid I2C address/, 'scan');
|
||||
assert.throws(_ => i2c1.scan(0, -1, _ => {}), /Invalid I2C address/, 'scan');
|
||||
assert.throws(_ => i2c1.scan(0, 128, _ => {}), /Invalid I2C address/, 'scan');
|
||||
|
||||
// scanSync(cb)
|
||||
assert.throws(_ => i2c1.scanSync('not an addr'), /Invalid I2C address/, 'scan');
|
||||
assert.throws(_ => i2c1.scanSync(-1), /Invalid I2C address/, 'scan');
|
||||
assert.throws(_ => i2c1.scanSync(128), /Invalid I2C address/, 'scan');
|
||||
|
||||
assert.throws(_ => i2c1.scanSync(0, 'not an addr'), /Invalid I2C address/, 'scan');
|
||||
assert.throws(_ => i2c1.scanSync(0, -1), /Invalid I2C address/, 'scan');
|
||||
assert.throws(_ => i2c1.scanSync(0, 128), /Invalid I2C address/, 'scan');
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Plain I2C
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// i2cRead(addr, length, buffer, cb)
|
||||
assert.throws(_ => i2c1.i2cRead('not an addr', 100, Buffer.alloc(100), _ => {}), /Invalid I2C address/, 'i2cRead');
|
||||
assert.throws(_ => i2c1.i2cRead(-1, 100, Buffer.alloc(100), _ => {}), /Invalid I2C address/, 'i2cRead');
|
||||
assert.throws(_ => i2c1.i2cRead(128, 100, Buffer.alloc(100), _ => {}), /Invalid I2C address/, 'i2cRead');
|
||||
|
||||
assert.throws(_ => i2c1.i2cRead(0, 'not a length', Buffer.alloc(100), _ => {}), /Invalid buffer length/, 'i2cRead');
|
||||
assert.throws(_ => i2c1.i2cRead(0, -1, Buffer.alloc(100), _ => {}), /Invalid buffer length/, 'i2cRead');
|
||||
|
||||
assert.throws(_ => i2c1.i2cRead(0, 100, 'not a buffer', _ => {}), /Invalid buffer/, 'i2cRead');
|
||||
|
||||
assert.throws(_ => i2c1.i2cRead(0, 101, Buffer.alloc(100), _ => {}), /Buffer must contain at least/, 'i2cRead');
|
||||
|
||||
assert.throws(_ => i2c1.i2cRead(0, 100, Buffer.alloc(100), 'not a cb'), /Invalid callback/, 'i2cRead');
|
||||
|
||||
// i2cReadSync(addr, length, buffer)
|
||||
assert.throws(_ => i2c1.i2cReadSync('not an addr', 0), /Invalid I2C address/, 'i2cReadSync');
|
||||
assert.throws(_ => i2c1.i2cReadSync(-1, 0), /Invalid I2C address/, 'i2cReadSync');
|
||||
assert.throws(_ => i2c1.i2cReadSync(128, 0), /Invalid I2C address/, 'i2cReadSync');
|
||||
|
||||
assert.throws(_ => i2c1.i2cReadSync(0, 'not a length', Buffer.alloc(100)), /Invalid buffer length/, 'i2cReadSync');
|
||||
assert.throws(_ => i2c1.i2cReadSync(0, -1, Buffer.alloc(100)), /Invalid buffer length/, 'i2cReadSync');
|
||||
|
||||
assert.throws(_ => i2c1.i2cReadSync(0, 100, 'not a buffer'), /Invalid buffer/, 'i2cReadSync');
|
||||
|
||||
assert.throws(_ => i2c1.i2cReadSync(0, 101, Buffer.alloc(100)), /Buffer must contain at least/, 'i2cReadSync');
|
||||
|
||||
// i2cWrite(addr, length, buffer, cb)
|
||||
assert.throws(_ => i2c1.i2cWrite('not an addr', 0, _ => {}), /Invalid I2C address/, 'i2cWrite');
|
||||
assert.throws(_ => i2c1.i2cWrite(-1, 0, _ => {}), /Invalid I2C address/, 'i2cWrite');
|
||||
assert.throws(_ => i2c1.i2cWrite(128, 0, _ => {}), /Invalid I2C address/, 'i2cWrite');
|
||||
|
||||
assert.throws(_ => i2c1.i2cWrite(0, 'not a length', Buffer.alloc(100), _ => {}), /Invalid buffer length/, 'i2cWrite');
|
||||
assert.throws(_ => i2c1.i2cWrite(0, -1, Buffer.alloc(100), _ => {}), /Invalid buffer length/, 'i2cWrite');
|
||||
|
||||
assert.throws(_ => i2c1.i2cWrite(0, 100, 'not a buffer', _ => {}), /Invalid buffer/, 'i2cWrite');
|
||||
|
||||
assert.throws(_ => i2c1.i2cWrite(0, 101, Buffer.alloc(100), _ => {}), /Buffer must contain at least/, 'i2cWrite');
|
||||
|
||||
assert.throws(_ => i2c1.i2cWrite(0, 100, Buffer.alloc(100), 'not a cb'), /Invalid callback/, 'i2cWrite');
|
||||
|
||||
// i2cWriteSync(addr, length, buffer)
|
||||
assert.throws(_ => i2c1.i2cWriteSync('not an addr', 0), /Invalid I2C address/, 'i2cWriteSync');
|
||||
assert.throws(_ => i2c1.i2cWriteSync(-1, 0), /Invalid I2C address/, 'i2cWriteSync');
|
||||
assert.throws(_ => i2c1.i2cWriteSync(128, 0), /Invalid I2C address/, 'i2cWriteSync');
|
||||
|
||||
assert.throws(_ => i2c1.i2cWriteSync(0, 'not a length', Buffer.alloc(100)), /Invalid buffer length/, 'i2cWriteSync');
|
||||
assert.throws(_ => i2c1.i2cWriteSync(0, -1, Buffer.alloc(100)), /Invalid buffer length/, 'i2cWriteSync');
|
||||
|
||||
assert.throws(_ => i2c1.i2cWriteSync(0, 100, 'not a buffer'), /Invalid buffer/, 'i2cWriteSync');
|
||||
|
||||
assert.throws(_ => i2c1.i2cWriteSync(0, 101, Buffer.alloc(100)), /Buffer must contain at least/, 'i2cWriteSync');
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// SMBus
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// readByte(addr, cmd, cb)
|
||||
assert.throws(_ => i2c1.readByte('not an addr', 0, _ => {}), /Invalid I2C address/, 'readByte');
|
||||
assert.throws(_ => i2c1.readByte(-1, 0, _ => {}), /Invalid I2C address/, 'readByte');
|
||||
assert.throws(_ => i2c1.readByte(128, 0, _ => {}), /Invalid I2C address/, 'readByte');
|
||||
|
||||
assert.throws(_ => i2c1.readByte(0, 'not a command', _ => {}), /Invalid I2C command/, 'readByte');
|
||||
assert.throws(_ => i2c1.readByte(0, -1, _ => {}), /Invalid I2C command/, 'readByte');
|
||||
assert.throws(_ => i2c1.readByte(0, 256, _ => {}), /Invalid I2C command/, 'readByte');
|
||||
|
||||
assert.throws(_ => i2c1.readByte(0, 0, 'not a cb'), /Invalid callback/, 'readByte');
|
||||
|
||||
// readByteSync(addr, cmd)
|
||||
assert.throws(_ => i2c1.readByteSync('not an addr', 0), /Invalid I2C address/, 'readByteSync');
|
||||
assert.throws(_ => i2c1.readByteSync(-1, 0), /Invalid I2C address/, 'readByteSync');
|
||||
assert.throws(_ => i2c1.readByteSync(128, 0), /Invalid I2C address/, 'readByteSync');
|
||||
|
||||
assert.throws(_ => i2c1.readByteSync(0, 'not a command'), /Invalid I2C command/, 'readByteSync');
|
||||
assert.throws(_ => i2c1.readByteSync(0, -1), /Invalid I2C command/, 'readByteSync');
|
||||
assert.throws(_ => i2c1.readByteSync(0, 256), /Invalid I2C command/, 'readByteSync');
|
||||
|
||||
// readWord(addr, cmd, cb)
|
||||
assert.throws(_ => i2c1.readWord('not an addr', 0, _ => {}), /Invalid I2C address/, 'readWord');
|
||||
assert.throws(_ => i2c1.readWord(-1, 0, _ => {}), /Invalid I2C address/, 'readWord');
|
||||
assert.throws(_ => i2c1.readWord(128, 0, _ => {}), /Invalid I2C address/, 'readWord');
|
||||
|
||||
assert.throws(_ => i2c1.readWord(0, 'not a command', _ => {}), /Invalid I2C command/, 'readWord');
|
||||
assert.throws(_ => i2c1.readWord(0, -1, _ => {}), /Invalid I2C command/, 'readWord');
|
||||
assert.throws(_ => i2c1.readWord(0, 256, _ => {}), /Invalid I2C command/, 'readWord');
|
||||
|
||||
assert.throws(_ => i2c1.readWord(0, 0, 'not a cb'), /Invalid callback/, 'readWord');
|
||||
|
||||
// readWordSync(addr, cmd)
|
||||
assert.throws(_ => i2c1.readWordSync('not an addr', 0), /Invalid I2C address/, 'readWordSync');
|
||||
assert.throws(_ => i2c1.readWordSync(-1, 0), /Invalid I2C address/, 'readWordSync');
|
||||
assert.throws(_ => i2c1.readWordSync(128, 0), /Invalid I2C address/, 'readWordSync');
|
||||
|
||||
assert.throws(_ => i2c1.readWordSync(0, 'not a command'), /Invalid I2C command/, 'readWordSync');
|
||||
assert.throws(_ => i2c1.readWordSync(0, -1), /Invalid I2C command/, 'readWordSync');
|
||||
assert.throws(_ => i2c1.readWordSync(0, 256), /Invalid I2C command/, 'readWordSync');
|
||||
|
||||
// readI2cBlock(addr, cmd, length, buffer, cb)
|
||||
assert.throws(_ => i2c1.readI2cBlock('not an addr', 0, 10, Buffer.alloc(10), _ => {}), /Invalid I2C address/, 'readI2cBlock');
|
||||
assert.throws(_ => i2c1.readI2cBlock(-1, 0, 10, Buffer.alloc(10), _ => {}), /Invalid I2C address/, 'readI2cBlock');
|
||||
assert.throws(_ => i2c1.readI2cBlock(128, 0, 10, Buffer.alloc(10), _ => {}), /Invalid I2C address/, 'readI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.readI2cBlock(0, 'not a command', 10, Buffer.alloc(10), _ => {}), /Invalid I2C command/, 'readI2cBlock');
|
||||
assert.throws(_ => i2c1.readI2cBlock(0, -1, 10, Buffer.alloc(10), _ => {}), /Invalid I2C command/, 'readI2cBlock');
|
||||
assert.throws(_ => i2c1.readI2cBlock(0, 256, 10, Buffer.alloc(10), _ => {}), /Invalid I2C command/, 'readI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.readI2cBlock(0, 0, 'not a length', Buffer.alloc(10), _ => {}), /Invalid buffer length/, 'readI2cBlock');
|
||||
assert.throws(_ => i2c1.readI2cBlock(0, 0, -1, Buffer.alloc(10), _ => {}), /Invalid buffer length/, 'readI2cBlock');
|
||||
assert.throws(_ => i2c1.readI2cBlock(0, 0, 33, Buffer.alloc(33), _ => {}), /Invalid buffer length/, 'readI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.readI2cBlock(0, 0, 10, 'not a buffer', _ => {}), /Invalid buffer/, 'readI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.readI2cBlock(0, 0, 11, Buffer.alloc(10), _ => {}), /Buffer must contain at least/, 'readI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.readI2cBlock(0, 0, 10, Buffer.alloc(10), 'not a cb'), /Invalid callback/, 'readI2cBlock');
|
||||
|
||||
// readI2cBlockSync(addr, cmd, length, buffer)
|
||||
assert.throws(_ => i2c1.readI2cBlockSync('not an addr', 0, 10, Buffer.alloc(10)), /Invalid I2C address/, 'readI2cBlockSync');
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(-1, 0, 10, Buffer.alloc(10)), /Invalid I2C address/, 'readI2cBlockSync');
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(128, 0, 10, Buffer.alloc(10)), /Invalid I2C address/, 'readI2cBlockSync');
|
||||
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(0, 'not a command', 10, Buffer.alloc(10)), /Invalid I2C command/, 'readI2cBlockSync');
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(0, -1, 10, Buffer.alloc(10)), /Invalid I2C command/, 'readI2cBlockSync');
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(0, 256, 10, Buffer.alloc(10)), /Invalid I2C command/, 'readI2cBlockSync');
|
||||
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(0, 0, 'not a length', Buffer.alloc(10)), /Invalid buffer length/, 'readI2cBlockSync');
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(0, 0, -1, Buffer.alloc(10)), /Invalid buffer length/, 'readI2cBlockSync');
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(0, 0, 33, Buffer.alloc(33)), /Invalid buffer length/, 'readI2cBlockSync');
|
||||
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(0, 0, 10, 'not a buffer'), /Invalid buffer/, 'readI2cBlockSync');
|
||||
|
||||
assert.throws(_ => i2c1.readI2cBlockSync(0, 0, 11, Buffer.alloc(10)), /Buffer must contain at least/, 'readI2cBlockSync');
|
||||
|
||||
// receiveByte(addr, cb)
|
||||
assert.throws(_ => i2c1.receiveByte('not an addr', _ => {}), /Invalid I2C address/, 'receiveByte');
|
||||
assert.throws(_ => i2c1.receiveByte(-1, _ => {}), /Invalid I2C address/, 'receiveByte');
|
||||
assert.throws(_ => i2c1.receiveByte(128, _ => {}), /Invalid I2C address/, 'receiveByte');
|
||||
|
||||
assert.throws(_ => i2c1.receiveByte(0, 'not a cb'), /Invalid callback/, 'receiveByte');
|
||||
|
||||
// receiveByteSync(addr)
|
||||
assert.throws(_ => i2c1.receiveByteSync('not an addr'), /Invalid I2C address/, 'receiveByteSync');
|
||||
assert.throws(_ => i2c1.receiveByteSync(-1), /Invalid I2C address/, 'receiveByteSync');
|
||||
assert.throws(_ => i2c1.receiveByteSync(128), /Invalid I2C address/, 'receiveByteSync');
|
||||
|
||||
// sendByte(addr, byte, cb)
|
||||
assert.throws(_ => i2c1.sendByte('not an addr', 0, _ => {}), /Invalid I2C address/, 'sendByte');
|
||||
assert.throws(_ => i2c1.sendByte(-1, 0, _ => {}), /Invalid I2C address/, 'sendByte');
|
||||
assert.throws(_ => i2c1.sendByte(128, 0, _ => {}), /Invalid I2C address/, 'sendByte');
|
||||
|
||||
assert.throws(_ => i2c1.sendByte(0, 'not a byte', _ => {}), /Invalid byte/, 'sendByte');
|
||||
assert.throws(_ => i2c1.sendByte(0, -1, _ => {}), /Invalid byte/, 'sendByte');
|
||||
assert.throws(_ => i2c1.sendByte(0, 256, _ => {}), /Invalid byte/, 'sendByte');
|
||||
|
||||
assert.throws(_ => i2c1.sendByte(0, 0, 'not a cb'), /Invalid callback/, 'sendByte');
|
||||
|
||||
// sendByteSync(addr, byte)
|
||||
assert.throws(_ => i2c1.sendByteSync('not an addr', 0), /Invalid I2C address/, 'sendByteSync');
|
||||
assert.throws(_ => i2c1.sendByteSync(-1, 0), /Invalid I2C address/, 'sendByteSync');
|
||||
assert.throws(_ => i2c1.sendByteSync(128, 0), /Invalid I2C address/, 'sendByteSync');
|
||||
|
||||
assert.throws(_ => i2c1.sendByteSync(0, 'not a byte'), /Invalid byte/, 'sendByteSync');
|
||||
assert.throws(_ => i2c1.sendByteSync(0, -1), /Invalid byte/, 'sendByteSync');
|
||||
assert.throws(_ => i2c1.sendByteSync(0, 256), /Invalid byte/, 'sendByteSync');
|
||||
|
||||
// writeByte(addr, cmd, byte, cb)
|
||||
assert.throws(_ => i2c1.writeByte('not an addr', 0, 0, _ => {}), /Invalid I2C address/, 'writeByte');
|
||||
assert.throws(_ => i2c1.writeByte(-1, 0, 0, _ => {}), /Invalid I2C address/, 'writeByte');
|
||||
assert.throws(_ => i2c1.writeByte(128, 0, 0, _ => {}), /Invalid I2C address/, 'writeByte');
|
||||
|
||||
assert.throws(_ => i2c1.writeByte(0, 'not a command', 0, _ => {}), /Invalid I2C command/, 'writeByte');
|
||||
assert.throws(_ => i2c1.writeByte(0, -1, 0, _ => {}), /Invalid I2C command/, 'writeByte');
|
||||
assert.throws(_ => i2c1.writeByte(0, 256, 0, _ => {}), /Invalid I2C command/, 'writeByte');
|
||||
|
||||
assert.throws(_ => i2c1.writeByte(0, 0, 'not a byte', _ => {}), /Invalid byte/, 'writeByte');
|
||||
assert.throws(_ => i2c1.writeByte(0, 0, -1, _ => {}), /Invalid byte/, 'writeByte');
|
||||
assert.throws(_ => i2c1.writeByte(0, 0, 256, _ => {}), /Invalid byte/, 'writeByte');
|
||||
|
||||
assert.throws(_ => i2c1.writeByte(0, 0, 0, 'not a cb'), /Invalid callback/, 'writeByte');
|
||||
|
||||
// writeByteSync(addr, cmd, byte)
|
||||
assert.throws(_ => i2c1.writeByteSync('not an addr', 0, 0), /Invalid I2C address/, 'writeByteSync');
|
||||
assert.throws(_ => i2c1.writeByteSync(-1, 0, 0), /Invalid I2C address/, 'writeByteSync');
|
||||
assert.throws(_ => i2c1.writeByteSync(128, 0, 0), /Invalid I2C address/, 'writeByteSync');
|
||||
|
||||
assert.throws(_ => i2c1.writeByteSync(0, 'not a command', 0), /Invalid I2C command/, 'writeByteSync');
|
||||
assert.throws(_ => i2c1.writeByteSync(0, -1, 0), /Invalid I2C command/, 'writeByteSync');
|
||||
assert.throws(_ => i2c1.writeByteSync(0, 256, 0), /Invalid I2C command/, 'writeByteSync');
|
||||
|
||||
assert.throws(_ => i2c1.writeByteSync(0, 0, 'not a byte'), /Invalid byte/, 'writeByteSync');
|
||||
assert.throws(_ => i2c1.writeByteSync(0, 0, -1), /Invalid byte/, 'writeByteSync');
|
||||
assert.throws(_ => i2c1.writeByteSync(0, 0, 256), /Invalid byte/, 'writeByteSync');
|
||||
|
||||
// writeWord(addr, cmd, word, cb)
|
||||
assert.throws(_ => i2c1.writeWord('not an addr', 0, 0, _ => {}), /Invalid I2C address/, 'writeWord');
|
||||
assert.throws(_ => i2c1.writeWord(-1, 0, 0, _ => {}), /Invalid I2C address/, 'writeWord');
|
||||
assert.throws(_ => i2c1.writeWord(128, 0, 0, _ => {}), /Invalid I2C address/, 'writeWord');
|
||||
|
||||
assert.throws(_ => i2c1.writeWord(0, 'not a command', 0, _ => {}), /Invalid I2C command/, 'writeWord');
|
||||
assert.throws(_ => i2c1.writeWord(0, -1, 0, _ => {}), /Invalid I2C command/, 'writeWord');
|
||||
assert.throws(_ => i2c1.writeWord(0, 256, 0, _ => {}), /Invalid I2C command/, 'writeWord');
|
||||
|
||||
assert.throws(_ => i2c1.writeWord(0, 0, 'not a word', _ => {}), /Invalid word/, 'writeWord');
|
||||
assert.throws(_ => i2c1.writeWord(0, 0, -1, _ => {}), /Invalid word/, 'writeWord');
|
||||
assert.throws(_ => i2c1.writeWord(0, 0, 0xffff+1, _ => {}), /Invalid word/, 'writeWord');
|
||||
|
||||
assert.throws(_ => i2c1.writeWord(0, 0, 0, 'not a cb'), /Invalid callback/, 'writeWord');
|
||||
|
||||
// writeWordSync(addr, cmd, word)
|
||||
assert.throws(_ => i2c1.writeWordSync('not an addr', 0, 0), /Invalid I2C address/, 'writeWordSync');
|
||||
assert.throws(_ => i2c1.writeWordSync(-1, 0, 0), /Invalid I2C address/, 'writeWordSync');
|
||||
assert.throws(_ => i2c1.writeWordSync(128, 0, 0), /Invalid I2C address/, 'writeWordSync');
|
||||
|
||||
assert.throws(_ => i2c1.writeWordSync(0, 'not a command', 0), /Invalid I2C command/, 'writeWordSync');
|
||||
assert.throws(_ => i2c1.writeWordSync(0, -1, 0), /Invalid I2C command/, 'writeWordSync');
|
||||
assert.throws(_ => i2c1.writeWordSync(0, 256, 0), /Invalid I2C command/, 'writeWordSync');
|
||||
|
||||
assert.throws(_ => i2c1.writeWordSync(0, 0, 'not a word'), /Invalid word/, 'writeWordSync');
|
||||
assert.throws(_ => i2c1.writeWordSync(0, 0, -1), /Invalid word/, 'writeWordSync');
|
||||
assert.throws(_ => i2c1.writeWordSync(0, 0, 0xffff+1), /Invalid word/, 'writeWordSync');
|
||||
|
||||
// writeQuick(addr, bit, cb)
|
||||
assert.throws(_ => i2c1.writeQuick('not an addr', 0, _ => {}), /Invalid I2C address/, 'writeQuick');
|
||||
assert.throws(_ => i2c1.writeQuick(-1, 0, _ => {}), /Invalid I2C address/, 'writeQuick');
|
||||
assert.throws(_ => i2c1.writeQuick(128, 0, _ => {}), /Invalid I2C address/, 'writeQuick');
|
||||
|
||||
assert.throws(_ => i2c1.writeQuick(0, 'not a word', _ => {}), /Invalid bit/, 'writeQuick');
|
||||
assert.throws(_ => i2c1.writeQuick(0, -1, _ => {}), /Invalid bit/, 'writeQuick');
|
||||
assert.throws(_ => i2c1.writeQuick(0, 2, _ => {}), /Invalid bit/, 'writeQuick');
|
||||
|
||||
assert.throws(_ => i2c1.writeQuick(0, 0, 'not a cb'), /Invalid callback/, 'writeQuick');
|
||||
|
||||
// writeQuickSync(addr, bit)
|
||||
assert.throws(_ => i2c1.writeQuickSync('not an addr', 0), /Invalid I2C address/, 'writeQuickSync');
|
||||
assert.throws(_ => i2c1.writeQuickSync(-1, 0), /Invalid I2C address/, 'writeQuickSync');
|
||||
assert.throws(_ => i2c1.writeQuickSync(128, 0), /Invalid I2C address/, 'writeQuickSync');
|
||||
|
||||
assert.throws(_ => i2c1.writeQuickSync(0, 'not a word'), /Invalid bit/, 'writeQuickSync');
|
||||
assert.throws(_ => i2c1.writeQuickSync(0, -1), /Invalid bit/, 'writeQuickSync');
|
||||
assert.throws(_ => i2c1.writeQuickSync(0, 2), /Invalid bit/, 'writeQuickSync');
|
||||
|
||||
// writeI2cBlock(addr, cmd, length, buffer, cb)
|
||||
assert.throws(_ => i2c1.writeI2cBlock('not an addr', 0, 10, Buffer.alloc(10), _ => {}), /Invalid I2C address/, 'writeI2cBlock');
|
||||
assert.throws(_ => i2c1.writeI2cBlock(-1, 0, 10, Buffer.alloc(10), _ => {}), /Invalid I2C address/, 'writeI2cBlock');
|
||||
assert.throws(_ => i2c1.writeI2cBlock(128, 0, 10, Buffer.alloc(10), _ => {}), /Invalid I2C address/, 'writeI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.writeI2cBlock(0, 'not a command', 10, Buffer.alloc(10), _ => {}), /Invalid I2C command/, 'writeI2cBlock');
|
||||
assert.throws(_ => i2c1.writeI2cBlock(0, -1, 10, Buffer.alloc(10), _ => {}), /Invalid I2C command/, 'writeI2cBlock');
|
||||
assert.throws(_ => i2c1.writeI2cBlock(0, 256, 10, Buffer.alloc(10), _ => {}), /Invalid I2C command/, 'writeI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.writeI2cBlock(0, 0, 'not a length', Buffer.alloc(10), _ => {}), /Invalid buffer length/, 'writeI2cBlock');
|
||||
assert.throws(_ => i2c1.writeI2cBlock(0, 0, -1, Buffer.alloc(10), _ => {}), /Invalid buffer length/, 'writeI2cBlock');
|
||||
assert.throws(_ => i2c1.writeI2cBlock(0, 0, 33, Buffer.alloc(33), _ => {}), /Invalid buffer length/, 'writeI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.writeI2cBlock(0, 0, 10, 'not a buffer', _ => {}), /Invalid buffer/, 'writeI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.writeI2cBlock(0, 0, 11, Buffer.alloc(10), _ => {}), /Buffer must contain at least/, 'writeI2cBlock');
|
||||
|
||||
assert.throws(_ => i2c1.writeI2cBlock(0, 0, 10, Buffer.alloc(10), 'not a cb'), /Invalid callback/, 'writeI2cBlock');
|
||||
|
||||
// writeI2cBlockSync(addr, cmd, length, buffer)
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync('not an addr', 0, 10, Buffer.alloc(10)), /Invalid I2C address/, 'writeI2cBlockSync');
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(-1, 0, 10, Buffer.alloc(10)), /Invalid I2C address/, 'writeI2cBlockSync');
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(128, 0, 10, Buffer.alloc(10)), /Invalid I2C address/, 'writeI2cBlockSync');
|
||||
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(0, 'not a command', 10, Buffer.alloc(10)), /Invalid I2C command/, 'writeI2cBlockSync');
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(0, -1, 10, Buffer.alloc(10)), /Invalid I2C command/, 'writeI2cBlockSync');
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(0, 256, 10, Buffer.alloc(10)), /Invalid I2C command/, 'writeI2cBlockSync');
|
||||
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(0, 0, 'not a length', Buffer.alloc(10)), /Invalid buffer length/, 'writeI2cBlockSync');
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(0, 0, -1, Buffer.alloc(10)), /Invalid buffer length/, 'writeI2cBlockSync');
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(0, 0, 33, Buffer.alloc(33)), /Invalid buffer length/, 'writeI2cBlockSync');
|
||||
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(0, 0, 10, 'not a buffer'), /Invalid buffer/, 'writeI2cBlockSync');
|
||||
|
||||
assert.throws(_ => i2c1.writeI2cBlockSync(0, 0, 11, Buffer.alloc(10)), /Buffer must contain at least/, 'writeI2cBlockSync');
|
||||
|
||||
console.log('ok - errors');
|
||||
|
||||
11
node_modules/i2c-bus/integration-test/i2c-functionality-available.js
generated
vendored
Normal file
11
node_modules/i2c-bus/integration-test/i2c-functionality-available.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
const i2c1 = i2c.openSync(1);
|
||||
const i2cfuncs = i2c1.i2cFuncsSync();
|
||||
const platform = i2cfuncs.smbusQuick ? 'Raspberry Pi?' : 'BeagleBone?';
|
||||
|
||||
i2c1.closeSync();
|
||||
|
||||
console.log('ok - i2c-functionality-available - ' + platform);
|
||||
|
||||
14
node_modules/i2c-bus/integration-test/run-tests
generated
vendored
Executable file
14
node_modules/i2c-bus/integration-test/run-tests
generated
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
node async
|
||||
node async-performance
|
||||
node async-promise
|
||||
node async-promise-performance
|
||||
node busses
|
||||
node errors
|
||||
node i2c-functionality-available
|
||||
node scan
|
||||
node sync
|
||||
node sync-many-instances
|
||||
node sync-performance
|
||||
node sync-plain-i2c-performance
|
||||
|
||||
27
node_modules/i2c-bus/integration-test/scan-leak-check.js
generated
vendored
Normal file
27
node_modules/i2c-bus/integration-test/scan-leak-check.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
const lodash = require('lodash');
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
|
||||
const bus = i2c.openSync(1);
|
||||
let count = 0;
|
||||
|
||||
const next = _ => {
|
||||
const addresses = bus.scanSync();
|
||||
|
||||
bus.scan((err, devices) => {
|
||||
assert(!err, 'can\'t scan for devices');
|
||||
assert(lodash.isEqual(addresses, devices), 'sync and async scan differ');
|
||||
|
||||
count += 1;
|
||||
if (count % 10 === 0) {
|
||||
console.log(count);
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
next();
|
||||
|
||||
82
node_modules/i2c-bus/integration-test/scan.js
generated
vendored
Normal file
82
node_modules/i2c-bus/integration-test/scan.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
'use strict';
|
||||
|
||||
const lodash = require('lodash');
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
|
||||
const TSL2561_ADDR = 0x39;
|
||||
const DS1621_ADDR = 0x48;
|
||||
|
||||
const bus = i2c.openSync(1);
|
||||
|
||||
const scanSyncRange = _ => {
|
||||
const devices = bus.scanSync(TSL2561_ADDR, DS1621_ADDR);
|
||||
|
||||
assert(devices.length === 2, 'expected 2 devices');
|
||||
assert(
|
||||
devices[0] === TSL2561_ADDR,
|
||||
'expected device at address 0x' + TSL2561_ADDR.toString(16)
|
||||
);
|
||||
assert(
|
||||
devices[1] === DS1621_ADDR,
|
||||
'expected device at address 0x' + DS1621_ADDR.toString(16)
|
||||
);
|
||||
|
||||
console.log('ok - scan');
|
||||
};
|
||||
|
||||
const scanSyncForSingleDevice = _ => {
|
||||
const devices = bus.scanSync(DS1621_ADDR);
|
||||
|
||||
assert(devices.length === 1, 'expected 1 device');
|
||||
assert(
|
||||
devices[0] === DS1621_ADDR,
|
||||
'expected device at address 0x' + DS1621_ADDR.toString(16)
|
||||
);
|
||||
|
||||
scanSyncRange();
|
||||
};
|
||||
|
||||
const scanRange = _ => {
|
||||
bus.scan(TSL2561_ADDR, DS1621_ADDR, (err, devices) => {
|
||||
assert(!err, 'can\'t scan range');
|
||||
assert(devices.length === 2, 'expected 2 devices');
|
||||
assert(
|
||||
devices[0] === TSL2561_ADDR,
|
||||
'expected device at address 0x' + TSL2561_ADDR.toString(16)
|
||||
);
|
||||
assert(
|
||||
devices[1] === DS1621_ADDR,
|
||||
'expected device at address 0x' + DS1621_ADDR.toString(16)
|
||||
);
|
||||
|
||||
scanSyncForSingleDevice();
|
||||
});
|
||||
};
|
||||
|
||||
const scanForSingleDevice = _ => {
|
||||
bus.scan(DS1621_ADDR, (err, devices) => {
|
||||
assert(!err, 'can\'t scan for single device');
|
||||
assert(devices.length === 1, 'expected 1 device');
|
||||
assert(
|
||||
devices[0] === DS1621_ADDR,
|
||||
'expected device at address 0x' + DS1621_ADDR.toString(16)
|
||||
);
|
||||
|
||||
scanRange();
|
||||
});
|
||||
};
|
||||
|
||||
const scanDefaultRange = _ => {
|
||||
const addresses = bus.scanSync();
|
||||
|
||||
bus.scan((err, devices) => {
|
||||
assert(!err, 'can\'t scan default range');
|
||||
assert(lodash.isEqual(addresses, devices), 'sync and async scan differ');
|
||||
|
||||
scanForSingleDevice();
|
||||
});
|
||||
};
|
||||
|
||||
scanDefaultRange();
|
||||
|
||||
21
node_modules/i2c-bus/integration-test/sync-brute-force-leak-check.js
generated
vendored
Normal file
21
node_modules/i2c-bus/integration-test/sync-brute-force-leak-check.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
const i2c1 = i2c.openSync(1);
|
||||
|
||||
for (let i = 1; i <= 1000000; i += 1) {
|
||||
const tlbuf = Buffer.alloc(1000000);
|
||||
const bytesRead = i2c1.readI2cBlockSync(DS1621_ADDR, CMD_ACCESS_TL, 2, tlbuf);
|
||||
assert.strictEqual(bytesRead, 2, 'expected readI2cBlockSync to read 2 bytes');
|
||||
if (i % 1000 === 0) {
|
||||
console.log(i);
|
||||
}
|
||||
}
|
||||
|
||||
i2c1.closeSync();
|
||||
|
||||
26
node_modules/i2c-bus/integration-test/sync-deviceid.js
generated
vendored
Normal file
26
node_modules/i2c-bus/integration-test/sync-deviceid.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const address = 0x50;
|
||||
const invalid = 0x42;
|
||||
|
||||
const readDeviceId = _ => {
|
||||
const i2c1 = i2c.openSync(42);
|
||||
const id = i2c1.deviceIdSync(address);
|
||||
|
||||
console.log('id for address', '0x' + address.toString(16), id);
|
||||
|
||||
//
|
||||
try {
|
||||
i2c1.deviceIdSync(invalid);
|
||||
} catch(e) {
|
||||
i2c1.closeSync();
|
||||
return;
|
||||
}
|
||||
|
||||
throw Error('should have exited though catch');
|
||||
};
|
||||
|
||||
readDeviceId();
|
||||
|
||||
51
node_modules/i2c-bus/integration-test/sync-many-instances.js
generated
vendored
Normal file
51
node_modules/i2c-bus/integration-test/sync-many-instances.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const DS1621_CMD_ACCESS_TH = 0xa1;
|
||||
const DS1621_CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
const TSL2561_ADDR = 0x39;
|
||||
const TSL2561_CMD = 0x80;
|
||||
const TSL2561_REG_ID = 0x0a;
|
||||
|
||||
const useBusMoreThanMaxFdTimes = _ => {
|
||||
// Assuming that less than 2000 files can be opened at the same time,
|
||||
// open and close /dev/i2c-1 2000 times to make sure it works and to ensure
|
||||
// that file descriptors are being freed.
|
||||
for (let i = 1; i <= 2000; i += 1) {
|
||||
const i2c1 = i2c.openSync(1);
|
||||
i2c1.readWordSync(DS1621_ADDR, DS1621_CMD_ACCESS_TL);
|
||||
i2c1.closeSync();
|
||||
}
|
||||
};
|
||||
|
||||
const useMultipleObjectsForSameBusConcurrently = _ => {
|
||||
const buses = [];
|
||||
|
||||
// Make sure many Bus objects can be opened and used for the same I2C bus at
|
||||
// the same time.
|
||||
for (let i = 1; i <= 128; i += 1) {
|
||||
buses.push(i2c.openSync(1));
|
||||
}
|
||||
buses.forEach(bus => bus.readWordSync(DS1621_ADDR, DS1621_CMD_ACCESS_TL));
|
||||
buses.forEach(bus => bus.closeSync());
|
||||
};
|
||||
|
||||
const useTwoObjectsForSameBusConcurrently = _ => {
|
||||
const ds1621 = i2c.openSync(1);
|
||||
const tsl2561 = i2c.openSync(1);
|
||||
const ds1621TempHigh = ds1621.readWordSync(DS1621_ADDR, DS1621_CMD_ACCESS_TH);
|
||||
const tsl2561Id = tsl2561.readByteSync(TSL2561_ADDR, TSL2561_CMD | TSL2561_REG_ID);
|
||||
|
||||
console.log(' ds1621TempHigh: ' + ds1621TempHigh);
|
||||
console.log(' tsl2561Id: ' + tsl2561Id);
|
||||
};
|
||||
|
||||
useBusMoreThanMaxFdTimes();
|
||||
useMultipleObjectsForSameBusConcurrently();
|
||||
useTwoObjectsForSameBusConcurrently();
|
||||
|
||||
console.log('ok - sync-many-instances');
|
||||
|
||||
24
node_modules/i2c-bus/integration-test/sync-performance.js
generated
vendored
Normal file
24
node_modules/i2c-bus/integration-test/sync-performance.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const ITERATIONS = 5000;
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
const i2c1 = i2c.openSync(1);
|
||||
|
||||
let time = process.hrtime();
|
||||
|
||||
for (let reads = 1; reads <= ITERATIONS; reads += 1) {
|
||||
i2c1.readWordSync(DS1621_ADDR, CMD_ACCESS_TL);
|
||||
}
|
||||
|
||||
time = process.hrtime(time);
|
||||
const readsPerSec = Math.floor(ITERATIONS / (time[0] + time[1] / 1E9));
|
||||
|
||||
i2c1.closeSync();
|
||||
|
||||
console.log('ok - sync-performance - ' + readsPerSec + ' reads per second');
|
||||
|
||||
28
node_modules/i2c-bus/integration-test/sync-plain-i2c-performance.js
generated
vendored
Normal file
28
node_modules/i2c-bus/integration-test/sync-plain-i2c-performance.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
const i2c = require('../');
|
||||
|
||||
const ITERATIONS = 5000;
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
const i2c1 = i2c.openSync(1);
|
||||
const cmdGetTL = Buffer.from([CMD_ACCESS_TL]);
|
||||
const tl = Buffer.alloc(2);
|
||||
|
||||
let time = process.hrtime();
|
||||
|
||||
// one operation is an i2cWriteSync and an i2cReadSync, i.e., two calls
|
||||
for (let operations = 1; operations <= ITERATIONS; operations += 1) {
|
||||
i2c1.i2cWriteSync(DS1621_ADDR, cmdGetTL.length, cmdGetTL);
|
||||
i2c1.i2cReadSync(DS1621_ADDR, 2, tl);
|
||||
}
|
||||
|
||||
time = process.hrtime(time);
|
||||
const opsPerSec = Math.floor(ITERATIONS / (time[0] + time[1] / 1E9));
|
||||
|
||||
i2c1.closeSync();
|
||||
|
||||
console.log('ok - sync-plain-i2c-performance - ' + opsPerSec + ' (x 2) operations per second');
|
||||
|
||||
103
node_modules/i2c-bus/integration-test/sync.js
generated
vendored
Normal file
103
node_modules/i2c-bus/integration-test/sync.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const i2c = require('../');
|
||||
|
||||
const DS1621_ADDR = 0x48;
|
||||
const CMD_ACCESS_CONFIG = 0xac;
|
||||
const CMD_ACCESS_TL = 0xa2;
|
||||
|
||||
const i2c1 = i2c.openSync(1);
|
||||
|
||||
// Wait while non volatile memory busy
|
||||
const waitForWrite = _ => {
|
||||
while (i2c1.readByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG) & 0x10) {
|
||||
}
|
||||
};
|
||||
|
||||
// Test writeByteSync & readByteSync
|
||||
// Enter one shot mode and verify that one shot mode has been entered
|
||||
const readWriteByte = _ => {
|
||||
const self = i2c1.writeByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG, 0x01);
|
||||
assert.strictEqual(self, i2c1, 'expected writeByteSync to return this');
|
||||
waitForWrite();
|
||||
const config = i2c1.readByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG);
|
||||
assert(typeof config === 'number' && config <= 0xff, 'expeted readByteSync to read a byte');
|
||||
assert.strictEqual(config & 0x1, 1, 'one shot mode not eneterd');
|
||||
};
|
||||
|
||||
// Test sendByteSync & receiveByteSync
|
||||
// Read config using different techniques and verify that 1st and 2nd read
|
||||
// are identical
|
||||
const sendReceiveByte = _ => {
|
||||
const expectedConfig = i2c1.readByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG);
|
||||
assert(typeof expectedConfig === 'number' && expectedConfig <= 0xff, 'expeted readByteSync to read a byte');
|
||||
|
||||
const self = i2c1.sendByteSync(DS1621_ADDR, CMD_ACCESS_CONFIG);
|
||||
assert.strictEqual(self, i2c1, 'expected sendByteSync to return this');
|
||||
|
||||
const config = i2c1.receiveByteSync(DS1621_ADDR);
|
||||
assert(typeof config === 'number' && config <= 0xff, 'expeted receiveByteSync to receive a byte');
|
||||
assert.strictEqual(config, expectedConfig, '1st and 2nd config read differ');
|
||||
};
|
||||
|
||||
// Test writeWordSync & readWordSync
|
||||
// Change value of tl and verify that tl has been changed
|
||||
const readWriteWord = _ => {
|
||||
const oldtl = i2c1.readWordSync(DS1621_ADDR, CMD_ACCESS_TL);
|
||||
assert(typeof oldtl === 'number' && oldtl <= 0xffff, 'expeted readWordSync to read a word');
|
||||
|
||||
const tl = (oldtl === 24 ? 23 : 24);
|
||||
|
||||
const self = i2c1.writeWordSync(DS1621_ADDR, CMD_ACCESS_TL, tl);
|
||||
assert.strictEqual(self, i2c1, 'expected writeWordSync to return this');
|
||||
waitForWrite();
|
||||
|
||||
const newtl = i2c1.readWordSync(DS1621_ADDR, CMD_ACCESS_TL);
|
||||
assert(typeof newtl === 'number' && newtl <= 0xffff, 'expeted readWordSync to read a word');
|
||||
assert.strictEqual(tl, newtl, 'expected to read word written');
|
||||
};
|
||||
|
||||
// Test writeI2cBlockSync & readI2cBlockSync
|
||||
// Change value of tl to 22 and verify that tl has been changed
|
||||
const readWriteI2cBlock = _ => {
|
||||
const tlbuf = Buffer.alloc(10);
|
||||
tlbuf.writeUInt16LE(22, 0);
|
||||
const self = i2c1.writeI2cBlockSync(DS1621_ADDR, CMD_ACCESS_TL, 2, tlbuf);
|
||||
assert.strictEqual(self, i2c1, 'expected writeI2cBlockSync to return this');
|
||||
waitForWrite();
|
||||
|
||||
const newtl = Buffer.alloc(10);
|
||||
const bytesRead = i2c1.readI2cBlockSync(DS1621_ADDR, CMD_ACCESS_TL, 2, newtl);
|
||||
assert.strictEqual(bytesRead, 2, 'expected readI2cBlockSync to read 2 bytes');
|
||||
assert.strictEqual(newtl.readUInt16LE(0), 22, 'expected readI2cBlockSync to read value 22');
|
||||
};
|
||||
|
||||
// Test i2cWriteSync & i2cReadSync
|
||||
// Change value of tl to 25 and verify that tl has been changed
|
||||
const i2cPlainReadWrite = _ => {
|
||||
const cmdSetTL = Buffer.from([CMD_ACCESS_TL, 25, 0]);
|
||||
let bytesWritten = i2c1.i2cWriteSync(DS1621_ADDR, cmdSetTL.length, cmdSetTL);
|
||||
assert.strictEqual(bytesWritten, 3, 'expected i2cWriteSync to write 3 bytes');
|
||||
waitForWrite();
|
||||
|
||||
const cmdGetTL = Buffer.from([CMD_ACCESS_TL]);
|
||||
bytesWritten = i2c1.i2cWriteSync(DS1621_ADDR, cmdGetTL.length, cmdGetTL);
|
||||
assert.strictEqual(bytesWritten, 1, 'expected i2cWriteSync to write 1 byte');
|
||||
|
||||
const tl = Buffer.alloc(2);
|
||||
const bytesRead = i2c1.i2cReadSync(DS1621_ADDR, 2, tl);
|
||||
assert.strictEqual(bytesRead, 2, 'expected i2cReadSync to read 2 bytes');
|
||||
assert.strictEqual(tl.readUInt16LE(0), 25, 'expected i2cReadSync to read value 25');
|
||||
};
|
||||
|
||||
readWriteByte();
|
||||
sendReceiveByte();
|
||||
readWriteWord();
|
||||
readWriteI2cBlock();
|
||||
i2cPlainReadWrite();
|
||||
|
||||
i2c1.closeSync();
|
||||
|
||||
console.log('ok - sync');
|
||||
|
||||
55
node_modules/i2c-bus/package.json
generated
vendored
Normal file
55
node_modules/i2c-bus/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "i2c-bus",
|
||||
"version": "5.2.3",
|
||||
"description": "I2C serial bus access with Node.js",
|
||||
"main": "i2c-bus.js",
|
||||
"directories": {
|
||||
"example": "example",
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage-report": "nyc report --reporter=html",
|
||||
"coveralls": "nyc report --reporter=text-lcov | coveralls",
|
||||
"install": "node-gyp rebuild",
|
||||
"integration-test": "cd integration-test && ./run-tests && cd ..",
|
||||
"lint": "jshint i2c-bus.js example/*.js integration-test/*.js test/*.js test/*/*.js",
|
||||
"test": "nyc mocha"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fivdi/i2c-bus.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.17.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"async": "^3.2.4",
|
||||
"coveralls": "^3.1.1",
|
||||
"glob": "^10.3.3",
|
||||
"jshint": "^2.13.6",
|
||||
"lodash": "^4.17.21",
|
||||
"mocha": "^10.2.0",
|
||||
"mock-fs": "^5.2.0",
|
||||
"mock-require": "^3.0.3",
|
||||
"nyc": "^15.1.0",
|
||||
"sinon": "^15.2.0"
|
||||
},
|
||||
"keywords": [
|
||||
"i2c",
|
||||
"iot",
|
||||
"raspberry",
|
||||
"raspi",
|
||||
"rpi",
|
||||
"pi",
|
||||
"beaglebone",
|
||||
"smbus",
|
||||
"linux"
|
||||
],
|
||||
"author": "fivdi",
|
||||
"license": "MIT",
|
||||
"gypfile": true
|
||||
}
|
||||
72
node_modules/i2c-bus/src/deviceid.cc
generated
vendored
Normal file
72
node_modules/i2c-bus/src/deviceid.cc
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./deviceid.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 DeviceId(int fd, __u16 address) {
|
||||
return i2c_smbus_deviceid(fd, address);
|
||||
}
|
||||
|
||||
class DeviceIdWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
DeviceIdWorker(Nan::Callback *callback, int fd, __u16 address)
|
||||
: I2cAsyncWorker(callback), fd(fd), address(address) {}
|
||||
~DeviceIdWorker() {}
|
||||
|
||||
void Execute() {
|
||||
id = DeviceId(fd, address);
|
||||
if (id == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("deviceId");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null(),
|
||||
Nan::New<v8::Integer>(id)
|
||||
};
|
||||
|
||||
callback->Call(2, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u16 address;
|
||||
__s32 id;
|
||||
};
|
||||
|
||||
NAN_METHOD(DeviceIdAsync) {
|
||||
if (info.Length() < 3 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "deviceId",
|
||||
"incorrect arguments passed to deviceId(int fd, int address, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u16 address = Nan::To<int32_t>(info[1]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new DeviceIdWorker(callback, fd, address));
|
||||
}
|
||||
|
||||
NAN_METHOD(DeviceIdSync) {
|
||||
if (info.Length() < 2 || !info[0]->IsInt32() || !info[1]->IsInt32()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "deviceIdSync",
|
||||
"incorrect arguments passed to deviceIdSync(int fd, int address)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u16 address = Nan::To<int32_t>(info[1]).FromJust();
|
||||
|
||||
__s32 ret = DeviceId(fd, address);
|
||||
if (ret == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "deviceIdSync", ""));
|
||||
}
|
||||
|
||||
info.GetReturnValue().Set(Nan::New<v8::Integer>(ret));
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/deviceid.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/deviceid.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_DEVICEID_H_
|
||||
#define I2C_BUS_DEVICEID_H_
|
||||
NAN_METHOD(DeviceIdAsync);
|
||||
NAN_METHOD(DeviceIdSync);
|
||||
#endif // I2C_BUS_DEVICEID_H_
|
||||
|
||||
364
node_modules/i2c-bus/src/i2c-dev.h
generated
vendored
Normal file
364
node_modules/i2c-bus/src/i2c-dev.h
generated
vendored
Normal file
@@ -0,0 +1,364 @@
|
||||
/*
|
||||
i2c-dev.h - i2c-bus driver, char device interface
|
||||
|
||||
Copyright (C) 1995-97 Simon G. Vogl
|
||||
Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_I2C_DEV_H
|
||||
#define _LINUX_I2C_DEV_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
/* -- i2c.h -- */
|
||||
|
||||
|
||||
/*
|
||||
* I2C Message - used for pure i2c transaction, also from /dev interface
|
||||
*/
|
||||
struct i2c_msg {
|
||||
__u16 addr; /* slave address */
|
||||
unsigned short flags;
|
||||
#define I2C_M_TEN 0x10 /* we have a ten bit chip address */
|
||||
#define I2C_M_RD 0x01
|
||||
#define I2C_M_NOSTART 0x4000
|
||||
#define I2C_M_REV_DIR_ADDR 0x2000
|
||||
#define I2C_M_IGNORE_NAK 0x1000
|
||||
#define I2C_M_NO_RD_ACK 0x0800
|
||||
short len; /* msg length */
|
||||
char *buf; /* pointer to msg data */
|
||||
};
|
||||
|
||||
/* To determine what functionality is present */
|
||||
|
||||
#define I2C_FUNC_I2C 0x00000001
|
||||
#define I2C_FUNC_10BIT_ADDR 0x00000002
|
||||
#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
|
||||
#define I2C_FUNC_SMBUS_PEC 0x00000008
|
||||
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
|
||||
#define I2C_FUNC_SMBUS_QUICK 0x00010000
|
||||
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
|
||||
#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
|
||||
#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
|
||||
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
|
||||
#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
|
||||
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
|
||||
#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
|
||||
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
|
||||
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
|
||||
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
|
||||
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
|
||||
|
||||
#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
|
||||
I2C_FUNC_SMBUS_WRITE_BYTE)
|
||||
#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
|
||||
I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
|
||||
#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
|
||||
I2C_FUNC_SMBUS_WRITE_WORD_DATA)
|
||||
#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
|
||||
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
|
||||
#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
|
||||
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
|
||||
|
||||
/* Old name, for compatibility */
|
||||
#define I2C_FUNC_SMBUS_HWPEC_CALC I2C_FUNC_SMBUS_PEC
|
||||
|
||||
/*
|
||||
* Data for SMBus Messages
|
||||
*/
|
||||
#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
|
||||
#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */
|
||||
union i2c_smbus_data {
|
||||
__u8 byte;
|
||||
__u16 word;
|
||||
__u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
|
||||
/* and one more for PEC */
|
||||
};
|
||||
|
||||
/* smbus_access read or write markers */
|
||||
#define I2C_SMBUS_READ 1
|
||||
#define I2C_SMBUS_WRITE 0
|
||||
|
||||
/* SMBus transaction types (size parameter in the above functions)
|
||||
Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
|
||||
#define I2C_SMBUS_QUICK 0
|
||||
#define I2C_SMBUS_BYTE 1
|
||||
#define I2C_SMBUS_BYTE_DATA 2
|
||||
#define I2C_SMBUS_WORD_DATA 3
|
||||
#define I2C_SMBUS_PROC_CALL 4
|
||||
#define I2C_SMBUS_BLOCK_DATA 5
|
||||
#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
|
||||
#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
|
||||
#define I2C_SMBUS_I2C_BLOCK_DATA 8
|
||||
|
||||
|
||||
/* /dev/i2c-X ioctl commands. The ioctl's parameter is always an
|
||||
* unsigned long, except for:
|
||||
* - I2C_FUNCS, takes pointer to an unsigned long
|
||||
* - I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data
|
||||
* - I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data
|
||||
*/
|
||||
#define I2C_RETRIES 0x0701 /* number of times a device address should
|
||||
be polled when not acknowledging */
|
||||
#define I2C_TIMEOUT 0x0702 /* set timeout in units of 10 ms */
|
||||
|
||||
/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
|
||||
* are NOT supported! (due to code brokenness)
|
||||
*/
|
||||
#define I2C_SLAVE 0x0703 /* Use this slave address */
|
||||
#define I2C_SLAVE_FORCE 0x0706 /* Use this slave address, even if it
|
||||
is already in use by a driver! */
|
||||
#define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */
|
||||
|
||||
#define I2C_FUNCS 0x0705 /* Get the adapter functionality mask */
|
||||
|
||||
#define I2C_RDWR 0x0707 /* Combined R/W transfer (one STOP only) */
|
||||
|
||||
#define I2C_PEC 0x0708 /* != 0 to use PEC with SMBus */
|
||||
#define I2C_SMBUS 0x0720 /* SMBus transfer */
|
||||
|
||||
|
||||
/* This is the structure as used in the I2C_SMBUS ioctl call */
|
||||
struct i2c_smbus_ioctl_data {
|
||||
__u8 read_write;
|
||||
__u8 command;
|
||||
__u32 size;
|
||||
union i2c_smbus_data *data;
|
||||
};
|
||||
|
||||
/* This is the structure as used in the I2C_RDWR ioctl call */
|
||||
struct i2c_rdwr_ioctl_data {
|
||||
struct i2c_msg *msgs; /* pointers to i2c_msgs */
|
||||
__u32 nmsgs; /* number of i2c_msgs */
|
||||
};
|
||||
|
||||
#define I2C_RDRW_IOCTL_MAX_MSGS 42
|
||||
|
||||
|
||||
static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
|
||||
int size, union i2c_smbus_data *data)
|
||||
{
|
||||
struct i2c_smbus_ioctl_data args;
|
||||
|
||||
args.read_write = read_write;
|
||||
args.command = command;
|
||||
args.size = size;
|
||||
args.data = data;
|
||||
return ioctl(file,I2C_SMBUS,&args);
|
||||
}
|
||||
|
||||
#define I2C_RESERVED_DEVICE_ID_ADDRESS 0x7C
|
||||
#define I2C_DEVICE_ID_LENGTH 3
|
||||
|
||||
static inline __s32 i2c_smbus_deviceid(int file, __u16 address)
|
||||
{
|
||||
struct i2c_rdwr_ioctl_data rdwr_data;
|
||||
char out[I2C_DEVICE_ID_LENGTH];
|
||||
struct i2c_msg parts[2];
|
||||
|
||||
// dump into char and shift up to account for R/W bit
|
||||
char addr = address << 1;
|
||||
|
||||
// pack messages parts
|
||||
parts[0].addr = I2C_RESERVED_DEVICE_ID_ADDRESS;
|
||||
parts[0].flags = 0;
|
||||
parts[0].len = 1;
|
||||
parts[0].buf = &addr;
|
||||
|
||||
parts[1].addr = I2C_RESERVED_DEVICE_ID_ADDRESS;
|
||||
parts[1].flags = I2C_M_RD;
|
||||
parts[1].len = I2C_DEVICE_ID_LENGTH;
|
||||
parts[1].buf = out;
|
||||
|
||||
rdwr_data.msgs = parts;
|
||||
rdwr_data.nmsgs = 2;
|
||||
|
||||
__s32 ret = ioctl(file,I2C_RDWR,&rdwr_data);
|
||||
if(ret < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
// shift bytes into single 24bit int
|
||||
return out[0] << 16 | out[1] << 8 | out[2];
|
||||
}
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_write_quick(int file, __u8 value)
|
||||
{
|
||||
return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_read_byte(int file)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data))
|
||||
return -1;
|
||||
else
|
||||
return 0x0FF & data.byte;
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_write_byte(int file, __u8 value)
|
||||
{
|
||||
return i2c_smbus_access(file,I2C_SMBUS_WRITE,value,
|
||||
I2C_SMBUS_BYTE,NULL);
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||
I2C_SMBUS_BYTE_DATA,&data))
|
||||
return -1;
|
||||
else
|
||||
return 0x0FF & data.byte;
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
|
||||
__u8 value)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
data.byte = value;
|
||||
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
I2C_SMBUS_BYTE_DATA, &data);
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||
I2C_SMBUS_WORD_DATA,&data))
|
||||
return -1;
|
||||
else
|
||||
return 0x0FFFF & data.word;
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_write_word_data(int file, __u8 command,
|
||||
__u16 value)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
data.word = value;
|
||||
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
I2C_SMBUS_WORD_DATA, &data);
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
data.word = value;
|
||||
if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
I2C_SMBUS_PROC_CALL,&data))
|
||||
return -1;
|
||||
else
|
||||
return 0x0FFFF & data.word;
|
||||
}
|
||||
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
static inline __s32 i2c_smbus_read_block_data(int file, __u8 command,
|
||||
__u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i;
|
||||
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||
I2C_SMBUS_BLOCK_DATA,&data))
|
||||
return -1;
|
||||
else {
|
||||
for (i = 1; i <= data.block[0]; i++)
|
||||
values[i-1] = data.block[i];
|
||||
return data.block[0];
|
||||
}
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_write_block_data(int file, __u8 command,
|
||||
__u8 length, const __u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i;
|
||||
if (length > 32)
|
||||
length = 32;
|
||||
for (i = 1; i <= length; i++)
|
||||
data.block[i] = values[i-1];
|
||||
data.block[0] = length;
|
||||
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
I2C_SMBUS_BLOCK_DATA, &data);
|
||||
}
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
|
||||
ask for less than 32 bytes, your code will only work with kernels
|
||||
2.6.23 and later. */
|
||||
static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,
|
||||
__u8 length, __u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i;
|
||||
|
||||
if (length > 32)
|
||||
length = 32;
|
||||
data.block[0] = length;
|
||||
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||
length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
|
||||
I2C_SMBUS_I2C_BLOCK_DATA,&data))
|
||||
return -1;
|
||||
else {
|
||||
for (i = 1; i <= data.block[0]; i++)
|
||||
values[i-1] = data.block[i];
|
||||
return data.block[0];
|
||||
}
|
||||
}
|
||||
|
||||
static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
|
||||
__u8 length,
|
||||
const __u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i;
|
||||
if (length > 32)
|
||||
length = 32;
|
||||
for (i = 1; i <= length; i++)
|
||||
data.block[i] = values[i-1];
|
||||
data.block[0] = length;
|
||||
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
I2C_SMBUS_I2C_BLOCK_BROKEN, &data);
|
||||
}
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
static inline __s32 i2c_smbus_block_process_call(int file, __u8 command,
|
||||
__u8 length, __u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i;
|
||||
if (length > 32)
|
||||
length = 32;
|
||||
for (i = 1; i <= length; i++)
|
||||
data.block[i] = values[i-1];
|
||||
data.block[0] = length;
|
||||
if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
I2C_SMBUS_BLOCK_PROC_CALL,&data))
|
||||
return -1;
|
||||
else {
|
||||
for (i = 1; i <= data.block[0]; i++)
|
||||
values[i-1] = data.block[i];
|
||||
return data.block[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* _LINUX_I2C_DEV_H */
|
||||
113
node_modules/i2c-bus/src/i2c.cc
generated
vendored
Normal file
113
node_modules/i2c-bus/src/i2c.cc
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2cfuncs.h"
|
||||
#include "./deviceid.h"
|
||||
#include "./readbyte.h"
|
||||
#include "./readword.h"
|
||||
#include "./readblock.h"
|
||||
#include "./readi2cblock.h"
|
||||
#include "./receivebyte.h"
|
||||
#include "./sendbyte.h"
|
||||
#include "./setaddr.h"
|
||||
#include "./writebyte.h"
|
||||
#include "./writeword.h"
|
||||
#include "./writeblock.h"
|
||||
#include "./writei2cblock.h"
|
||||
#include "./writequick.h"
|
||||
#include "./i2c-dev.h"
|
||||
|
||||
static void ExportInt(
|
||||
Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target,
|
||||
const char* name,
|
||||
int value
|
||||
) {
|
||||
Nan::Set(target,
|
||||
Nan::New<v8::String>(name).ToLocalChecked(),
|
||||
Nan::New<v8::Integer>(value)
|
||||
);
|
||||
}
|
||||
|
||||
NAN_MODULE_INIT(InitAll) {
|
||||
Nan::Export(target, "i2cFuncsAsync", I2cFuncsAsync);
|
||||
Nan::Export(target, "i2cFuncsSync", I2cFuncsSync);
|
||||
|
||||
Nan::Export(target, "deviceIdAsync", DeviceIdAsync);
|
||||
Nan::Export(target, "deviceIdSync", DeviceIdSync);
|
||||
|
||||
Nan::Export(target, "readByteAsync", ReadByteAsync);
|
||||
Nan::Export(target, "readByteSync", ReadByteSync);
|
||||
|
||||
Nan::Export(target, "readWordAsync", ReadWordAsync);
|
||||
Nan::Export(target, "readWordSync", ReadWordSync);
|
||||
|
||||
Nan::Export(target, "readBlockAsync", ReadBlockAsync);
|
||||
Nan::Export(target, "readBlockSync", ReadBlockSync);
|
||||
|
||||
Nan::Export(target, "readI2cBlockAsync", ReadI2cBlockAsync);
|
||||
Nan::Export(target, "readI2cBlockSync", ReadI2cBlockSync);
|
||||
|
||||
Nan::Export(target, "receiveByteAsync", ReceiveByteAsync);
|
||||
Nan::Export(target, "receiveByteSync", ReceiveByteSync);
|
||||
|
||||
Nan::Export(target, "sendByteAsync", SendByteAsync);
|
||||
Nan::Export(target, "sendByteSync", SendByteSync);
|
||||
|
||||
Nan::Export(target, "setAddrAsync", SetAddrAsync);
|
||||
Nan::Export(target, "setAddrSync", SetAddrSync);
|
||||
|
||||
Nan::Export(target, "writeByteAsync", WriteByteAsync);
|
||||
Nan::Export(target, "writeByteSync", WriteByteSync);
|
||||
|
||||
Nan::Export(target, "writeWordAsync", WriteWordAsync);
|
||||
Nan::Export(target, "writeWordSync", WriteWordSync);
|
||||
|
||||
Nan::Export(target, "writeBlockAsync", WriteBlockAsync);
|
||||
Nan::Export(target, "writeBlockSync", WriteBlockSync);
|
||||
|
||||
Nan::Export(target, "writeI2cBlockAsync", WriteI2cBlockAsync);
|
||||
Nan::Export(target, "writeI2cBlockSync", WriteI2cBlockSync);
|
||||
|
||||
Nan::Export(target, "writeQuickAsync", WriteQuickAsync);
|
||||
Nan::Export(target, "writeQuickSync", WriteQuickSync);
|
||||
|
||||
ExportInt(target, "I2C_FUNC_I2C", I2C_FUNC_I2C);
|
||||
ExportInt(target, "I2C_FUNC_10BIT_ADDR", I2C_FUNC_10BIT_ADDR);
|
||||
ExportInt(target, "I2C_FUNC_PROTOCOL_MANGLING", I2C_FUNC_PROTOCOL_MANGLING);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_PEC", I2C_FUNC_SMBUS_PEC);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_BLOCK_PROC_CALL", I2C_FUNC_SMBUS_BLOCK_PROC_CALL);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_QUICK", I2C_FUNC_SMBUS_QUICK);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_READ_BYTE", I2C_FUNC_SMBUS_READ_BYTE);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_WRITE_BYTE", I2C_FUNC_SMBUS_WRITE_BYTE);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_READ_BYTE_DATA", I2C_FUNC_SMBUS_READ_BYTE_DATA);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_WRITE_BYTE_DATA", I2C_FUNC_SMBUS_WRITE_BYTE_DATA);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_READ_WORD_DATA", I2C_FUNC_SMBUS_READ_WORD_DATA);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_WRITE_WORD_DATA", I2C_FUNC_SMBUS_WRITE_WORD_DATA);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_PROC_CALL", I2C_FUNC_SMBUS_PROC_CALL);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_READ_BLOCK_DATA", I2C_FUNC_SMBUS_READ_BLOCK_DATA);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_WRITE_BLOCK_DATA", I2C_FUNC_SMBUS_WRITE_BLOCK_DATA);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_READ_I2C_BLOCK", I2C_FUNC_SMBUS_READ_I2C_BLOCK);
|
||||
ExportInt(target, "I2C_FUNC_SMBUS_WRITE_I2C_BLOCK", I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
|
||||
}
|
||||
|
||||
NODE_MODULE(i2c, InitAll)
|
||||
|
||||
// Hack to speed up compilation.
|
||||
// Originally all the cc files included below were listed in the sources
|
||||
// section of binding.gyp. Including them here rather than compiling them
|
||||
// individually, which is what happens if they're listed in binding.gyp,
|
||||
// reduces the build time from 36s to 15s on a BBB.
|
||||
#include "./i2cfuncs.cc"
|
||||
#include "./deviceid.cc"
|
||||
#include "./readbyte.cc"
|
||||
#include "./readword.cc"
|
||||
#include "./readblock.cc"
|
||||
#include "./readi2cblock.cc"
|
||||
#include "./receivebyte.cc"
|
||||
#include "./sendbyte.cc"
|
||||
#include "./setaddr.cc"
|
||||
#include "./writebyte.cc"
|
||||
#include "./writeword.cc"
|
||||
#include "./writeblock.cc"
|
||||
#include "./writei2cblock.cc"
|
||||
#include "./writequick.cc"
|
||||
|
||||
70
node_modules/i2c-bus/src/i2cfuncs.cc
generated
vendored
Normal file
70
node_modules/i2c-bus/src/i2cfuncs.cc
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./i2cfuncs.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 I2cFuncs(int fd, unsigned long *i2cfuncs) {
|
||||
return ioctl(fd, I2C_FUNCS, i2cfuncs);
|
||||
}
|
||||
|
||||
class I2cFuncsWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
I2cFuncsWorker(Nan::Callback *callback, int fd)
|
||||
: I2cAsyncWorker(callback), fd(fd) {}
|
||||
~I2cFuncsWorker() {}
|
||||
|
||||
void Execute() {
|
||||
__s32 ret = I2cFuncs(fd, &i2cfuncs);
|
||||
if (ret == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("i2cFuncs");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null(),
|
||||
Nan::New<v8::Uint32>(static_cast<unsigned int>(i2cfuncs))
|
||||
};
|
||||
|
||||
callback->Call(2, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
unsigned long i2cfuncs;
|
||||
};
|
||||
|
||||
NAN_METHOD(I2cFuncsAsync) {
|
||||
if (info.Length() < 2 || !info[0]->IsInt32() || !info[1]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "i2cFuncs",
|
||||
"incorrect arguments passed to i2cFuncs(int fd, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[1].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new I2cFuncsWorker(callback, fd));
|
||||
}
|
||||
|
||||
NAN_METHOD(I2cFuncsSync) {
|
||||
if (info.Length() < 1 || !info[0]->IsInt32()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "i2cFuncsSync",
|
||||
"incorrect arguments passed to i2cFuncsSync(int fd)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
|
||||
unsigned long i2cfuncs;
|
||||
__s32 ret = I2cFuncs(fd, &i2cfuncs);
|
||||
if (ret == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "i2cFuncsSync", ""));
|
||||
}
|
||||
|
||||
info.GetReturnValue().Set(Nan::New<v8::Uint32>(static_cast<unsigned int>(i2cfuncs)));
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/i2cfuncs.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/i2cfuncs.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_I2CFUNCS_H_
|
||||
#define I2C_BUS_I2CFUNCS_H_
|
||||
NAN_METHOD(I2cFuncsAsync);
|
||||
NAN_METHOD(I2cFuncsSync);
|
||||
#endif // I2C_BUS_I2CFUNCS_H_
|
||||
|
||||
117
node_modules/i2c-bus/src/readblock.cc
generated
vendored
Normal file
117
node_modules/i2c-bus/src/readblock.cc
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./readblock.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 ReadBlock(int fd, __u8 cmd, __u8 *block) {
|
||||
return i2c_smbus_read_block_data(fd, cmd, block);
|
||||
}
|
||||
|
||||
class ReadBlockWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
ReadBlockWorker(
|
||||
Nan::Callback *callback,
|
||||
int fd,
|
||||
__u8 cmd,
|
||||
__u8* block,
|
||||
v8::Local<v8::Object> &bufferHandle
|
||||
) : I2cAsyncWorker(callback), fd(fd), cmd(cmd), block(block), bytesRead(0) {
|
||||
SaveToPersistent("buffer", bufferHandle);
|
||||
}
|
||||
|
||||
~ReadBlockWorker() {}
|
||||
|
||||
void Execute() {
|
||||
bytesRead = ReadBlock(fd, cmd, block);
|
||||
if (bytesRead == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("readBlock");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> bufferHandle = GetFromPersistent("buffer");
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null(),
|
||||
Nan::New<v8::Integer>(bytesRead),
|
||||
bufferHandle
|
||||
};
|
||||
|
||||
callback->Call(3, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 cmd;
|
||||
__u8* block;
|
||||
__s32 bytesRead;
|
||||
};
|
||||
|
||||
NAN_METHOD(ReadBlockAsync) {
|
||||
if (info.Length() < 4 ||
|
||||
!info[0]->IsInt32() ||
|
||||
!info[1]->IsInt32() ||
|
||||
!info[2]->IsObject() ||
|
||||
!info[3]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readBlock",
|
||||
"incorrect arguments passed to readBlock"
|
||||
"(int fd, int cmd, Buffer buffer, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
v8::Local<v8::Object> bufferHandle = info[2].As<v8::Object>();
|
||||
Nan::Callback *callback = new Nan::Callback(info[3].As<v8::Function>());
|
||||
|
||||
__u8* bufferData = (__u8*) node::Buffer::Data(bufferHandle);
|
||||
size_t bufferLength = node::Buffer::Length(bufferHandle);
|
||||
|
||||
if (bufferLength < 1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readBlock",
|
||||
"buffer passed to readBlock has no space for reading data"));
|
||||
}
|
||||
|
||||
Nan::AsyncQueueWorker(new ReadBlockWorker(
|
||||
callback,
|
||||
fd,
|
||||
cmd,
|
||||
bufferData,
|
||||
bufferHandle
|
||||
));
|
||||
}
|
||||
|
||||
NAN_METHOD(ReadBlockSync) {
|
||||
if (info.Length() < 3 ||
|
||||
!info[0]->IsInt32() ||
|
||||
!info[1]->IsInt32() ||
|
||||
!info[2]->IsObject()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readBlockSync",
|
||||
"incorrect arguments passed to readBlockSync"
|
||||
"(int fd, int cmd, Buffer buffer)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
v8::Local<v8::Object> bufferHandle = info[2].As<v8::Object>();
|
||||
|
||||
__u8* bufferData = (__u8*) node::Buffer::Data(bufferHandle);
|
||||
size_t bufferLength = node::Buffer::Length(bufferHandle);
|
||||
|
||||
if (bufferLength < 1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readBlockSync",
|
||||
"buffer passed to readBlockSync has no space for reading data"));
|
||||
}
|
||||
|
||||
__s32 bytesRead = ReadBlock(fd, cmd, bufferData);
|
||||
if (bytesRead == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "readBlockSync", ""));
|
||||
}
|
||||
|
||||
info.GetReturnValue().Set(Nan::New<v8::Integer>(bytesRead));
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/readblock.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/readblock.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_READBLOCK_H_
|
||||
#define I2C_BUS_READBLOCK_H_
|
||||
NAN_METHOD(ReadBlockAsync);
|
||||
NAN_METHOD(ReadBlockSync);
|
||||
#endif // I2C_BUS_READBLOCK_H_
|
||||
|
||||
72
node_modules/i2c-bus/src/readbyte.cc
generated
vendored
Normal file
72
node_modules/i2c-bus/src/readbyte.cc
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./readbyte.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 ReadByte(int fd, __u8 cmd) {
|
||||
return i2c_smbus_read_byte_data(fd, cmd);
|
||||
}
|
||||
|
||||
class ReadByteWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
ReadByteWorker(Nan::Callback *callback, int fd, __u8 cmd)
|
||||
: I2cAsyncWorker(callback), fd(fd), cmd(cmd) {}
|
||||
~ReadByteWorker() {}
|
||||
|
||||
void Execute() {
|
||||
byte = ReadByte(fd, cmd);
|
||||
if (byte == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("readByte");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null(),
|
||||
Nan::New<v8::Integer>(byte)
|
||||
};
|
||||
|
||||
callback->Call(2, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 cmd;
|
||||
__s32 byte;
|
||||
};
|
||||
|
||||
NAN_METHOD(ReadByteAsync) {
|
||||
if (info.Length() < 3 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readByte",
|
||||
"incorrect arguments passed to readByte(int fd, int cmd, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new ReadByteWorker(callback, fd, cmd));
|
||||
}
|
||||
|
||||
NAN_METHOD(ReadByteSync) {
|
||||
if (info.Length() < 2 || !info[0]->IsInt32() || !info[1]->IsInt32()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readByteSync",
|
||||
"incorrect arguments passed to readByteSync(int fd, int cmd)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
|
||||
__s32 byte = ReadByte(fd, cmd);
|
||||
if (byte == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "readByteSync", ""));
|
||||
}
|
||||
|
||||
info.GetReturnValue().Set(Nan::New<v8::Integer>(byte));
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/readbyte.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/readbyte.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_READBYTE_H_
|
||||
#define I2C_BUS_READBYTE_H_
|
||||
NAN_METHOD(ReadByteAsync);
|
||||
NAN_METHOD(ReadByteSync);
|
||||
#endif // I2C_BUS_READBYTE_H_
|
||||
|
||||
134
node_modules/i2c-bus/src/readi2cblock.cc
generated
vendored
Normal file
134
node_modules/i2c-bus/src/readi2cblock.cc
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./readi2cblock.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 ReadI2cBlock(int fd, __u8 cmd, __u8 length, __u8 *block) {
|
||||
return i2c_smbus_read_i2c_block_data(fd, cmd, length, block);
|
||||
}
|
||||
|
||||
class ReadI2cBlockWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
ReadI2cBlockWorker(
|
||||
Nan::Callback *callback,
|
||||
int fd,
|
||||
__u8 cmd,
|
||||
__u32 length,
|
||||
__u8* block,
|
||||
v8::Local<v8::Object> &bufferHandle
|
||||
) : I2cAsyncWorker(callback), fd(fd), cmd(cmd), length(length), block(block), bytesRead(0) {
|
||||
SaveToPersistent("buffer", bufferHandle);
|
||||
}
|
||||
|
||||
~ReadI2cBlockWorker() {}
|
||||
|
||||
void Execute() {
|
||||
bytesRead = ReadI2cBlock(fd, cmd, length, block);
|
||||
if (bytesRead == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("readI2cBlock");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> bufferHandle = GetFromPersistent("buffer");
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null(),
|
||||
Nan::New<v8::Integer>(bytesRead),
|
||||
bufferHandle
|
||||
};
|
||||
|
||||
callback->Call(3, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 cmd;
|
||||
__u32 length;
|
||||
__u8* block;
|
||||
__s32 bytesRead;
|
||||
};
|
||||
|
||||
NAN_METHOD(ReadI2cBlockAsync) {
|
||||
if (info.Length() < 5 ||
|
||||
!info[0]->IsInt32() ||
|
||||
!info[1]->IsInt32() ||
|
||||
!info[2]->IsUint32() ||
|
||||
!info[3]->IsObject() ||
|
||||
!info[4]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readI2cBlock",
|
||||
"incorrect arguments passed to readI2cBlock"
|
||||
"(int fd, int cmd, int length, Buffer buffer, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
|
||||
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();
|
||||
Nan::Callback *callback = new Nan::Callback(info[4].As<v8::Function>());
|
||||
|
||||
__u8* bufferData = (__u8*) node::Buffer::Data(bufferHandle);
|
||||
size_t bufferLength = node::Buffer::Length(bufferHandle);
|
||||
|
||||
if (length > I2C_SMBUS_I2C_BLOCK_MAX) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readI2cBlock",
|
||||
"readI2cBlock can't read blocks with more than 32 bytes"));
|
||||
}
|
||||
|
||||
if (length > bufferLength) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readI2cBlock",
|
||||
"buffer passed to readI2cBlock contains less than 'length' bytes"));
|
||||
}
|
||||
|
||||
Nan::AsyncQueueWorker(new ReadI2cBlockWorker(
|
||||
callback,
|
||||
fd,
|
||||
cmd,
|
||||
length,
|
||||
bufferData,
|
||||
bufferHandle
|
||||
));
|
||||
}
|
||||
|
||||
NAN_METHOD(ReadI2cBlockSync) {
|
||||
if (info.Length() < 4 ||
|
||||
!info[0]->IsInt32() ||
|
||||
!info[1]->IsInt32() ||
|
||||
!info[2]->IsUint32() ||
|
||||
!info[3]->IsObject()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readI2cBlockSync",
|
||||
"incorrect arguments passed to readI2cBlockSync"
|
||||
"(int fd, int cmd, int length, Buffer buffer)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
|
||||
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();
|
||||
|
||||
__u8* bufferData = (__u8*) node::Buffer::Data(bufferHandle);
|
||||
size_t bufferLength = node::Buffer::Length(bufferHandle);
|
||||
|
||||
if (length > I2C_SMBUS_I2C_BLOCK_MAX) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readI2cBlockSync",
|
||||
"readI2cBlockSync can't read blocks with more than 32 bytes"));
|
||||
}
|
||||
|
||||
if (length > bufferLength) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readI2cBlockSync",
|
||||
"buffer passed to readI2cBlockSync contains less than 'length' bytes"));
|
||||
}
|
||||
|
||||
__s32 bytesRead = ReadI2cBlock(fd, cmd, length, bufferData);
|
||||
if (bytesRead == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "readI2cBlockSync", ""));
|
||||
}
|
||||
|
||||
info.GetReturnValue().Set(Nan::New<v8::Integer>(bytesRead));
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/readi2cblock.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/readi2cblock.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_READI2CBLOCK_H_
|
||||
#define I2C_BUS_READI2CBLOCK_H_
|
||||
NAN_METHOD(ReadI2cBlockAsync);
|
||||
NAN_METHOD(ReadI2cBlockSync);
|
||||
#endif // I2C_BUS_READI2CBLOCK_H_
|
||||
|
||||
72
node_modules/i2c-bus/src/readword.cc
generated
vendored
Normal file
72
node_modules/i2c-bus/src/readword.cc
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./readword.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 ReadWord(int fd, __u8 cmd) {
|
||||
return i2c_smbus_read_word_data(fd, cmd);
|
||||
}
|
||||
|
||||
class ReadWordWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
ReadWordWorker(Nan::Callback *callback, int fd, __u8 cmd)
|
||||
: I2cAsyncWorker(callback), fd(fd), cmd(cmd) {}
|
||||
~ReadWordWorker() {}
|
||||
|
||||
void Execute() {
|
||||
word = ReadWord(fd, cmd);
|
||||
if (word == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("readWord");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null(),
|
||||
Nan::New<v8::Integer>(word)
|
||||
};
|
||||
|
||||
callback->Call(2, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 cmd;
|
||||
__s32 word;
|
||||
};
|
||||
|
||||
NAN_METHOD(ReadWordAsync) {
|
||||
if (info.Length() < 3 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readWord",
|
||||
"incorrect arguments passed to readWord(int fd, int cmd, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new ReadWordWorker(callback, fd, cmd));
|
||||
}
|
||||
|
||||
NAN_METHOD(ReadWordSync) {
|
||||
if (info.Length() < 2 || !info[0]->IsInt32() || !info[1]->IsInt32()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "readWordSync",
|
||||
"incorrect arguments passed to readWordSync(int fd, int cmd)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
|
||||
__s32 word = ReadWord(fd, cmd);
|
||||
if (word == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "readWordSync", ""));
|
||||
}
|
||||
|
||||
info.GetReturnValue().Set(Nan::New<v8::Integer>(word));
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/readword.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/readword.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_READWORD_H_
|
||||
#define I2C_BUS_READWORD_H_
|
||||
NAN_METHOD(ReadWordAsync);
|
||||
NAN_METHOD(ReadWordSync);
|
||||
#endif // I2C_BUS_READWORD_H_
|
||||
|
||||
69
node_modules/i2c-bus/src/receivebyte.cc
generated
vendored
Normal file
69
node_modules/i2c-bus/src/receivebyte.cc
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./receivebyte.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 ReceiveByte(int fd) {
|
||||
return i2c_smbus_read_byte(fd);
|
||||
}
|
||||
|
||||
class ReceiveByteWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
ReceiveByteWorker(Nan::Callback *callback, int fd)
|
||||
: I2cAsyncWorker(callback), fd(fd) {}
|
||||
~ReceiveByteWorker() {}
|
||||
|
||||
void Execute() {
|
||||
byte = ReceiveByte(fd);
|
||||
if (byte == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("receiveByte");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null(),
|
||||
Nan::New<v8::Integer>(byte)
|
||||
};
|
||||
|
||||
callback->Call(2, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__s32 byte;
|
||||
};
|
||||
|
||||
NAN_METHOD(ReceiveByteAsync) {
|
||||
if (info.Length() < 2 || !info[0]->IsInt32() || !info[1]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "receiveByte",
|
||||
"incorrect arguments passed to receiveByte(int fd, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[1].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new ReceiveByteWorker(callback, fd));
|
||||
}
|
||||
|
||||
NAN_METHOD(ReceiveByteSync) {
|
||||
if (info.Length() < 1 || !info[0]->IsInt32()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "receiveByteSync",
|
||||
"incorrect arguments passed to receiveByteSync(int fd)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
|
||||
__s32 byte = ReceiveByte(fd);
|
||||
if (byte == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "receiveByteSync", ""));
|
||||
}
|
||||
|
||||
info.GetReturnValue().Set(Nan::New<v8::Integer>(byte));
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/receivebyte.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/receivebyte.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_RECEIVEBYTE_H_
|
||||
#define I2C_BUS_RECEIVEBYTE_H_
|
||||
NAN_METHOD(ReceiveByteAsync);
|
||||
NAN_METHOD(ReceiveByteSync);
|
||||
#endif // I2C_BUS_RECEIVEBYTE_H_
|
||||
|
||||
68
node_modules/i2c-bus/src/sendbyte.cc
generated
vendored
Normal file
68
node_modules/i2c-bus/src/sendbyte.cc
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./sendbyte.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 SendByte(int fd, __u8 byte) {
|
||||
return i2c_smbus_write_byte(fd, byte);
|
||||
}
|
||||
|
||||
class SendByteWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
SendByteWorker(Nan::Callback *callback, int fd, __u8 byte)
|
||||
: I2cAsyncWorker(callback), fd(fd), byte(byte) {}
|
||||
~SendByteWorker() {}
|
||||
|
||||
void Execute() {
|
||||
__s32 ret = SendByte(fd, byte);
|
||||
if (ret == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("sendByte");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null()
|
||||
};
|
||||
|
||||
callback->Call(1, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 byte;
|
||||
};
|
||||
|
||||
NAN_METHOD(SendByteAsync) {
|
||||
if (info.Length() < 3 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "sendByte",
|
||||
"incorrect arguments passed to sendByte(int fd, int byte, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 byte = Nan::To<int32_t>(info[1]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new SendByteWorker(callback, fd, byte));
|
||||
}
|
||||
|
||||
NAN_METHOD(SendByteSync) {
|
||||
if (info.Length() < 2 || !info[0]->IsInt32() || !info[1]->IsInt32()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "sendByteSync",
|
||||
"incorrect arguments passed to sendByteSync(int fd, int byte)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 byte = Nan::To<int32_t>(info[1]).FromJust();
|
||||
|
||||
__s32 ret = SendByte(fd, byte);
|
||||
if (ret == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "sendByteSync", ""));
|
||||
}
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/sendbyte.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/sendbyte.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_SENDBYTE_H_
|
||||
#define I2C_BUS_SENDBYTE_H_
|
||||
NAN_METHOD(SendByteAsync);
|
||||
NAN_METHOD(SendByteSync);
|
||||
#endif // I2C_BUS_SENDBYTE_H_
|
||||
|
||||
69
node_modules/i2c-bus/src/setaddr.cc
generated
vendored
Normal file
69
node_modules/i2c-bus/src/setaddr.cc
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./setaddr.h"
|
||||
#include "./util.h"
|
||||
|
||||
static int SetAddr(int fd, int addr, bool forceAccess) {
|
||||
return ioctl(fd, forceAccess ? I2C_SLAVE_FORCE : I2C_SLAVE, addr);
|
||||
}
|
||||
|
||||
class SetAddrWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
SetAddrWorker(Nan::Callback *callback, int fd, int addr, bool forceAccess)
|
||||
: I2cAsyncWorker(callback), fd(fd), addr(addr), forceAccess(forceAccess) {}
|
||||
~SetAddrWorker() {}
|
||||
|
||||
void Execute() {
|
||||
if (SetAddr(fd, addr, forceAccess) == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("setAddr");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null()
|
||||
};
|
||||
|
||||
callback->Call(1, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
int addr;
|
||||
bool forceAccess;
|
||||
};
|
||||
|
||||
NAN_METHOD(SetAddrAsync) {
|
||||
if (info.Length() < 4 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsBoolean() || !info[3]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "setAddr",
|
||||
"incorrect arguments passed to setAddr(int fd, int addr, bool forceAccess, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
int addr = Nan::To<int32_t>(info[1]).FromJust();
|
||||
bool forceAccess = Nan::To<bool>(info[2]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[3].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new SetAddrWorker(callback, fd, addr, forceAccess));
|
||||
}
|
||||
|
||||
NAN_METHOD(SetAddrSync) {
|
||||
if (info.Length() < 3 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsBoolean()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "setAddrSync",
|
||||
"incorrect arguments passed to setAddrSync(int fd, int addr, bool forceAccess)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
int addr = Nan::To<int32_t>(info[1]).FromJust();
|
||||
bool forceAccess = Nan::To<bool>(info[2]).FromJust();
|
||||
|
||||
if (SetAddr(fd, addr, forceAccess) != 0) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "setAddrSync", ""));
|
||||
}
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/setaddr.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/setaddr.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_SETADDR_H_
|
||||
#define I2C_BUS_SETADDR_H_
|
||||
NAN_METHOD(SetAddrAsync);
|
||||
NAN_METHOD(SetAddrSync);
|
||||
#endif // I2C_BUS_SETADDR_H_
|
||||
|
||||
67
node_modules/i2c-bus/src/util.h
generated
vendored
Normal file
67
node_modules/i2c-bus/src/util.h
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
#ifndef I2C_BUS_UTIL_H_
|
||||
#define I2C_BUS_UTIL_H_
|
||||
|
||||
class I2cAsyncWorker : public Nan::AsyncWorker {
|
||||
public:
|
||||
explicit I2cAsyncWorker(Nan::Callback *callback)
|
||||
: Nan::AsyncWorker(callback), errorNo_(0), errorSyscall_(0) {}
|
||||
|
||||
virtual ~I2cAsyncWorker() {
|
||||
if (errorSyscall_) {
|
||||
delete[] errorSyscall_;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void WorkComplete() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
if (errorNo_ == 0) {
|
||||
HandleOKCallback();
|
||||
} else {
|
||||
HandleErrorCallback();
|
||||
}
|
||||
|
||||
delete callback;
|
||||
callback = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void HandleErrorCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[1] = {
|
||||
Nan::ErrnoException(ErrorNo(), ErrorSyscall(), "")
|
||||
};
|
||||
|
||||
callback->Call(1, argv, async_resource);
|
||||
}
|
||||
|
||||
void SetErrorNo(int errorNo) {
|
||||
errorNo_ = errorNo;
|
||||
}
|
||||
|
||||
int ErrorNo() {
|
||||
return errorNo_;
|
||||
}
|
||||
|
||||
void SetErrorSyscall(const char *errorSyscall) {
|
||||
if (errorSyscall_) {
|
||||
delete[] errorSyscall_;
|
||||
}
|
||||
|
||||
size_t size = strlen(errorSyscall) + 1;
|
||||
errorSyscall_ = new char[size];
|
||||
memcpy(errorSyscall_, errorSyscall, size);
|
||||
}
|
||||
|
||||
const char *ErrorSyscall() {
|
||||
return errorSyscall_;
|
||||
}
|
||||
|
||||
private:
|
||||
int errorNo_;
|
||||
char *errorSyscall_;
|
||||
};
|
||||
|
||||
#endif // I2C_BUS_UTIL_H_
|
||||
|
||||
133
node_modules/i2c-bus/src/writeblock.cc
generated
vendored
Normal file
133
node_modules/i2c-bus/src/writeblock.cc
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./writeblock.h"
|
||||
#include "./util.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static __s32 WriteBlock(int fd, __u8 cmd, __u8 length, const __u8 *block) {
|
||||
return i2c_smbus_write_block_data(fd, cmd, length, block);
|
||||
}
|
||||
|
||||
class WriteBlockWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
WriteBlockWorker(
|
||||
Nan::Callback *callback,
|
||||
int fd,
|
||||
__u8 cmd,
|
||||
__u32 length,
|
||||
const __u8* block,
|
||||
v8::Local<v8::Object> &bufferHandle
|
||||
) : I2cAsyncWorker(callback), fd(fd), cmd(cmd), length(length), block(block) {
|
||||
SaveToPersistent("buffer", bufferHandle);
|
||||
}
|
||||
|
||||
~WriteBlockWorker() {}
|
||||
|
||||
void Execute() {
|
||||
__s32 ret = WriteBlock(fd, cmd, length, block);
|
||||
if (ret == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("writeBlock");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> bufferHandle = GetFromPersistent("buffer");
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null(),
|
||||
Nan::New<v8::Integer>(length),
|
||||
bufferHandle
|
||||
};
|
||||
|
||||
callback->Call(3, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 cmd;
|
||||
__u32 length;
|
||||
const __u8* block;
|
||||
};
|
||||
|
||||
NAN_METHOD(WriteBlockAsync) {
|
||||
if (info.Length() < 5 ||
|
||||
!info[0]->IsInt32() ||
|
||||
!info[1]->IsInt32() ||
|
||||
!info[2]->IsUint32() ||
|
||||
!info[3]->IsObject() ||
|
||||
!info[4]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeBlock",
|
||||
"incorrect arguments passed to writeBlock"
|
||||
"(int fd, int cmd, int length, Buffer buffer, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
|
||||
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();
|
||||
Nan::Callback *callback = new Nan::Callback(info[4].As<v8::Function>());
|
||||
|
||||
const __u8* bufferData = (const __u8*) node::Buffer::Data(bufferHandle);
|
||||
size_t bufferLength = node::Buffer::Length(bufferHandle);
|
||||
|
||||
if (length > I2C_SMBUS_I2C_BLOCK_MAX) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeBlock",
|
||||
"writeBlock can't write blocks with more than 32 bytes"));
|
||||
}
|
||||
|
||||
if (length > bufferLength) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeBlock",
|
||||
"buffer passed to writeBlock contains less than 'length' bytes"));
|
||||
}
|
||||
|
||||
Nan::AsyncQueueWorker(new WriteBlockWorker(
|
||||
callback,
|
||||
fd,
|
||||
cmd,
|
||||
length,
|
||||
bufferData,
|
||||
bufferHandle
|
||||
));
|
||||
}
|
||||
|
||||
NAN_METHOD(WriteBlockSync) {
|
||||
if (info.Length() < 4 ||
|
||||
!info[0]->IsInt32() ||
|
||||
!info[1]->IsInt32() ||
|
||||
!info[2]->IsUint32() ||
|
||||
!info[3]->IsObject()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeBlockSync",
|
||||
"incorrect arguments passed to writeBlockSync"
|
||||
"(int fd, int cmd, int length, Buffer buffer)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
|
||||
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();
|
||||
|
||||
const __u8* bufferData = (const __u8*) node::Buffer::Data(bufferHandle);
|
||||
size_t bufferLength = node::Buffer::Length(bufferHandle);
|
||||
|
||||
if (length > I2C_SMBUS_I2C_BLOCK_MAX) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeBlockSync",
|
||||
"writeBlockSync can't write blocks with more than 32 bytes"));
|
||||
}
|
||||
|
||||
if (length > bufferLength) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeBlockSync",
|
||||
"buffer passed to writeBlockSync contains less than 'length' bytes"));
|
||||
}
|
||||
|
||||
__s32 ret = WriteBlock(fd, cmd, length, bufferData);
|
||||
if (ret == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "writeBlockSync", ""));
|
||||
}
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/writeblock.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/writeblock.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_WRITEBLOCK_H_
|
||||
#define I2C_BUS_WRITEBLOCK_H_
|
||||
NAN_METHOD(WriteBlockAsync);
|
||||
NAN_METHOD(WriteBlockSync);
|
||||
#endif // I2C_BUS_WRITEBLOCK_H_
|
||||
|
||||
72
node_modules/i2c-bus/src/writebyte.cc
generated
vendored
Normal file
72
node_modules/i2c-bus/src/writebyte.cc
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./writebyte.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 WriteByte(int fd, __u8 cmd, __u8 byte) {
|
||||
return i2c_smbus_write_byte_data(fd, cmd, byte);
|
||||
}
|
||||
|
||||
class WriteByteWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
WriteByteWorker(Nan::Callback *callback, int fd, __u8 cmd, __u8 byte)
|
||||
: I2cAsyncWorker(callback), fd(fd), cmd(cmd), byte(byte) {}
|
||||
~WriteByteWorker() {}
|
||||
|
||||
void Execute() {
|
||||
__s32 ret = WriteByte(fd, cmd, byte);
|
||||
if (ret == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("writeByte");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null()
|
||||
};
|
||||
|
||||
callback->Call(1, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 cmd;
|
||||
__u8 byte;
|
||||
};
|
||||
|
||||
NAN_METHOD(WriteByteAsync) {
|
||||
if (info.Length() < 4 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsInt32() || !info[3]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeByte",
|
||||
"incorrect arguments passed to writeByte"
|
||||
"(int fd, int cmd, int byte, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u8 byte = Nan::To<int32_t>(info[2]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[3].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new WriteByteWorker(callback, fd, cmd, byte));
|
||||
}
|
||||
|
||||
NAN_METHOD(WriteByteSync) {
|
||||
if (info.Length() < 3 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsInt32()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeByteSync",
|
||||
"incorrect arguments passed to writeByteSync(int fd, int cmd, int byte)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u8 byte = Nan::To<int32_t>(info[2]).FromJust();
|
||||
|
||||
__s32 ret = WriteByte(fd, cmd, byte);
|
||||
if (ret == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "writeByteSync", ""));
|
||||
}
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/writebyte.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/writebyte.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_WRITEBYTE_H_
|
||||
#define I2C_BUS_WRITEBYTE_H_
|
||||
NAN_METHOD(WriteByteAsync);
|
||||
NAN_METHOD(WriteByteSync);
|
||||
#endif // I2C_BUS_WRITEBYTE_H_
|
||||
|
||||
131
node_modules/i2c-bus/src/writei2cblock.cc
generated
vendored
Normal file
131
node_modules/i2c-bus/src/writei2cblock.cc
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./writei2cblock.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 WriteI2cBlock(int fd, __u8 cmd, __u8 length, const __u8 *block) {
|
||||
return i2c_smbus_write_i2c_block_data(fd, cmd, length, block);
|
||||
}
|
||||
|
||||
class WriteI2cBlockWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
WriteI2cBlockWorker(
|
||||
Nan::Callback *callback,
|
||||
int fd,
|
||||
__u8 cmd,
|
||||
__u32 length,
|
||||
const __u8* block,
|
||||
v8::Local<v8::Object> &bufferHandle
|
||||
) : I2cAsyncWorker(callback), fd(fd), cmd(cmd), length(length), block(block) {
|
||||
SaveToPersistent("buffer", bufferHandle);
|
||||
}
|
||||
|
||||
~WriteI2cBlockWorker() {}
|
||||
|
||||
void Execute() {
|
||||
__s32 ret = WriteI2cBlock(fd, cmd, length, block);
|
||||
if (ret == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("writeI2cBlock");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> bufferHandle = GetFromPersistent("buffer");
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null(),
|
||||
Nan::New<v8::Integer>(length),
|
||||
bufferHandle
|
||||
};
|
||||
|
||||
callback->Call(3, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 cmd;
|
||||
__u32 length;
|
||||
const __u8* block;
|
||||
};
|
||||
|
||||
NAN_METHOD(WriteI2cBlockAsync) {
|
||||
if (info.Length() < 5 ||
|
||||
!info[0]->IsInt32() ||
|
||||
!info[1]->IsInt32() ||
|
||||
!info[2]->IsUint32() ||
|
||||
!info[3]->IsObject() ||
|
||||
!info[4]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeI2cBlock",
|
||||
"incorrect arguments passed to writeI2cBlock"
|
||||
"(int fd, int cmd, int length, Buffer buffer, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
|
||||
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();
|
||||
Nan::Callback *callback = new Nan::Callback(info[4].As<v8::Function>());
|
||||
|
||||
const __u8* bufferData = (const __u8*) node::Buffer::Data(bufferHandle);
|
||||
size_t bufferLength = node::Buffer::Length(bufferHandle);
|
||||
|
||||
if (length > I2C_SMBUS_I2C_BLOCK_MAX) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeI2cBlock",
|
||||
"writeI2cBlock can't write blocks with more than 32 bytes"));
|
||||
}
|
||||
|
||||
if (length > bufferLength) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeI2cBlock",
|
||||
"buffer passed to writeI2cBlock contains less than 'length' bytes"));
|
||||
}
|
||||
|
||||
Nan::AsyncQueueWorker(new WriteI2cBlockWorker(
|
||||
callback,
|
||||
fd,
|
||||
cmd,
|
||||
length,
|
||||
bufferData,
|
||||
bufferHandle
|
||||
));
|
||||
}
|
||||
|
||||
NAN_METHOD(WriteI2cBlockSync) {
|
||||
if (info.Length() < 4 ||
|
||||
!info[0]->IsInt32() ||
|
||||
!info[1]->IsInt32() ||
|
||||
!info[2]->IsUint32() ||
|
||||
!info[3]->IsObject()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeI2cBlockSync",
|
||||
"incorrect arguments passed to writeI2cBlockSync"
|
||||
"(int fd, int cmd, int length, Buffer buffer)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
|
||||
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();
|
||||
|
||||
const __u8* bufferData = (const __u8*) node::Buffer::Data(bufferHandle);
|
||||
size_t bufferLength = node::Buffer::Length(bufferHandle);
|
||||
|
||||
if (length > I2C_SMBUS_I2C_BLOCK_MAX) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeI2cBlockSync",
|
||||
"writeI2cBlockSync can't write blocks with more than 32 bytes"));
|
||||
}
|
||||
|
||||
if (length > bufferLength) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeI2cBlockSync",
|
||||
"buffer passed to writeI2cBlockSync contains less than 'length' bytes"));
|
||||
}
|
||||
|
||||
__s32 ret = WriteI2cBlock(fd, cmd, length, bufferData);
|
||||
if (ret == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "writeI2cBlockSync", ""));
|
||||
}
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/writei2cblock.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/writei2cblock.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_WRITEI2CBLOCK_H_
|
||||
#define I2C_BUS_WRITEI2CBLOCK_H_
|
||||
NAN_METHOD(WriteI2cBlockAsync);
|
||||
NAN_METHOD(WriteI2cBlockSync);
|
||||
#endif // I2C_BUS_WRITEI2CBLOCK_H_
|
||||
|
||||
68
node_modules/i2c-bus/src/writequick.cc
generated
vendored
Normal file
68
node_modules/i2c-bus/src/writequick.cc
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./writequick.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 WriteQuick(int fd, __u8 bit) {
|
||||
return i2c_smbus_write_quick(fd, bit);
|
||||
}
|
||||
|
||||
class WriteQuickWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
WriteQuickWorker(Nan::Callback *callback, int fd, __u8 bit)
|
||||
: I2cAsyncWorker(callback), fd(fd), bit(bit) {}
|
||||
~WriteQuickWorker() {}
|
||||
|
||||
void Execute() {
|
||||
__s32 ret = WriteQuick(fd, bit);
|
||||
if (ret == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("writeQuick");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null()
|
||||
};
|
||||
|
||||
callback->Call(1, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 bit;
|
||||
};
|
||||
|
||||
NAN_METHOD(WriteQuickAsync) {
|
||||
if (info.Length() < 3 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeQuick",
|
||||
"incorrect arguments passed to writeQuick(int fd, int bit, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 bit = Nan::To<int32_t>(info[1]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new WriteQuickWorker(callback, fd, bit));
|
||||
}
|
||||
|
||||
NAN_METHOD(WriteQuickSync) {
|
||||
if (info.Length() < 2 || !info[0]->IsInt32() || !info[1]->IsInt32()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeQuickSync",
|
||||
"incorrect arguments passed to writeQuickSync(int fd, int bit)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 bit = Nan::To<int32_t>(info[1]).FromJust();
|
||||
|
||||
__s32 ret = WriteQuick(fd, bit);
|
||||
if (ret == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "writeQuickSync", ""));
|
||||
}
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/writequick.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/writequick.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_WRITEQUICK_H_
|
||||
#define I2C_BUS_WRITEQUICK_H_
|
||||
NAN_METHOD(WriteQuickAsync);
|
||||
NAN_METHOD(WriteQuickSync);
|
||||
#endif // I2C_BUS_WRITEQUICK_H_
|
||||
|
||||
73
node_modules/i2c-bus/src/writeword.cc
generated
vendored
Normal file
73
node_modules/i2c-bus/src/writeword.cc
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
#include <errno.h>
|
||||
#include <node.h>
|
||||
#include <nan.h>
|
||||
#include "./i2c-dev.h"
|
||||
#include "./writeword.h"
|
||||
#include "./util.h"
|
||||
|
||||
static __s32 WriteWord(int fd, __u8 cmd, __u16 word) {
|
||||
return i2c_smbus_write_word_data(fd, cmd, word);
|
||||
}
|
||||
|
||||
class WriteWordWorker : public I2cAsyncWorker {
|
||||
public:
|
||||
WriteWordWorker(Nan::Callback *callback, int fd, __u8 cmd, __u16 word)
|
||||
: I2cAsyncWorker(callback), fd(fd), cmd(cmd), word(word) {}
|
||||
~WriteWordWorker() {}
|
||||
|
||||
void Execute() {
|
||||
__s32 ret = WriteWord(fd, cmd, word);
|
||||
if (ret == -1) {
|
||||
SetErrorNo(errno);
|
||||
SetErrorSyscall("writeWord");
|
||||
}
|
||||
}
|
||||
|
||||
void HandleOKCallback() {
|
||||
Nan::HandleScope scope;
|
||||
|
||||
v8::Local<v8::Value> argv[] = {
|
||||
Nan::Null()
|
||||
};
|
||||
|
||||
callback->Call(1, argv, async_resource);
|
||||
}
|
||||
|
||||
private:
|
||||
int fd;
|
||||
__u8 cmd;
|
||||
__u16 word;
|
||||
};
|
||||
|
||||
NAN_METHOD(WriteWordAsync) {
|
||||
if (info.Length() < 4 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsInt32() || !info[3]->IsFunction()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeWord",
|
||||
"incorrect arguments passed to writeWord"
|
||||
"(int fd, int cmd, int word, function cb)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u16 word = Nan::To<int32_t>(info[2]).FromJust();
|
||||
Nan::Callback *callback = new Nan::Callback(info[3].As<v8::Function>());
|
||||
|
||||
Nan::AsyncQueueWorker(new WriteWordWorker(callback, fd, cmd, word));
|
||||
}
|
||||
|
||||
NAN_METHOD(WriteWordSync) {
|
||||
if (info.Length() < 3 || !info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsInt32()) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(EINVAL, "writeWordSync",
|
||||
"incorrect arguments passed to writeWordSync"
|
||||
"(int fd, int cmd, int word)"));
|
||||
}
|
||||
|
||||
int fd = Nan::To<int32_t>(info[0]).FromJust();
|
||||
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
|
||||
__u16 word = Nan::To<int32_t>(info[2]).FromJust();
|
||||
|
||||
__s32 ret = WriteWord(fd, cmd, word);
|
||||
if (ret == -1) {
|
||||
return Nan::ThrowError(Nan::ErrnoException(errno, "writeWordSync", ""));
|
||||
}
|
||||
}
|
||||
|
||||
6
node_modules/i2c-bus/src/writeword.h
generated
vendored
Normal file
6
node_modules/i2c-bus/src/writeword.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef I2C_BUS_WRITEWORD_H_
|
||||
#define I2C_BUS_WRITEWORD_H_
|
||||
NAN_METHOD(WriteWordAsync);
|
||||
NAN_METHOD(WriteWordSync);
|
||||
#endif // I2C_BUS_WRITEWORD_H_
|
||||
|
||||
Reference in New Issue
Block a user