add listener program
This commit is contained in:
parent
0bfcdc0d38
commit
e269ac60ef
159 changed files with 21076 additions and 0 deletions
11
index.js
Normal file
11
index.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
var LCDPLATE, lcd;
|
||||||
|
LCDPLATE = require('adafruit-i2c-lcd').plate;
|
||||||
|
lcd = new LCDPLATE(1, 0x43);
|
||||||
|
|
||||||
|
lcd.backlight(lcd.colors.RED);
|
||||||
|
lcd.message('Hello World!');
|
||||||
|
|
||||||
|
lcd.on('button_change', function(button) {
|
||||||
|
lcd.clear();
|
||||||
|
lcd.message('Button changed:\n' + lcd.buttonName(button));
|
||||||
|
});
|
||||||
|
|
@ -81,3 +81,21 @@ sudo alsactl store
|
||||||
### LCD Screen
|
### LCD Screen
|
||||||
Follow https://peppe8o.com/1602-lcd-raspberry-pi-display/
|
Follow https://peppe8o.com/1602-lcd-raspberry-pi-display/
|
||||||
|
|
||||||
|
sudo apt install python3-pip python3-smbus i2c-tools -y
|
||||||
|
sudo raspi-config
|
||||||
|
|
||||||
|
enable i2c in interface options
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
python3 -m venv screen --system-site-packages
|
||||||
|
source ./screen/bin/activate
|
||||||
|
|
||||||
|
pip3 install adafruit-circuitpython-charlcd
|
||||||
|
|
||||||
|
wget https://peppe8o.com/download/python/lcd/i2c-lcd-test-01-hello-world.py
|
||||||
|
|
||||||
|
i2cdetect -y 1
|
||||||
|
|
||||||
|
python3 i2c-lcd-test-01-hello-world.py
|
||||||
52
node_modules/.package-lock.json
generated
vendored
Normal file
52
node_modules/.package-lock.json
generated
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
{
|
||||||
|
"name": "portal",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/adafruit-i2c-lcd": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/adafruit-i2c-lcd/-/adafruit-i2c-lcd-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-L23HBVbNyr1yGXwO0RsT6modQgqOe98EDA4OR8oo74Rhwy5xaqPjSSBFvvBc7IX7hgjjBS12udSzguCehSzrxw==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"i2c-bus": "^5.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/bindings": {
|
||||||
|
"version": "1.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||||
|
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"file-uri-to-path": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/file-uri-to-path": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/i2c-bus": {
|
||||||
|
"version": "5.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/i2c-bus/-/i2c-bus-5.2.3.tgz",
|
||||||
|
"integrity": "sha512-kzFgU0OSIZlaeUUa+VK7L+kkxnj4feimCVQDOPrzj0cTaB+hNweTsO8/j7QvW2gRgWQ7ds5IpfFjpBrX+fMNng==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"bindings": "^1.5.0",
|
||||||
|
"nan": "^2.17.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/nan": {
|
||||||
|
"version": "2.22.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/nan/-/nan-2.22.2.tgz",
|
||||||
|
"integrity": "sha512-DANghxFkS1plDdRsX0X9pm0Z6SJNN6gBdtXfanwoZ8hooC5gosGFSBGRYHUVPz1asKA/kMRqDRdHrluZ61SpBQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
node_modules/adafruit-i2c-lcd/LICENSE
generated
vendored
Normal file
27
node_modules/adafruit-i2c-lcd/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
Copyright (c) 2013, fehmer
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer in the documentation and/or
|
||||||
|
other materials provided with the distribution.
|
||||||
|
|
||||||
|
Neither the name of the {organization} nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
169
node_modules/adafruit-i2c-lcd/README.md
generated
vendored
Normal file
169
node_modules/adafruit-i2c-lcd/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,169 @@
|
||||||
|
# Adafruit I2C LCD Plate
|
||||||
|
|
||||||
|
Node.js implementation for the Adafruit RGB 16x2 LCD+Keypad Kit for Raspberry Pi
|
||||||
|
http://www.adafruit.com/products/1110
|
||||||
|
|
||||||
|
**Note:** This readme is for the current version 1.x.x/2.x.x. If you are using older versions please read the [version 0.0.x readme](https://github.com/fehmer/adafruit-i2c-lcd/tree/0.0.x) or [version 0.1.x readme](https://github.com/fehmer/adafruit-i2c-lcd/tree/0.1.x).
|
||||||
|
|
||||||
|
**Note:** Since version 1.0.0 this module is based on [i2c-bus](https://www.npmjs.com/package/i2c-bus). For compatibility with your node.js version read the i2c-bus documentation. Older versions of this module were based on [i2c](https://www.npmjs.com/package/i2c). adafruit-i2c-lcd version 0.1.x only works with node.js 0.12.x and adafruit-i2c-lcd version 0.0.x only works with node.js 0.10.x.
|
||||||
|
|
||||||
|
**Note:** Version 2.0.0 and greater drops support for node v4, v5, and v7 as well as npm < v4 (update npm by running the command ```npm i npm -g```)
|
||||||
|
|
||||||
|
**Note:** This module is compatible with Sainsmart 1602 I2C, see [Compatibility](#compatibility)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
1. read the [i2c-bus documentation](https://github.com/fivdi/i2c-bus/blob/master/doc/raspberry-pi-i2c.md) how to setup your raspberry pi.
|
||||||
|
2. add dependency using ```npm install adafruit-i2c-lcd --save```
|
||||||
|
3. Copy and run one of the examples from the examples directory. Maybe you have to run them as root.
|
||||||
|
|
||||||
|
### simple example
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var LCDPLATE, lcd;
|
||||||
|
LCDPLATE = require('adafruit-i2c-lcd').plate;
|
||||||
|
lcd = new LCDPLATE(1, 0x20);
|
||||||
|
|
||||||
|
lcd.backlight(lcd.colors.RED);
|
||||||
|
lcd.message('Hello World!');
|
||||||
|
|
||||||
|
lcd.on('button_change', function(button) {
|
||||||
|
lcd.clear();
|
||||||
|
lcd.message('Button changed:\n' + lcd.buttonName(button));
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
- [LCDPLATE(device:String,address:Number,[pollInterval:Number])](#lcdplatedevicestringaddressnumberpollintervalnumber)
|
||||||
|
- [LCDPLATE.clear()](#lcdplateclear)
|
||||||
|
- [LCDPLATE.close()](#lcdplateclose)
|
||||||
|
- [LCDPLATE.backlight(color:Number)](#lcdplatebacklightcolornumber)
|
||||||
|
- [LCDPLATE.message(text:String,[clear:boolean])](#lcdplatemessagetextstring-booleanclear)
|
||||||
|
- [LCDPLATE.createChar(index:Number, pattern:byte[])](#lcdplatecreatecharindexnumber-patternbyte)
|
||||||
|
- [LCDPLATE.buttonState():Number](#lcdplatebuttonstatenumber)
|
||||||
|
- [LCDPLATE.buttonName(val:Number):String](#lcdplatebuttonnamevalnumberstring)
|
||||||
|
|
||||||
|
### LCDPLATE(device:String,address:Number,[pollInterval:Number])
|
||||||
|
|
||||||
|
Setting up a new LCDPLATE.
|
||||||
|
|
||||||
|
- device: Device name, e.g. '/dev/i2c-1'
|
||||||
|
- address: Address of the i2c panel, e.g. 0x20
|
||||||
|
- pollInterval: optional. Set the poll interval for the buttons to x ms. Use pollInterval=-1 to disable polling. (Buttons will not work)
|
||||||
|
|
||||||
|
### LCDPLATE.clear()
|
||||||
|
|
||||||
|
Clear the LCD, remove all text.
|
||||||
|
|
||||||
|
### LCDPLATE.close()
|
||||||
|
|
||||||
|
Close the LCD plate. Use this to stop the polling.
|
||||||
|
|
||||||
|
### LCDPLATE.backlight(color:Number)
|
||||||
|
|
||||||
|
Set the backlight of the LCD to the given color. You can use predefined colors from the LCDPLATE class:
|
||||||
|
|
||||||
|
LCDPLATE.colors = [OFF, RED, GREEN, BLUE, YELLOW, TEAL, VIOLET, WHITE, ON]
|
||||||
|
|
||||||
|
|
||||||
|
### LCDPLATE.message(text:String, [boolean:clear])
|
||||||
|
|
||||||
|
Add the text on the LCD. Use \n as line feed. Only the first two lines will be sent to the display.
|
||||||
|
If parameter clear is given and true only the text is shown, previous content on the lcd will be cleared.
|
||||||
|
|
||||||
|
### LCDPLATE.createChar(index:Number, pattern:byte[])
|
||||||
|
|
||||||
|
Defines custom characters. Index must be between 0 and 7. Pattern is the pattern of your character, must contain exactly 8 bytes.
|
||||||
|
E.g. you can easyly design your custom character at http://www.quinapalus.com/hd44780udg.html to show your custom character use eg. lcd.message('\x01').
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```javascript
|
||||||
|
lcd.createChar(1, [0,0,10,31,31,14,4,0]);
|
||||||
|
lcd.createChar(2, [0,4,10,17,17,10,4,0]);
|
||||||
|
|
||||||
|
lcd.clear();
|
||||||
|
lcd.backlight(lcd.colors.RED);
|
||||||
|
lcd.message('I\x01 n\x02de.js', true);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### LCDPLATE.buttonState():Number
|
||||||
|
|
||||||
|
Returns the pressed buttons as a number. Use bitmasks to mask out the state of the desired button. See LCDPLATE.buttons for button values.
|
||||||
|
|
||||||
|
### LCDPLATE.buttonName(val:Number):String
|
||||||
|
|
||||||
|
Returns the name, e.g. 'SELECT' to a button number. See LCDPLATE.buttons for button values.
|
||||||
|
|
||||||
|
## Events
|
||||||
|
|
||||||
|
### button_change
|
||||||
|
|
||||||
|
Fires if a button is pressed or released.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
* button: the button, See LCDPLATE.buttons for button values.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```javascript
|
||||||
|
lcd.on('button_change', function(button) {
|
||||||
|
lcd.clear();
|
||||||
|
lcd.message('Button changed:\n' + lcd.buttonName(button));
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### button_up
|
||||||
|
|
||||||
|
Fires if a button is released.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
* button: the button, See LCDPLATE.buttons for button values.
|
||||||
|
|
||||||
|
|
||||||
|
### button_down
|
||||||
|
|
||||||
|
Fires if a button is pressed.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
* button: the button, See LCDPLATE.buttons for button values.
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
This library is compatible with the Sainsmart 1602 I2C (SKU: 20-011-221)
|
||||||
|
with some notable exceptions. This clone has a blue backlight and an
|
||||||
|
RGB LED on-board.
|
||||||
|
|
||||||
|
* The [LCDPLATE.backlight()](#lcdplatebacklightcolornumber) function
|
||||||
|
changes the RGB LED rather than the backlight.
|
||||||
|
* The backlight on the LCD is connected to GPA5, which is the sixth (6th)
|
||||||
|
bit of port A. It can be set on or off directly in your client code.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
lcd.sendBytes(0, 0x1F); // Sainsmart 1602 I2C backlight on
|
||||||
|
lcd.sendBytes(0, 0x3F); // Sainsmart 1602 I2C backlight off
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Licence
|
||||||
|
|
||||||
|
Based on the [Adafruit's Raspberry-Pi Python Code Library](https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git)
|
||||||
|
|
||||||
|
> Here is a growing collection of libraries and example python scripts
|
||||||
|
> for controlling a variety of Adafruit electronics with a Raspberry Pi
|
||||||
|
|
||||||
|
> In progress!
|
||||||
|
>
|
||||||
|
> Adafruit invests time and resources providing this open source code,
|
||||||
|
> please support Adafruit and open-source hardware by purchasing
|
||||||
|
> products from Adafruit!
|
||||||
|
>
|
||||||
|
> Written by Limor Fried, Kevin Townsend and Mikey Sklar for Adafruit Industries.
|
||||||
|
> BSD license, all text above must be included in any redistribution
|
||||||
|
>
|
||||||
|
> To download, we suggest logging into your Pi with Internet accessibility and typing:
|
||||||
|
> git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
|
||||||
BIN
node_modules/adafruit-i2c-lcd/adafruit-i2c-lcd-2.0.0.tgz
generated
vendored
Normal file
BIN
node_modules/adafruit-i2c-lcd/adafruit-i2c-lcd-2.0.0.tgz
generated
vendored
Normal file
Binary file not shown.
80
node_modules/adafruit-i2c-lcd/example/demo.js
generated
vendored
Normal file
80
node_modules/adafruit-i2c-lcd/example/demo.js
generated
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
var LCDPLATE, lcd;
|
||||||
|
LCDPLATE = require('adafruit-i2c-lcd').plate;
|
||||||
|
lcd = new LCDPLATE(1, 0x20);
|
||||||
|
var index = 0;
|
||||||
|
|
||||||
|
// create some custom characters
|
||||||
|
lcd.createChar(1, [2, 3, 2, 2, 14, 30, 12, 0])
|
||||||
|
lcd.createChar(2, [0, 1, 3, 22, 28, 8, 0, 0])
|
||||||
|
lcd.createChar(3, [0, 14, 21, 23, 17, 14, 0, 0])
|
||||||
|
lcd.createChar(4, [31, 17, 10, 4, 10, 17, 31, 0])
|
||||||
|
lcd.createChar(5, [8, 12, 10, 9, 10, 12, 8, 0])
|
||||||
|
lcd.createChar(6, [2, 6, 10, 18, 10, 6, 2, 0])
|
||||||
|
lcd.createChar(7, [31, 17, 21, 21, 21, 21, 17, 31])
|
||||||
|
|
||||||
|
//demo content
|
||||||
|
var demo = [{
|
||||||
|
color: lcd.colors.RED,
|
||||||
|
message: 'test backlight\n color: RED \x01'
|
||||||
|
}, {
|
||||||
|
color: lcd.colors.GREEN,
|
||||||
|
message: 'test backlight\n color: GREEN \x02'
|
||||||
|
}, {
|
||||||
|
color: lcd.colors.BLUE,
|
||||||
|
message: 'test backlight\n color: BLUE \x03'
|
||||||
|
}, {
|
||||||
|
color: lcd.colors.YELLOW,
|
||||||
|
message: 'test backlight\n color: YELLOW \x04'
|
||||||
|
}, {
|
||||||
|
color: lcd.colors.TEAL,
|
||||||
|
message: 'test backlight\n color: TEAL \x05'
|
||||||
|
}, {
|
||||||
|
color: lcd.colors.VIOLET,
|
||||||
|
message: 'test backlight\n color: VIOLET \x06'
|
||||||
|
}, {
|
||||||
|
color: lcd.colors.WHITE,
|
||||||
|
message: 'test backlight\n color: WHITE \x07'
|
||||||
|
}, {
|
||||||
|
color: lcd.colors.WHITE,
|
||||||
|
message: 'now try pressing\n some buttons!'
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
// show button state on lcd and console
|
||||||
|
function displayButton(state, button) {
|
||||||
|
lcd.clear();
|
||||||
|
lcd.message('Button: ' + lcd.buttonName(button) + '\nState: ' + state);
|
||||||
|
console.log(state, lcd.buttonName(button));
|
||||||
|
}
|
||||||
|
|
||||||
|
//show hello world in red
|
||||||
|
lcd.backlight(lcd.colors.RED);
|
||||||
|
lcd.message('Hello World!\nLoading demo...');
|
||||||
|
|
||||||
|
//start demo, loop over the demo content.
|
||||||
|
var demoInterval = setInterval(function() {
|
||||||
|
if (index < 8) {
|
||||||
|
//show demo content
|
||||||
|
lcd.clear();
|
||||||
|
lcd.backlight(demo[index].color);
|
||||||
|
lcd.message(demo[index].message);
|
||||||
|
} else {
|
||||||
|
//end of demo
|
||||||
|
clearInterval(demoInterval);
|
||||||
|
|
||||||
|
//register events to show button press/release
|
||||||
|
lcd.on('button_change', function(button) {
|
||||||
|
console.log('button_change', lcd.buttonName(button));
|
||||||
|
});
|
||||||
|
|
||||||
|
lcd.on('button_down', function(button) {
|
||||||
|
displayButton('pressed', button);
|
||||||
|
});
|
||||||
|
|
||||||
|
lcd.on('button_up', function(button) {
|
||||||
|
displayButton('released', button);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}, 1000);
|
||||||
0
node_modules/adafruit-i2c-lcd/lib/.gitkeep
generated
vendored
Normal file
0
node_modules/adafruit-i2c-lcd/lib/.gitkeep
generated
vendored
Normal file
42
node_modules/adafruit-i2c-lcd/lib/I2CBusWireAdapter.js
generated
vendored
Normal file
42
node_modules/adafruit-i2c-lcd/lib/I2CBusWireAdapter.js
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
// Generated by CoffeeScript 1.12.7
|
||||||
|
(function() {
|
||||||
|
var I2C, I2CBusWireAdapter;
|
||||||
|
|
||||||
|
I2C = require('i2c-bus');
|
||||||
|
|
||||||
|
I2CBusWireAdapter = (function() {
|
||||||
|
function I2CBusWireAdapter(device, address) {
|
||||||
|
if (!(typeof device === 'number')) {
|
||||||
|
throw new Error('parameter device has to be the number of the device, not a path or device name. e.g. 1 instead of /dev/i2c-1 or i2c-1');
|
||||||
|
}
|
||||||
|
this._DEVICE = device;
|
||||||
|
this._ADDRESS = address;
|
||||||
|
this._WIRE = I2C.openSync(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
I2CBusWireAdapter.prototype.writeByte = function(value) {
|
||||||
|
return this._WIRE.sendByteSync(this._ADDRESS, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
I2CBusWireAdapter.prototype.writeBytes = function(cmd, values) {
|
||||||
|
if (!Buffer.isBuffer(values)) {
|
||||||
|
values = new Buffer(values);
|
||||||
|
}
|
||||||
|
return this._WIRE.writeI2cBlockSync(this._ADDRESS, cmd, values.length, values);
|
||||||
|
};
|
||||||
|
|
||||||
|
I2CBusWireAdapter.prototype.readByte = function(cmd) {
|
||||||
|
if (cmd != null) {
|
||||||
|
return this._WIRE.readByteSync(this._ADDRESS, cmd);
|
||||||
|
} else {
|
||||||
|
return this._WIRE.receiveByteSync(this._ADDRESS);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return I2CBusWireAdapter;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
module.exports = I2CBusWireAdapter;
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
300
node_modules/adafruit-i2c-lcd/lib/adafruit_i2c_lcd.js
generated
vendored
Normal file
300
node_modules/adafruit-i2c-lcd/lib/adafruit_i2c_lcd.js
generated
vendored
Normal file
|
|
@ -0,0 +1,300 @@
|
||||||
|
// Generated by CoffeeScript 1.12.7
|
||||||
|
(function() {
|
||||||
|
var EventEmitter, LCD_BLINKOFF, LCD_BLINKON, LCD_CLEARDISPLAY, LCD_CURSORMOVE, LCD_CURSOROFF, LCD_CURSORON, LCD_CURSORSHIFT, LCD_DISPLAYCONTROL, LCD_DISPLAYMOVE, LCD_DISPLAYOFF, LCD_DISPLAYON, LCD_ENTRYLEFT, LCD_ENTRYMODESET, LCD_ENTRYRIGHT, LCD_ENTRYSHIFTDECREMENT, LCD_ENTRYSHIFTINCREMENT, LCD_FUNCTIONSET, LCD_MOVELEFT, LCD_MOVERIGHT, LCD_RETURNHOME, LCD_SETCGRAMADDR, LCD_SETDDRAMADDR, MCP23017_GPIOA, MCP23017_GPIOB, MCP23017_IOCON_BANK0, MCP23017_IOCON_BANK1, MCP23017_IODIRB, Plate, WireAdapter, flip, pollables,
|
||||||
|
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||||
|
hasProp = {}.hasOwnProperty;
|
||||||
|
|
||||||
|
MCP23017_IOCON_BANK0 = 0x0A;
|
||||||
|
|
||||||
|
MCP23017_IOCON_BANK1 = 0x15;
|
||||||
|
|
||||||
|
MCP23017_GPIOA = 0x09;
|
||||||
|
|
||||||
|
MCP23017_IODIRB = 0x10;
|
||||||
|
|
||||||
|
MCP23017_GPIOB = 0x19;
|
||||||
|
|
||||||
|
LCD_CLEARDISPLAY = 0x01;
|
||||||
|
|
||||||
|
LCD_RETURNHOME = 0x02;
|
||||||
|
|
||||||
|
LCD_ENTRYMODESET = 0x04;
|
||||||
|
|
||||||
|
LCD_DISPLAYCONTROL = 0x08;
|
||||||
|
|
||||||
|
LCD_CURSORSHIFT = 0x10;
|
||||||
|
|
||||||
|
LCD_FUNCTIONSET = 0x20;
|
||||||
|
|
||||||
|
LCD_SETCGRAMADDR = 0x40;
|
||||||
|
|
||||||
|
LCD_SETDDRAMADDR = 0x80;
|
||||||
|
|
||||||
|
LCD_DISPLAYON = 0x04;
|
||||||
|
|
||||||
|
LCD_DISPLAYOFF = 0x00;
|
||||||
|
|
||||||
|
LCD_CURSORON = 0x02;
|
||||||
|
|
||||||
|
LCD_CURSOROFF = 0x00;
|
||||||
|
|
||||||
|
LCD_BLINKON = 0x01;
|
||||||
|
|
||||||
|
LCD_BLINKOFF = 0x00;
|
||||||
|
|
||||||
|
LCD_ENTRYRIGHT = 0x00;
|
||||||
|
|
||||||
|
LCD_ENTRYLEFT = 0x02;
|
||||||
|
|
||||||
|
LCD_ENTRYSHIFTINCREMENT = 0x01;
|
||||||
|
|
||||||
|
LCD_ENTRYSHIFTDECREMENT = 0x00;
|
||||||
|
|
||||||
|
LCD_DISPLAYMOVE = 0x08;
|
||||||
|
|
||||||
|
LCD_CURSORMOVE = 0x00;
|
||||||
|
|
||||||
|
LCD_MOVERIGHT = 0x04;
|
||||||
|
|
||||||
|
LCD_MOVELEFT = 0x00;
|
||||||
|
|
||||||
|
flip = [0x00, 0x10, 0x08, 0x18, 0x04, 0x14, 0x0C, 0x1C, 0x02, 0x12, 0x0A, 0x1A, 0x06, 0x16, 0x0E, 0x1E];
|
||||||
|
|
||||||
|
pollables = [LCD_CLEARDISPLAY, LCD_RETURNHOME];
|
||||||
|
|
||||||
|
EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
|
WireAdapter = require('./I2CBusWireAdapter');
|
||||||
|
|
||||||
|
Plate = (function(superClass) {
|
||||||
|
extend(Plate, superClass);
|
||||||
|
|
||||||
|
function Plate(device, address, pollInterval) {
|
||||||
|
this.ADDRESS = address;
|
||||||
|
this.PORTA = 0;
|
||||||
|
this.PORTB = 0;
|
||||||
|
this.DDRB = 0x10;
|
||||||
|
this.WIRE = new WireAdapter(device, address);
|
||||||
|
if (pollInterval == null) {
|
||||||
|
pollInterval = 200;
|
||||||
|
}
|
||||||
|
this.init();
|
||||||
|
this.BSTATE = 0;
|
||||||
|
if (pollInterval > 0) {
|
||||||
|
this.poll = setInterval((function(_this) {
|
||||||
|
return function() {
|
||||||
|
var cur, key;
|
||||||
|
cur = _this.buttonState();
|
||||||
|
if (cur !== _this.BSTATE) {
|
||||||
|
key = _this.BSTATE ^ cur;
|
||||||
|
_this.emit('button_change', key);
|
||||||
|
if (cur < _this.BSTATE) {
|
||||||
|
_this.emit('button_up', key);
|
||||||
|
} else {
|
||||||
|
_this.emit('button_down', key);
|
||||||
|
}
|
||||||
|
return _this.BSTATE = cur;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(this), pollInterval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Plate.prototype.colors = {
|
||||||
|
OFF: 0x00,
|
||||||
|
RED: 0x01,
|
||||||
|
GREEN: 0x02,
|
||||||
|
BLUE: 0x04,
|
||||||
|
YELLOW: 0x03,
|
||||||
|
TEAL: 0x06,
|
||||||
|
VIOLET: 0x05,
|
||||||
|
WHITE: 0x07,
|
||||||
|
ON: 0x07
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.buttons = {
|
||||||
|
SELECT: 0x01,
|
||||||
|
RIGHT: 0x02,
|
||||||
|
DOWN: 0x04,
|
||||||
|
UP: 0x08,
|
||||||
|
LEFT: 0x10
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.clear = function() {
|
||||||
|
return this.writeByte(LCD_CLEARDISPLAY);
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.home = function() {
|
||||||
|
return this.writeByte(LCD_RETURNHOME);
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.close = function() {
|
||||||
|
if (this.poll != null) {
|
||||||
|
return clearInterval(this.poll);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.backlight = function(color) {
|
||||||
|
var c;
|
||||||
|
c = ~color;
|
||||||
|
this.PORTA = (this.PORTA & 0x3F) | ((c & 0x3) << 6);
|
||||||
|
this.PORTB = (this.PORTB & 0xFE) | ((c & 0x4) >> 2);
|
||||||
|
this.sendBytes(MCP23017_GPIOA, this.PORTA);
|
||||||
|
return this.sendBytes(MCP23017_GPIOB, this.PORTB);
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.message = function(text, clear) {
|
||||||
|
var i, j, len, line, lines, results;
|
||||||
|
if (clear) {
|
||||||
|
this.clear();
|
||||||
|
}
|
||||||
|
lines = text.split('\n');
|
||||||
|
results = [];
|
||||||
|
for (i = j = 0, len = lines.length; j < len; i = ++j) {
|
||||||
|
line = lines[i];
|
||||||
|
if (i === 1) {
|
||||||
|
this.writeByte(0xC0);
|
||||||
|
}
|
||||||
|
if (i < 2) {
|
||||||
|
results.push(this.writeByte(line, true));
|
||||||
|
} else {
|
||||||
|
results.push(void 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.buttonState = function() {
|
||||||
|
var ret;
|
||||||
|
ret = this.WIRE.readByte(MCP23017_GPIOA);
|
||||||
|
return ret & 0x1F;
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.buttonName = function(val) {
|
||||||
|
switch (val) {
|
||||||
|
case this.buttons.SELECT:
|
||||||
|
return "SELECT";
|
||||||
|
case this.buttons.RIGHT:
|
||||||
|
return "RIGHT";
|
||||||
|
case this.buttons.UP:
|
||||||
|
return "UP";
|
||||||
|
case this.buttons.DOWN:
|
||||||
|
return "DOWN";
|
||||||
|
case this.buttons.LEFT:
|
||||||
|
return "LEFT";
|
||||||
|
default:
|
||||||
|
return void 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.createChar = function(location, pattern) {
|
||||||
|
var data, j, len;
|
||||||
|
location = location & 0x7;
|
||||||
|
this.writeByte(LCD_SETCGRAMADDR | (location << 3));
|
||||||
|
for (j = 0, len = pattern.length; j < len; j++) {
|
||||||
|
data = pattern[j];
|
||||||
|
this.writeByte(data, true);
|
||||||
|
}
|
||||||
|
return this.clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.init = function() {
|
||||||
|
var displaycontrol, displaymode, displayshift;
|
||||||
|
this.sendBytes(MCP23017_IOCON_BANK1, 0);
|
||||||
|
this.sendBytes(0, [0x3F, this.DDRB, 0x3F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3F, 0x0, 0x0, 0x0, 0x0, 0x0, this.PORTA, this.PORTB, this.PORTA, this.PORTB]);
|
||||||
|
this.sendBytes(MCP23017_IOCON_BANK0, 0xA0);
|
||||||
|
displayshift = LCD_CURSORMOVE | LCD_MOVERIGHT;
|
||||||
|
displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
|
||||||
|
displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
|
||||||
|
this.writeByte(0x33);
|
||||||
|
this.writeByte(0x32);
|
||||||
|
this.writeByte(0x28);
|
||||||
|
this.writeByte(LCD_CLEARDISPLAY);
|
||||||
|
this.writeByte(LCD_CURSORSHIFT | displayshift);
|
||||||
|
this.writeByte(LCD_ENTRYMODESET | displaymode);
|
||||||
|
this.writeByte(LCD_DISPLAYCONTROL | displaycontrol);
|
||||||
|
this.writeByte(LCD_RETURNHOME);
|
||||||
|
this.clear;
|
||||||
|
return this.backlight(0x0);
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.sendBytes = function(cmd, values) {
|
||||||
|
var data, reg;
|
||||||
|
reg = cmd;
|
||||||
|
if (typeof values === 'number') {
|
||||||
|
data = [];
|
||||||
|
data.push(values);
|
||||||
|
values = data;
|
||||||
|
}
|
||||||
|
return this.WIRE.writeBytes(cmd, values);
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.sendByte = function(value) {
|
||||||
|
return this.WIRE.writeByte(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.maskOut = function(bitmask, value) {
|
||||||
|
var hi, lo;
|
||||||
|
hi = bitmask | flip[value >> 4];
|
||||||
|
lo = bitmask | flip[value & 0x0F];
|
||||||
|
return [hi | 0x20, hi, lo | 0x20, lo];
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.writeByte = function(value, char_mode) {
|
||||||
|
var bitmask, bits, data, hi, j, k, last, lo, ref;
|
||||||
|
char_mode = char_mode || false;
|
||||||
|
if (this.DDRB & 0x10) {
|
||||||
|
lo = (this.PORTB & 0x01) | 0x40;
|
||||||
|
hi = lo | 0x20;
|
||||||
|
this.sendBytes(MCP23017_GPIOB, lo);
|
||||||
|
while (true) {
|
||||||
|
this.sendByte(hi);
|
||||||
|
bits = this.readByte();
|
||||||
|
this.sendBytes(MCP23017_GPIOB, [lo, hi, lo]);
|
||||||
|
if ((bits & 0x2) === 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.PORTB = lo;
|
||||||
|
this.DDRB &= 0xEF;
|
||||||
|
this.sendBytes(MCP23017_IODIRB, this.DDRB);
|
||||||
|
}
|
||||||
|
bitmask = this.PORTB & 0x01;
|
||||||
|
if (char_mode) {
|
||||||
|
bitmask |= 0x80;
|
||||||
|
}
|
||||||
|
if (typeof value === "string") {
|
||||||
|
last = value.length - 1;
|
||||||
|
data = [];
|
||||||
|
for (k = j = 0, ref = last; 0 <= ref ? j <= ref : j >= ref; k = 0 <= ref ? ++j : --j) {
|
||||||
|
if (value[k] != null) {
|
||||||
|
data = data.concat(this.maskOut(bitmask, value[k].charCodeAt(0)));
|
||||||
|
if (data.length >= 32 || k === last) {
|
||||||
|
this.sendBytes(MCP23017_GPIOB, data);
|
||||||
|
this.PORTB = data[data.length - 1];
|
||||||
|
data = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data = this.maskOut(bitmask, value);
|
||||||
|
this.sendBytes(MCP23017_GPIOB, data);
|
||||||
|
this.PORTB = data[data.length - 1];
|
||||||
|
}
|
||||||
|
if (!char_mode && pollables.indexOf(value) !== -1) {
|
||||||
|
this.DDRB |= 0x10;
|
||||||
|
return this.sendBytes(MCP23017_IODIRB, this.DDRB);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Plate.prototype.readByte = function() {
|
||||||
|
return this.WIRE.readByte();
|
||||||
|
};
|
||||||
|
|
||||||
|
return Plate;
|
||||||
|
|
||||||
|
})(EventEmitter);
|
||||||
|
|
||||||
|
module.exports = Plate;
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
5
node_modules/adafruit-i2c-lcd/lib/index.js
generated
vendored
Normal file
5
node_modules/adafruit-i2c-lcd/lib/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
// Generated by CoffeeScript 1.12.7
|
||||||
|
(function() {
|
||||||
|
module.exports.plate = require('./adafruit_i2c_lcd');
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
30
node_modules/adafruit-i2c-lcd/package.json
generated
vendored
Normal file
30
node_modules/adafruit-i2c-lcd/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "adafruit-i2c-lcd",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"description": "Node Library for using adafruit i2c rgb lcd pi plate",
|
||||||
|
"main": "./lib/index.js",
|
||||||
|
"dependencies": {
|
||||||
|
"i2c-bus": "^5.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"coffee-script": ""
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "node_modules/coffee-script/bin/coffee -o lib -c src"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/fehmer/adafruit-i2c-lcd.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"raspberry",
|
||||||
|
"pi",
|
||||||
|
"adafruit",
|
||||||
|
"i2c",
|
||||||
|
"lcd",
|
||||||
|
"rgb",
|
||||||
|
"plate"
|
||||||
|
],
|
||||||
|
"author": "Christian Fehmer",
|
||||||
|
"license": "BSD-2-Clause"
|
||||||
|
}
|
||||||
22
node_modules/bindings/LICENSE.md
generated
vendored
Normal file
22
node_modules/bindings/LICENSE.md
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>
|
||||||
|
|
||||||
|
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.
|
||||||
98
node_modules/bindings/README.md
generated
vendored
Normal file
98
node_modules/bindings/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
node-bindings
|
||||||
|
=============
|
||||||
|
### Helper module for loading your native module's `.node` file
|
||||||
|
|
||||||
|
This is a helper module for authors of Node.js native addon modules.
|
||||||
|
It is basically the "swiss army knife" of `require()`ing your native module's
|
||||||
|
`.node` file.
|
||||||
|
|
||||||
|
Throughout the course of Node's native addon history, addons have ended up being
|
||||||
|
compiled in a variety of different places, depending on which build tool and which
|
||||||
|
version of node was used. To make matters worse, now the `gyp` build tool can
|
||||||
|
produce either a __Release__ or __Debug__ build, each being built into different
|
||||||
|
locations.
|
||||||
|
|
||||||
|
This module checks _all_ the possible locations that a native addon would be built
|
||||||
|
at, and returns the first one that loads successfully.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
Install with `npm`:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
$ npm install --save bindings
|
||||||
|
```
|
||||||
|
|
||||||
|
Or add it to the `"dependencies"` section of your `package.json` file.
|
||||||
|
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
`require()`ing the proper bindings file for the current node version, platform
|
||||||
|
and architecture is as simple as:
|
||||||
|
|
||||||
|
``` js
|
||||||
|
var bindings = require('bindings')('binding.node')
|
||||||
|
|
||||||
|
// Use your bindings defined in your C files
|
||||||
|
bindings.your_c_function()
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Nice Error Output
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
When the `.node` file could not be loaded, `node-bindings` throws an Error with
|
||||||
|
a nice error message telling you exactly what was tried. You can also check the
|
||||||
|
`err.tries` Array property.
|
||||||
|
|
||||||
|
```
|
||||||
|
Error: Could not load the bindings file. Tried:
|
||||||
|
→ /Users/nrajlich/ref/build/binding.node
|
||||||
|
→ /Users/nrajlich/ref/build/Debug/binding.node
|
||||||
|
→ /Users/nrajlich/ref/build/Release/binding.node
|
||||||
|
→ /Users/nrajlich/ref/out/Debug/binding.node
|
||||||
|
→ /Users/nrajlich/ref/Debug/binding.node
|
||||||
|
→ /Users/nrajlich/ref/out/Release/binding.node
|
||||||
|
→ /Users/nrajlich/ref/Release/binding.node
|
||||||
|
→ /Users/nrajlich/ref/build/default/binding.node
|
||||||
|
→ /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node
|
||||||
|
at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13)
|
||||||
|
at Object.<anonymous> (/Users/nrajlich/ref/lib/ref.js:5:47)
|
||||||
|
at Module._compile (module.js:449:26)
|
||||||
|
at Object.Module._extensions..js (module.js:467:10)
|
||||||
|
at Module.load (module.js:356:32)
|
||||||
|
at Function.Module._load (module.js:312:12)
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
The searching for the `.node` file will originate from the first directory in which has a `package.json` file is found.
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>
|
||||||
|
|
||||||
|
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.
|
||||||
221
node_modules/bindings/bindings.js
generated
vendored
Normal file
221
node_modules/bindings/bindings.js
generated
vendored
Normal file
|
|
@ -0,0 +1,221 @@
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var fs = require('fs'),
|
||||||
|
path = require('path'),
|
||||||
|
fileURLToPath = require('file-uri-to-path'),
|
||||||
|
join = path.join,
|
||||||
|
dirname = path.dirname,
|
||||||
|
exists =
|
||||||
|
(fs.accessSync &&
|
||||||
|
function(path) {
|
||||||
|
try {
|
||||||
|
fs.accessSync(path);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}) ||
|
||||||
|
fs.existsSync ||
|
||||||
|
path.existsSync,
|
||||||
|
defaults = {
|
||||||
|
arrow: process.env.NODE_BINDINGS_ARROW || ' → ',
|
||||||
|
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled',
|
||||||
|
platform: process.platform,
|
||||||
|
arch: process.arch,
|
||||||
|
nodePreGyp:
|
||||||
|
'node-v' +
|
||||||
|
process.versions.modules +
|
||||||
|
'-' +
|
||||||
|
process.platform +
|
||||||
|
'-' +
|
||||||
|
process.arch,
|
||||||
|
version: process.versions.node,
|
||||||
|
bindings: 'bindings.node',
|
||||||
|
try: [
|
||||||
|
// node-gyp's linked version in the "build" dir
|
||||||
|
['module_root', 'build', 'bindings'],
|
||||||
|
// node-waf and gyp_addon (a.k.a node-gyp)
|
||||||
|
['module_root', 'build', 'Debug', 'bindings'],
|
||||||
|
['module_root', 'build', 'Release', 'bindings'],
|
||||||
|
// Debug files, for development (legacy behavior, remove for node v0.9)
|
||||||
|
['module_root', 'out', 'Debug', 'bindings'],
|
||||||
|
['module_root', 'Debug', 'bindings'],
|
||||||
|
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
||||||
|
['module_root', 'out', 'Release', 'bindings'],
|
||||||
|
['module_root', 'Release', 'bindings'],
|
||||||
|
// Legacy from node-waf, node <= 0.4.x
|
||||||
|
['module_root', 'build', 'default', 'bindings'],
|
||||||
|
// Production "Release" buildtype binary (meh...)
|
||||||
|
['module_root', 'compiled', 'version', 'platform', 'arch', 'bindings'],
|
||||||
|
// node-qbs builds
|
||||||
|
['module_root', 'addon-build', 'release', 'install-root', 'bindings'],
|
||||||
|
['module_root', 'addon-build', 'debug', 'install-root', 'bindings'],
|
||||||
|
['module_root', 'addon-build', 'default', 'install-root', 'bindings'],
|
||||||
|
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
|
||||||
|
['module_root', 'lib', 'binding', 'nodePreGyp', 'bindings']
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main `bindings()` function loads the compiled bindings for a given module.
|
||||||
|
* It uses V8's Error API to determine the parent filename that this function is
|
||||||
|
* being invoked from, which is then used to find the root directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function bindings(opts) {
|
||||||
|
// Argument surgery
|
||||||
|
if (typeof opts == 'string') {
|
||||||
|
opts = { bindings: opts };
|
||||||
|
} else if (!opts) {
|
||||||
|
opts = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// maps `defaults` onto `opts` object
|
||||||
|
Object.keys(defaults).map(function(i) {
|
||||||
|
if (!(i in opts)) opts[i] = defaults[i];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get the module root
|
||||||
|
if (!opts.module_root) {
|
||||||
|
opts.module_root = exports.getRoot(exports.getFileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the given bindings name ends with .node
|
||||||
|
if (path.extname(opts.bindings) != '.node') {
|
||||||
|
opts.bindings += '.node';
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/webpack/webpack/issues/4175#issuecomment-342931035
|
||||||
|
var requireFunc =
|
||||||
|
typeof __webpack_require__ === 'function'
|
||||||
|
? __non_webpack_require__
|
||||||
|
: require;
|
||||||
|
|
||||||
|
var tries = [],
|
||||||
|
i = 0,
|
||||||
|
l = opts.try.length,
|
||||||
|
n,
|
||||||
|
b,
|
||||||
|
err;
|
||||||
|
|
||||||
|
for (; i < l; i++) {
|
||||||
|
n = join.apply(
|
||||||
|
null,
|
||||||
|
opts.try[i].map(function(p) {
|
||||||
|
return opts[p] || p;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
tries.push(n);
|
||||||
|
try {
|
||||||
|
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
||||||
|
if (!opts.path) {
|
||||||
|
b.path = n;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code !== 'MODULE_NOT_FOUND' &&
|
||||||
|
e.code !== 'QUALIFIED_PATH_RESOLUTION_FAILED' &&
|
||||||
|
!/not find/i.test(e.message)) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = new Error(
|
||||||
|
'Could not locate the bindings file. Tried:\n' +
|
||||||
|
tries
|
||||||
|
.map(function(a) {
|
||||||
|
return opts.arrow + a;
|
||||||
|
})
|
||||||
|
.join('\n')
|
||||||
|
);
|
||||||
|
err.tries = tries;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
module.exports = exports = bindings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the filename of the JavaScript file that invokes this function.
|
||||||
|
* Used to help find the root directory of a module.
|
||||||
|
* Optionally accepts an filename argument to skip when searching for the invoking filename
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.getFileName = function getFileName(calling_file) {
|
||||||
|
var origPST = Error.prepareStackTrace,
|
||||||
|
origSTL = Error.stackTraceLimit,
|
||||||
|
dummy = {},
|
||||||
|
fileName;
|
||||||
|
|
||||||
|
Error.stackTraceLimit = 10;
|
||||||
|
|
||||||
|
Error.prepareStackTrace = function(e, st) {
|
||||||
|
for (var i = 0, l = st.length; i < l; i++) {
|
||||||
|
fileName = st[i].getFileName();
|
||||||
|
if (fileName !== __filename) {
|
||||||
|
if (calling_file) {
|
||||||
|
if (fileName !== calling_file) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// run the 'prepareStackTrace' function above
|
||||||
|
Error.captureStackTrace(dummy);
|
||||||
|
dummy.stack;
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
Error.prepareStackTrace = origPST;
|
||||||
|
Error.stackTraceLimit = origSTL;
|
||||||
|
|
||||||
|
// handle filename that starts with "file://"
|
||||||
|
var fileSchema = 'file://';
|
||||||
|
if (fileName.indexOf(fileSchema) === 0) {
|
||||||
|
fileName = fileURLToPath(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileName;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the root directory of a module, given an arbitrary filename
|
||||||
|
* somewhere in the module tree. The "root directory" is the directory
|
||||||
|
* containing the `package.json` file.
|
||||||
|
*
|
||||||
|
* In: /home/nate/node-native-module/lib/index.js
|
||||||
|
* Out: /home/nate/node-native-module
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.getRoot = function getRoot(file) {
|
||||||
|
var dir = dirname(file),
|
||||||
|
prev;
|
||||||
|
while (true) {
|
||||||
|
if (dir === '.') {
|
||||||
|
// Avoids an infinite loop in rare cases, like the REPL
|
||||||
|
dir = process.cwd();
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
exists(join(dir, 'package.json')) ||
|
||||||
|
exists(join(dir, 'node_modules'))
|
||||||
|
) {
|
||||||
|
// Found the 'package.json' file or 'node_modules' dir; we're done
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
if (prev === dir) {
|
||||||
|
// Got to the top
|
||||||
|
throw new Error(
|
||||||
|
'Could not find module root given file: "' +
|
||||||
|
file +
|
||||||
|
'". Do you have a `package.json` file? '
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Try the parent dir next
|
||||||
|
prev = dir;
|
||||||
|
dir = join(dir, '..');
|
||||||
|
}
|
||||||
|
};
|
||||||
28
node_modules/bindings/package.json
generated
vendored
Normal file
28
node_modules/bindings/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"name": "bindings",
|
||||||
|
"description": "Helper module for loading your native module's .node file",
|
||||||
|
"keywords": [
|
||||||
|
"native",
|
||||||
|
"addon",
|
||||||
|
"bindings",
|
||||||
|
"gyp",
|
||||||
|
"waf",
|
||||||
|
"c",
|
||||||
|
"c++"
|
||||||
|
],
|
||||||
|
"version": "1.5.0",
|
||||||
|
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/TooTallNate/node-bindings.git"
|
||||||
|
},
|
||||||
|
"main": "./bindings.js",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/TooTallNate/node-bindings/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/TooTallNate/node-bindings",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"file-uri-to-path": "1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
node_modules/file-uri-to-path/.npmignore
generated
vendored
Normal file
1
node_modules/file-uri-to-path/.npmignore
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/node_modules
|
||||||
30
node_modules/file-uri-to-path/.travis.yml
generated
vendored
Normal file
30
node_modules/file-uri-to-path/.travis.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
language: node_js
|
||||||
|
|
||||||
|
node_js:
|
||||||
|
- "0.8"
|
||||||
|
- "0.10"
|
||||||
|
- "0.12"
|
||||||
|
- "1"
|
||||||
|
- "2"
|
||||||
|
- "3"
|
||||||
|
- "4"
|
||||||
|
- "5"
|
||||||
|
- "6"
|
||||||
|
- "7"
|
||||||
|
- "8"
|
||||||
|
|
||||||
|
install:
|
||||||
|
- PATH="`npm bin`:`npm bin -g`:$PATH"
|
||||||
|
# Node 0.8 comes with a too obsolete npm
|
||||||
|
- if [[ "`node --version`" =~ ^v0\.8\. ]]; then npm install -g npm@1.4.28 ; fi
|
||||||
|
# Install dependencies and build
|
||||||
|
- npm install
|
||||||
|
|
||||||
|
script:
|
||||||
|
# Output useful info for debugging
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
# Run tests
|
||||||
|
- npm test
|
||||||
21
node_modules/file-uri-to-path/History.md
generated
vendored
Normal file
21
node_modules/file-uri-to-path/History.md
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
1.0.0 / 2017-07-06
|
||||||
|
==================
|
||||||
|
|
||||||
|
* update "mocha" to v3
|
||||||
|
* fixed unicode URI decoding (#6)
|
||||||
|
* add typings for Typescript
|
||||||
|
* README: use SVG Travis-CI badge
|
||||||
|
* add LICENSE file (MIT)
|
||||||
|
* add .travis.yml file (testing Node.js 0.8 through 8 currently)
|
||||||
|
* add README.md file
|
||||||
|
|
||||||
|
0.0.2 / 2014-01-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* index: invert the path separators on Windows
|
||||||
|
|
||||||
|
0.0.1 / 2014-01-27
|
||||||
|
==================
|
||||||
|
|
||||||
|
* initial commit
|
||||||
20
node_modules/file-uri-to-path/LICENSE
generated
vendored
Normal file
20
node_modules/file-uri-to-path/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
|
||||||
|
|
||||||
|
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.
|
||||||
74
node_modules/file-uri-to-path/README.md
generated
vendored
Normal file
74
node_modules/file-uri-to-path/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
file-uri-to-path
|
||||||
|
================
|
||||||
|
### Convert a `file:` URI to a file path
|
||||||
|
[](https://travis-ci.org/TooTallNate/file-uri-to-path)
|
||||||
|
|
||||||
|
Accepts a `file:` URI and returns a regular file path suitable for use with the
|
||||||
|
`fs` module functions.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
Install with `npm`:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
$ npm install file-uri-to-path
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Example
|
||||||
|
-------
|
||||||
|
|
||||||
|
``` js
|
||||||
|
var uri2path = require('file-uri-to-path');
|
||||||
|
|
||||||
|
uri2path('file://localhost/c|/WINDOWS/clock.avi');
|
||||||
|
// "c:\\WINDOWS\\clock.avi"
|
||||||
|
|
||||||
|
uri2path('file:///c|/WINDOWS/clock.avi');
|
||||||
|
// "c:\\WINDOWS\\clock.avi"
|
||||||
|
|
||||||
|
uri2path('file://localhost/c:/WINDOWS/clock.avi');
|
||||||
|
// "c:\\WINDOWS\\clock.avi"
|
||||||
|
|
||||||
|
uri2path('file://hostname/path/to/the%20file.txt');
|
||||||
|
// "\\\\hostname\\path\\to\\the file.txt"
|
||||||
|
|
||||||
|
uri2path('file:///c:/path/to/the%20file.txt');
|
||||||
|
// "c:\\path\\to\\the file.txt"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
API
|
||||||
|
---
|
||||||
|
|
||||||
|
### fileUriToPath(String uri) → String
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
|
||||||
|
|
||||||
|
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.
|
||||||
2
node_modules/file-uri-to-path/index.d.ts
generated
vendored
Normal file
2
node_modules/file-uri-to-path/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
declare function fileUriToPath(uri: string): string;
|
||||||
|
export = fileUriToPath;
|
||||||
66
node_modules/file-uri-to-path/index.js
generated
vendored
Normal file
66
node_modules/file-uri-to-path/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var sep = require('path').sep || '/';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module exports.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = fileUriToPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File URI to Path function.
|
||||||
|
*
|
||||||
|
* @param {String} uri
|
||||||
|
* @return {String} path
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function fileUriToPath (uri) {
|
||||||
|
if ('string' != typeof uri ||
|
||||||
|
uri.length <= 7 ||
|
||||||
|
'file://' != uri.substring(0, 7)) {
|
||||||
|
throw new TypeError('must pass in a file:// URI to convert to a file path');
|
||||||
|
}
|
||||||
|
|
||||||
|
var rest = decodeURI(uri.substring(7));
|
||||||
|
var firstSlash = rest.indexOf('/');
|
||||||
|
var host = rest.substring(0, firstSlash);
|
||||||
|
var path = rest.substring(firstSlash + 1);
|
||||||
|
|
||||||
|
// 2. Scheme Definition
|
||||||
|
// As a special case, <host> can be the string "localhost" or the empty
|
||||||
|
// string; this is interpreted as "the machine from which the URL is
|
||||||
|
// being interpreted".
|
||||||
|
if ('localhost' == host) host = '';
|
||||||
|
|
||||||
|
if (host) {
|
||||||
|
host = sep + sep + host;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.2 Drives, drive letters, mount points, file system root
|
||||||
|
// Drive letters are mapped into the top of a file URI in various ways,
|
||||||
|
// depending on the implementation; some applications substitute
|
||||||
|
// vertical bar ("|") for the colon after the drive letter, yielding
|
||||||
|
// "file:///c|/tmp/test.txt". In some cases, the colon is left
|
||||||
|
// unchanged, as in "file:///c:/tmp/test.txt". In other cases, the
|
||||||
|
// colon is simply omitted, as in "file:///c/tmp/test.txt".
|
||||||
|
path = path.replace(/^(.+)\|/, '$1:');
|
||||||
|
|
||||||
|
// for Windows, we need to invert the path separators from what a URI uses
|
||||||
|
if (sep == '\\') {
|
||||||
|
path = path.replace(/\//g, '\\');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^.+\:/.test(path)) {
|
||||||
|
// has Windows drive at beginning of path
|
||||||
|
} else {
|
||||||
|
// unix path…
|
||||||
|
path = sep + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return host + path;
|
||||||
|
}
|
||||||
32
node_modules/file-uri-to-path/package.json
generated
vendored
Normal file
32
node_modules/file-uri-to-path/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
"name": "file-uri-to-path",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Convert a file: URI to a file path",
|
||||||
|
"main": "index.js",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"directories": {
|
||||||
|
"test": "test"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha --reporter spec"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/TooTallNate/file-uri-to-path.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"file",
|
||||||
|
"uri",
|
||||||
|
"convert",
|
||||||
|
"path"
|
||||||
|
],
|
||||||
|
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/TooTallNate/file-uri-to-path/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/TooTallNate/file-uri-to-path",
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "3"
|
||||||
|
}
|
||||||
|
}
|
||||||
24
node_modules/file-uri-to-path/test/test.js
generated
vendored
Normal file
24
node_modules/file-uri-to-path/test/test.js
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
var sep = require('path').sep || '/';
|
||||||
|
var assert = require('assert');
|
||||||
|
var uri2path = require('../');
|
||||||
|
var tests = require('./tests.json');
|
||||||
|
|
||||||
|
describe('file-uri-to-path', function () {
|
||||||
|
|
||||||
|
Object.keys(tests).forEach(function (uri) {
|
||||||
|
|
||||||
|
// the test cases were generated from Windows' PathCreateFromUrlA() function.
|
||||||
|
// On Unix, we have to replace the path separator with the Unix one instead of
|
||||||
|
// the Windows one.
|
||||||
|
var expected = tests[uri].replace(/\\/g, sep);
|
||||||
|
|
||||||
|
it('should convert ' + JSON.stringify(uri) + ' to ' + JSON.stringify(expected),
|
||||||
|
function () {
|
||||||
|
var actual = uri2path(uri);
|
||||||
|
assert.equal(actual, expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
13
node_modules/file-uri-to-path/test/tests.json
generated
vendored
Normal file
13
node_modules/file-uri-to-path/test/tests.json
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"file://host/path": "\\\\host\\path",
|
||||||
|
"file://localhost/etc/fstab": "\\etc\\fstab",
|
||||||
|
"file:///etc/fstab": "\\etc\\fstab",
|
||||||
|
"file:///c:/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
|
||||||
|
"file://localhost/c|/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
|
||||||
|
"file:///c|/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
|
||||||
|
"file://localhost/c:/WINDOWS/clock.avi": "c:\\WINDOWS\\clock.avi",
|
||||||
|
"file://hostname/path/to/the%20file.txt": "\\\\hostname\\path\\to\\the file.txt",
|
||||||
|
"file:///c:/path/to/the%20file.txt": "c:\\path\\to\\the file.txt",
|
||||||
|
"file:///C:/Documents%20and%20Settings/davris/FileSchemeURIs.doc": "C:\\Documents and Settings\\davris\\FileSchemeURIs.doc",
|
||||||
|
"file:///C:/caf%C3%A9/%C3%A5r/d%C3%BCnn/%E7%89%9B%E9%93%83/Ph%E1%BB%9F/%F0%9F%98%B5.exe": "C:\\café\\år\\dünn\\牛铃\\Phở\\😵.exe"
|
||||||
|
}
|
||||||
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"
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
354
node_modules/i2c-bus/build/Makefile
generated
vendored
Normal file
354
node_modules/i2c-bus/build/Makefile
generated
vendored
Normal file
|
|
@ -0,0 +1,354 @@
|
||||||
|
# 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)
|
||||||
|
PLI.target ?= pli
|
||||||
|
|
||||||
|
# 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
|
||||||
|
PLI.host ?= pli
|
||||||
|
|
||||||
|
# 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_symlink = SYMLINK $@
|
||||||
|
cmd_symlink = ln -sf "$<" "$@"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# Note: this does not handle spaces in paths
|
||||||
|
define xargs
|
||||||
|
$(1) $(word 1,$(2))
|
||||||
|
$(if $(word 2,$(2)),$(call xargs,$(1),$(wordlist 2,$(words $(2)),$(2))))
|
||||||
|
endef
|
||||||
|
|
||||||
|
define write-to-file
|
||||||
|
@: >$(1)
|
||||||
|
$(call xargs,@printf "%s\n" >>$(1),$(2))
|
||||||
|
endef
|
||||||
|
|
||||||
|
OBJ_FILE_LIST := ar-file-list
|
||||||
|
|
||||||
|
define create_archive
|
||||||
|
rm -f $(1) $(1).$(OBJ_FILE_LIST); mkdir -p `dirname $(1)`
|
||||||
|
$(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2)))
|
||||||
|
$(AR.$(TOOLSET)) crs $(1) @$(1).$(OBJ_FILE_LIST)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define create_thin_archive
|
||||||
|
rm -f $(1) $(OBJ_FILE_LIST); mkdir -p `dirname $(1)`
|
||||||
|
$(call write-to-file,$(1).$(OBJ_FILE_LIST),$(filter %.o,$(2)))
|
||||||
|
$(AR.$(TOOLSET)) crsT $(1) @$(1).$(OBJ_FILE_LIST)
|
||||||
|
endef
|
||||||
|
|
||||||
|
# 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/boazsender/.volta/tools/image/node/22.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/boazsender/.cache/node-gyp/22.14.0" "-Dnode_gyp_dir=/home/boazsender/.volta/tools/image/node/22.14.0/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/home/boazsender/.cache/node-gyp/22.14.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/home/boazsender/git/portal/node_modules/i2c-bus" "-Dnode_engine=v8" "--depth=." "-Goutput_dir=." "--generator-output=build" -I/home/boazsender/git/portal/node_modules/i2c-bus/build/config.gypi -I/home/boazsender/.volta/tools/image/node/22.14.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/home/boazsender/.cache/node-gyp/22.14.0/include/node/common.gypi "--toplevel-dir=." binding.gyp
|
||||||
|
Makefile: $(srcdir)/binding.gyp $(srcdir)/../../../../.volta/tools/image/node/22.14.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/../../../../.cache/node-gyp/22.14.0/include/node/common.gypi
|
||||||
|
$(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 -m64 -Wl,-soname=i2c.node -Wl,--start-group Release/obj.target/i2c/src/i2c.o -Wl,--end-group
|
||||||
221
node_modules/i2c-bus/build/Release/.deps/Release/obj.target/i2c/src/i2c.o.d
generated
vendored
Normal file
221
node_modules/i2c-bus/build/Release/.deps/Release/obj.target/i2c/src/i2c.o.d
generated
vendored
Normal file
|
|
@ -0,0 +1,221 @@
|
||||||
|
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_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DBUILDING_NODE_EXTENSION' -I/home/boazsender/.cache/node-gyp/22.14.0/include/node -I/home/boazsender/.cache/node-gyp/22.14.0/src -I/home/boazsender/.cache/node-gyp/22.14.0/deps/openssl/config -I/home/boazsender/.cache/node-gyp/22.14.0/deps/openssl/openssl/include -I/home/boazsender/.cache/node-gyp/22.14.0/deps/uv/include -I/home/boazsender/.cache/node-gyp/22.14.0/deps/zlib -I/home/boazsender/.cache/node-gyp/22.14.0/deps/v8/include -I../../nan -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations -Wno-cast-function-type -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -fno-strict-aliasing -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/boazsender/.cache/node-gyp/22.14.0/include/node/node.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/cppgc/common.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8config.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-array-buffer.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-local-handle.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-handle-base.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-internal.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8config.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-object.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-maybe.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-persistent-handle.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-weak-callback-info.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-primitive.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-data.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-value.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-traced-handle.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-container.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-context.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-snapshot.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-isolate.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-callbacks.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-promise.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-debug.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-script.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-memory-span.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-message.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-embedder-heap.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-function-callback.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-microtask.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-statistics.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-unwinder.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-embedder-state-scope.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-date.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-exception.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-extension.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-external.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-function.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-template.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-initialization.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-platform.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-source-location.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-json.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-locker.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-microtask-queue.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-primitive-object.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-proxy.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-regexp.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-typed-array.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-value-serializer.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-version.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-wasm.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_version.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_api.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/js_native_api.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/js_native_api_types.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_api_types.h \
|
||||||
|
../../nan/nan.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_version.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/errno.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/version.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/unix.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/threadpool.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/linux.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_buffer.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node.h \
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/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/boazsender/.cache/node-gyp/22.14.0/include/node/node.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/cppgc/common.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8config.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-array-buffer.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-local-handle.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-handle-base.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-internal.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8config.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-object.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-maybe.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-persistent-handle.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-weak-callback-info.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-primitive.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-data.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-value.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-traced-handle.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-container.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-context.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-snapshot.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-isolate.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-callbacks.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-promise.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-debug.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-script.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-memory-span.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-message.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-embedder-heap.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-function-callback.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-microtask.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-statistics.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-unwinder.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-embedder-state-scope.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-date.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-exception.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-extension.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-external.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-function.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-template.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-initialization.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-platform.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-source-location.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-json.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-locker.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-microtask-queue.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-primitive-object.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-proxy.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-regexp.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-typed-array.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-value-serializer.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-version.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/v8-wasm.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_version.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_api.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/js_native_api.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/js_native_api_types.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_api_types.h:
|
||||||
|
../../nan/nan.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_version.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/errno.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/version.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/unix.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/threadpool.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/uv/linux.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node_buffer.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/include/node/node.h:
|
||||||
|
/home/boazsender/.cache/node-gyp/22.14.0/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
|
||||||
466
node_modules/i2c-bus/build/config.gypi
generated
vendored
Normal file
466
node_modules/i2c-bus/build/config.gypi
generated
vendored
Normal file
|
|
@ -0,0 +1,466 @@
|
||||||
|
# Do not edit. File was generated by node-gyp's "configure" step
|
||||||
|
{
|
||||||
|
"target_defaults": {
|
||||||
|
"cflags": [],
|
||||||
|
"configurations": {
|
||||||
|
"Debug": {
|
||||||
|
"v8_enable_v8_checks": 0,
|
||||||
|
"variables": {}
|
||||||
|
},
|
||||||
|
"Release": {
|
||||||
|
"v8_enable_v8_checks": 1,
|
||||||
|
"variables": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"default_configuration": "Release",
|
||||||
|
"defines": [],
|
||||||
|
"include_dirs": [],
|
||||||
|
"libraries": []
|
||||||
|
},
|
||||||
|
"variables": {
|
||||||
|
"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": "x64",
|
||||||
|
"icu_data_in": "../../deps/icu-tmp/icudt76l.dat",
|
||||||
|
"icu_endianness": "l",
|
||||||
|
"icu_gyp_path": "tools/icu/icu-generic.gyp",
|
||||||
|
"icu_path": "deps/icu-small",
|
||||||
|
"icu_small": "false",
|
||||||
|
"icu_ver_major": "76",
|
||||||
|
"libdir": "lib",
|
||||||
|
"llvm_version": "0.0",
|
||||||
|
"napi_build_version": "10",
|
||||||
|
"node_builtin_shareable_builtins": [
|
||||||
|
"deps/cjs-module-lexer/lexer.js",
|
||||||
|
"deps/cjs-module-lexer/dist/lexer.js",
|
||||||
|
"deps/undici/undici.js",
|
||||||
|
"deps/amaro/dist/index.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/myers_diff.js",
|
||||||
|
"lib/internal/assert/utils.js",
|
||||||
|
"lib/internal/async_context_frame.js",
|
||||||
|
"lib/internal/async_hooks.js",
|
||||||
|
"lib/internal/async_local_storage/async_context_frame.js",
|
||||||
|
"lib/internal/async_local_storage/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/data_url.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/glob.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/network.js",
|
||||||
|
"lib/internal/inspector/network_http.js",
|
||||||
|
"lib/internal/inspector/network_undici.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/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/modules/typescript.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/priority_queue.js",
|
||||||
|
"lib/internal/process/execution.js",
|
||||||
|
"lib/internal/process/finalization.js",
|
||||||
|
"lib/internal/process/per_thread.js",
|
||||||
|
"lib/internal/process/permission.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/quic/quic.js",
|
||||||
|
"lib/internal/quic/state.js",
|
||||||
|
"lib/internal/quic/stats.js",
|
||||||
|
"lib/internal/quic/symbols.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/assert.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/snapshot.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/webstorage.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/sqlite.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": 127,
|
||||||
|
"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_sqlite": "false",
|
||||||
|
"node_shared_uvwasi": "false",
|
||||||
|
"node_shared_zlib": "false",
|
||||||
|
"node_tag": "",
|
||||||
|
"node_target_type": "executable",
|
||||||
|
"node_use_amaro": "true",
|
||||||
|
"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": "true",
|
||||||
|
"ossfuzz": "false",
|
||||||
|
"shlib_suffix": "so.127",
|
||||||
|
"single_executable_application": "true",
|
||||||
|
"target_arch": "x64",
|
||||||
|
"ubsan": 0,
|
||||||
|
"use_prefix_to_find_headers": "false",
|
||||||
|
"v8_enable_31bit_smis_on_64bit_arch": 0,
|
||||||
|
"v8_enable_extensible_ro_snapshot": 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_sandbox": 0,
|
||||||
|
"v8_enable_shared_ro_heap": 1,
|
||||||
|
"v8_enable_short_builtin_calls": 1,
|
||||||
|
"v8_enable_wasm_simd256_revec": 1,
|
||||||
|
"v8_enable_webassembly": 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/boazsender/.cache/node-gyp/22.14.0",
|
||||||
|
"python": "/usr/bin/python3",
|
||||||
|
"standalone_static_library": 1,
|
||||||
|
"user_agent": "npm/10.9.2 node/v22.14.0 linux x64 workspaces/false",
|
||||||
|
"userconfig": "/home/boazsender/.npmrc",
|
||||||
|
"local_prefix": "/home/boazsender/git/portal",
|
||||||
|
"prefix": "/home/boazsender/.volta/tools/image/node/22.14.0",
|
||||||
|
"npm_version": "10.9.2",
|
||||||
|
"cache": "/home/boazsender/.npm",
|
||||||
|
"node_gyp": "/home/boazsender/.volta/tools/image/node/22.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",
|
||||||
|
"globalconfig": "/home/boazsender/.volta/tools/image/node/22.14.0/etc/npmrc",
|
||||||
|
"init_module": "/home/boazsender/.npm-init.js",
|
||||||
|
"global_prefix": "/home/boazsender/.volta/tools/image/node/22.14.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
162
node_modules/i2c-bus/build/i2c.target.mk
generated
vendored
Normal file
162
node_modules/i2c-bus/build/i2c.target.mk
generated
vendored
Normal file
|
|
@ -0,0 +1,162 @@
|
||||||
|
# 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_LARGEFILE_SOURCE' \
|
||||||
|
'-D_FILE_OFFSET_BITS=64' \
|
||||||
|
'-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 \
|
||||||
|
-m64 \
|
||||||
|
-g \
|
||||||
|
-O0
|
||||||
|
|
||||||
|
# Flags passed to only C files.
|
||||||
|
CFLAGS_C_Debug :=
|
||||||
|
|
||||||
|
# Flags passed to only C++ files.
|
||||||
|
CFLAGS_CC_Debug := \
|
||||||
|
-fno-rtti \
|
||||||
|
-fno-exceptions \
|
||||||
|
-fno-strict-aliasing \
|
||||||
|
-std=gnu++17
|
||||||
|
|
||||||
|
INCS_Debug := \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/include/node \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/src \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/deps/openssl/config \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/deps/openssl/openssl/include \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/deps/uv/include \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/deps/zlib \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/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_LARGEFILE_SOURCE' \
|
||||||
|
'-D_FILE_OFFSET_BITS=64' \
|
||||||
|
'-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 \
|
||||||
|
-m64 \
|
||||||
|
-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 \
|
||||||
|
-fno-strict-aliasing \
|
||||||
|
-std=gnu++17
|
||||||
|
|
||||||
|
INCS_Release := \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/include/node \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/src \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/deps/openssl/config \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/deps/openssl/openssl/include \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/deps/uv/include \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/deps/zlib \
|
||||||
|
-I/home/boazsender/.cache/node-gyp/22.14.0/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 \
|
||||||
|
-m64
|
||||||
|
|
||||||
|
LDFLAGS_Release := \
|
||||||
|
-pthread \
|
||||||
|
-rdynamic \
|
||||||
|
-m64
|
||||||
|
|
||||||
|
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_
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue