Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-i2c

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-i2c - npm Package Compare versions

Comparing version 0.8.3 to 0.8.4

64

i2c/26-i2c.js

@@ -11,3 +11,3 @@ module.exports = function(RED) {

node.port = I2C.openSync( node.busno );
node.port = I2C.openSync(node.busno);
node.on("input", function(msg) {

@@ -19,5 +19,5 @@ node.port.scan(function(err, res) {

} else {
node.send([{ payload:res }, null]);
node.send([{ payload: res }, null]);
res.forEach(function(entry) {
node.send([null, { payload:entry, address:entry }]);
node.send([null, { payload: entry, address: entry }]);
});

@@ -44,7 +44,7 @@ }

node.port = I2C.openSync( node.busno );
node.port = I2C.openSync(node.busno);
node.on("input", function(msg) {
var address = node.address || msg.address ;
var command = node.command || msg.command ;
var buffcount = node.count || msg.bytes ;
var address = node.address || msg.address;
var command = node.command || msg.command;
var buffcount = node.count || msg.bytes;
address = parseInt(address);

@@ -54,6 +54,6 @@ command = parseInt(command);

if (isNaN(address)) {
this.status({fill:"red",shape:"ring",text:"Address ("+address+") value is missing or incorrect"});
this.status({ fill: "red", shape: "ring", text: "Address (" + address + ") value is missing or incorrect" });
return;
} else if ((!buffcount) || isNaN(buffcount) ) {
this.status({fill:"red",shape:"ring",text:"Read bytes ("+buffcount+") value is missing or incorrect"});
} else if ((!buffcount) || isNaN(buffcount)) {
this.status({ fill: "red", shape: "ring", text: "Read bytes (" + buffcount + ") value is missing or incorrect" });
return;

@@ -64,3 +64,3 @@ } else {

var buffer = new Buffer(buffcount);
if(isNaN(command)) {
if (isNaN(command)) {
node.port.i2cRead(address, buffcount, buffer, function(err, size, res) {

@@ -72,3 +72,3 @@ /* Block for read without command like pcf8574A and pcf8574 */

var payload;
if (node.count == 1) {
if (buffcount == 1) {
payload = res[0];

@@ -94,3 +94,3 @@ } else {

var payload;
if (node.count == 1) {
if (buffcount == 1) {
payload = res[0];

@@ -130,3 +130,3 @@ } else {

node.port = I2C.openSync( node.busno );
node.port = I2C.openSync(node.busno);
node.on("input", function(msg) {

@@ -144,6 +144,6 @@ var myPayload;

if (isNaN(address)) {
this.status({fill:"red",shape:"ring",text:"Address ("+address+") value is missing or incorrect"});
this.status({ fill: "red", shape: "ring", text: "Address (" + address + ") value is missing or incorrect" });
return;
} else if (isNaN(buffcount) ) {
this.status({fill:"red",shape:"ring",text:"Send bytes ("+buffcount+") value is missing or incorrect"});
} else if (isNaN(buffcount)) {
this.status({ fill: "red", shape: "ring", text: "Send bytes (" + buffcount + ") value is missing or incorrect" });
return;

@@ -159,7 +159,8 @@ } else {

} else {
myPayload = RED.util.evaluateNodeProperty(this.payload, this.payloadType, this,msg);
myPayload = RED.util.evaluateNodeProperty(this.payload, this.payloadType, this, msg);
}
if (myPayload == null || node.count == 0) {
node.port.sendByte(address, command, function(err) {
if (err) { node.error(err, msg);
if (myPayload == null || buffcount == 0) {
node.port.sendByte(address, command, function(err) {
if (err) {
node.error(err, msg);
} else {

@@ -169,6 +170,6 @@ node.send(msg);

});
} else if (!isNaN(myPayload)) {
} else if (Number.isFinite(myPayload)) {
var data = myPayload;
myPayload = Buffer.allocUnsafe(node.count);
myPayload.writeIntLE(data, 0, node.count, true);
myPayload = Buffer.allocUnsafe(buffcount);
myPayload.writeIntLE(data, 0, buffcount, true);
} else if (typeof myPayload === "string" || Array.isArray(myPayload)) {

@@ -182,15 +183,12 @@ myPayload = Buffer.from(myPayload);

node.port.i2cWrite(address, myPayload.length, myPayload, function(err) {
if (err) { node.error(err, msg); }
else { node.send(msg); }
if (err) { node.error(err, msg); } else { node.send(msg); }
});
}
else {
} else {
node.port.writeI2cBlock(address, command, myPayload.length, myPayload, function(err) {
if (err) { node.error(err, msg); }
else { node.send(msg); }
if (err) { node.error(err, msg); } else { node.send(msg); }
});
}
}
} catch(err) {
this.error(err,msg);
} catch (err) {
this.error(err, msg);
}

@@ -204,2 +202,2 @@ });

RED.nodes.registerType("i2c out", I2COutNode);
}
}
{
"name": "node-red-contrib-i2c",
"version": "0.8.3",
"version": "0.8.4",
"description": "A Node-RED node to talk to the Raspiberry PI's I2C port",

@@ -5,0 +5,0 @@ "dependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc