Merge branch 'test-mysql2' into fix-node-mysql

This commit is contained in:
Dave Conway-Jones 2021-11-18 08:50:13 +00:00 committed by GitHub
commit da01c7493c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 36 additions and 62 deletions

View File

@ -1,13 +1,12 @@
sudo: false sudo: false
language: node_js language: node_js
matrix: matrix:
allow_failures: # allow_failures:
- node_js: 16 # - node_js: 16
include: include:
- node_js: 16 - node_js: 16
- node_js: 14 - node_js: 14
- node_js: 12 - node_js: 12
- node_js: 10
# - python: 2.7 # - python: 2.7
# language: python # language: python
# before_script: pip install flake8 # before_script: pip install flake8

View File

@ -1,9 +1,9 @@
{ {
"name" : "node-red-node-data-generator", "name" : "node-red-node-data-generator",
"version" : "0.2.0", "version" : "1.0.0",
"description" : "A Node-RED node to create a string of dummy data values from a template. Useful for test-cases.", "description" : "A Node-RED node to create a string of dummy data values from a template. Useful for test-cases.",
"dependencies" : { "dependencies" : {
"dummy-json": "^2.0.0" "dummy-json": "^3.0.4"
}, },
"repository" : { "repository" : {
"type":"git", "type":"git",

View File

@ -171,24 +171,19 @@ if len(sys.argv) > 2:
data = 0 data = 0
elif cmd == "mouse": # catch mice button events elif cmd == "mouse": # catch mice button events
file = open( "/dev/input/mice", "rb" ) f = open( "/dev/input/mice", "rb" )
oldbutt = 0 oldbutt = 0
def getMouseEvent():
global oldbutt
global pin
buf = file.read(3)
pin = pin & 0x07
button = ord( buf[0] ) & pin # mask out just the required button(s)
if button != oldbutt: # only send if changed
oldbutt = button
print(button)
while True: while True:
try: try:
getMouseEvent() buf = f.read(3)
pin = pin & 0x07
button = struct.unpack('3b',buf)[0] & pin # mask out just the required button(s)
if button != oldbutt: # only send if changed
oldbutt = button
print(button)
except: except:
file.close() f.close()
sys.exit(0) sys.exit(0)
elif cmd == "kbd": # catch keyboard button events elif cmd == "kbd": # catch keyboard button events
@ -196,7 +191,7 @@ if len(sys.argv) > 2:
while not os.path.isdir("/dev/input/by-path"): while not os.path.isdir("/dev/input/by-path"):
sleep(10) sleep(10)
infile = subprocess.check_output("ls /dev/input/by-path/ | grep -m 1 'kbd'", shell=True).strip() infile = subprocess.check_output("ls /dev/input/by-path/ | grep -m 1 'kbd'", shell=True).strip()
infile_path = "/dev/input/by-path/" + infile infile_path = "/dev/input/by-path/" + infile.decode("utf-8")
EVENT_SIZE = struct.calcsize('llHHI') EVENT_SIZE = struct.calcsize('llHHI')
file = open(infile_path, "rb") file = open(infile_path, "rb")
event = file.read(EVENT_SIZE) event = file.read(EVENT_SIZE)

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-node-pi-gpio", "name": "node-red-node-pi-gpio",
"version": "2.0.0-beta4", "version": "2.0.1",
"description": "The basic Node-RED node for Pi GPIO", "description": "The basic Node-RED node for Pi GPIO",
"dependencies" : { "dependencies" : {
}, },

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-pi-mcp3008", "name" : "node-red-node-pi-mcp3008",
"version" : "0.5.0", "version" : "0.5.1",
"description" : "A Node-RED node to read from the MCP3008 Analogue to Digital Converter", "description" : "A Node-RED node to read from the MCP3008 Analogue to Digital Converter",
"dependencies" : { "dependencies" : {
"mcp-spi-adc": "^3.2.0" "mcp-spi-adc": "^3.2.0"

View File

@ -29,7 +29,6 @@ module.exports = function(RED) {
this.bus = parseInt(n.bus || 0); this.bus = parseInt(n.bus || 0);
this.dev = n.dev || "3008"; this.dev = n.dev || "3008";
this.mcp3xxx = []; this.mcp3xxx = [];
var node = this;
this.cb = function (err) { if (err) { node.error("Error: "+err); } }; this.cb = function (err) { if (err) { node.error("Error: "+err); } };
this.opt = { speedHz:20000, deviceNumber:node.dnum, busNumber:node.bus }; this.opt = { speedHz:20000, deviceNumber:node.dnum, busNumber:node.bus };
var chans = parseInt(this.dev.substr(3)); var chans = parseInt(this.dev.substr(3));
@ -40,14 +39,14 @@ module.exports = function(RED) {
fs.statSync("/dev/spidev"+node.bus+"."+node.dnum); fs.statSync("/dev/spidev"+node.bus+"."+node.dnum);
if (node.mcp3xxx.length === 0) { if (node.mcp3xxx.length === 0) {
for (var i=0; i<chans; i++) { for (var i=0; i<chans; i++) {
if (node.dev === "3002") { mcp3xxx.push(mcpadc.openMcp3002(i, opt, cb)); } if (node.dev === "3002") { node.mcp3xxx.push(mcpadc.openMcp3002(i, node.opt, node.cb)); }
if (node.dev === "3004") { mcp3xxx.push(mcpadc.openMcp3004(i, opt, cb)); } if (node.dev === "3004") { node.mcp3xxx.push(mcpadc.openMcp3004(i, node.opt, node.cb)); }
if (node.dev === "3008") { mcp3xxx.push(mcpadc.openMcp3008(i, opt, cb)); } if (node.dev === "3008") { node.mcp3xxx.push(mcpadc.openMcp3008(i, node.opt, node.cb)); }
if (node.dev === "3201") { mcp3xxx.push(mcpadc.openMcp3201(i, opt, cb)); } if (node.dev === "3201") { node.mcp3xxx.push(mcpadc.openMcp3201(i, node.opt, node.cb)); }
if (node.dev === "3202") { mcp3xxx.push(mcpadc.openMcp3202(i, opt, cb)); } if (node.dev === "3202") { node.mcp3xxx.push(mcpadc.openMcp3202(i, node.opt, node.cb)); }
if (node.dev === "3204") { mcp3xxx.push(mcpadc.openMcp3204(i, opt, cb)); } if (node.dev === "3204") { node.mcp3xxx.push(mcpadc.openMcp3204(i, node.opt, node.cb)); }
if (node.dev === "3208") { mcp3xxx.push(mcpadc.openMcp3208(i, opt, cb)); } if (node.dev === "3208") { node.mcp3xxx.push(mcpadc.openMcp3208(i, node.opt, node.cb)); }
if (node.dev === "3304") { mcp3xxx.push(mcpadc.openMcp3304(i, opt, cb)); } if (node.dev === "3304") { node.mcp3xxx.push(mcpadc.openMcp3304(i, node.opt, node.cb)); }
} }
} }
node.on("input", function(msg) { node.on("input", function(msg) {
@ -76,7 +75,7 @@ module.exports = function(RED) {
for (var i=0; i<chans; i++) { for (var i=0; i<chans; i++) {
node.mcp3xxx[i].close(function() { j += 1; if (j === chans) {done()} }); node.mcp3xxx[i].close(function() { j += 1; if (j === chans) {done()} });
} }
mcp3xxx = []; node.mcp3xxx = [];
} }
else { done(); } else { done(); }
}); });

View File

@ -257,6 +257,7 @@
oneditprepare: function() { oneditprepare: function() {
var previous = null; var previous = null;
var blist = [ var blist = [
{value:"230400",label:"230400",hasValue:false},
{value:"115200",label:"115200",hasValue:false}, {value:"115200",label:"115200",hasValue:false},
{value:"57600",label:"57600",hasValue:false}, {value:"57600",label:"57600",hasValue:false},
{value:"38400",label:"38400",hasValue:false}, {value:"38400",label:"38400",hasValue:false},

View File

@ -1,9 +1,9 @@
{ {
"name" : "node-red-node-serialport", "name" : "node-red-node-serialport",
"version" : "0.14.1", "version" : "0.15.0",
"description" : "Node-RED nodes to talk to serial ports", "description" : "Node-RED nodes to talk to serial ports",
"dependencies" : { "dependencies" : {
"serialport" : "^9.1.0" "serialport" : "^9.2.5"
}, },
"repository" : { "repository" : {
"type":"git", "type":"git",
@ -13,12 +13,12 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"keywords": [ "node-red", "serial" ], "keywords": [ "node-red", "serial" ],
"node-red": { "node-red": {
"version": ">=0.18.0", "version": ">=1.0.0",
"nodes": { "nodes": {
"serialport": "25-serial.js" "serialport": "25-serial.js"
} }
}, },
"engines" : { "node" : ">=8.6.0" }, "engines" : { "node" : ">=10.0.0" },
"author": { "author": {
"name": "Dave Conway-Jones", "name": "Dave Conway-Jones",
"email": "ceejay@vnet.ibm.com", "email": "ceejay@vnet.ibm.com",

View File

@ -48,14 +48,14 @@
"ngeohash": "^0.6.3", "ngeohash": "^0.6.3",
"node-red": "^2.1.3", "node-red": "^2.1.3",
"node-red-node-test-helper": "^0.2.7", "node-red-node-test-helper": "^0.2.7",
"nodemailer": "^6.7.0", "nodemailer": "^6.7.1",
"poplib": "^0.1.7", "poplib": "^0.1.7",
"proxyquire": "^2.1.3", "proxyquire": "^2.1.3",
"pushbullet": "^2.4.0", "pushbullet": "^2.4.0",
"sentiment": "^2.1.0", "sentiment": "^2.1.0",
"should": "^13.2.3", "should": "^13.2.3",
"sinon": "~7.5.0", "sinon": "~7.5.0",
"smtp-server": "~3.9.0", "smtp-server": "^3.9.0",
"supertest": "^4.0.2", "supertest": "^4.0.2",
"when": "^3.7.8" "when": "^3.7.8"
}, },

View File

@ -121,6 +121,7 @@ module.exports = function(RED) {
if (done) { done(); } if (done) { done(); }
return return
} }
var bind = []; var bind = [];
if (Array.isArray(msg.payload)) { if (Array.isArray(msg.payload)) {
bind = msg.payload; bind = msg.payload;
@ -137,36 +138,15 @@ module.exports = function(RED) {
node.error(err, msg); node.error(err, msg);
} }
else { else {
// if (rows.constructor.name === "OkPacket") {
// msg.payload = JSON.parse(JSON.stringify(rows));
// }
// else if (rows.constructor.name === "Array") {
// if (rows[0] && rows[0].constructor.name === "RowDataPacket") {
// msg.payload = rows.map(v => Object.assign({}, v));
// }
// else if (rows[0] && rows[0].constructor.name === "Array") {
// if (rows[0][0] && rows[0][0].constructor.name === "RowDataPacket") {
// msg.payload = rows.map(function(v) {
// if (!Array.isArray(v)) { return v; }
// v.map(w => Object.assign({}, w))
// });
// }
// else { msg.payload = rows; }
// }
// else { msg.payload = rows; }
// }
// else { msg.payload = rows; }
msg.payload = rows; msg.payload = rows;
send(msg); send(msg);
status = { fill: "green", shape: "dot", text: RED._("mysql.status.ok") }; status = { fill: "green", shape: "dot", text: RED._("mysql.status.ok") };
node.status(status); node.status(status);
} }
if (done) { done(); } if (done) { done(); }
// if (node.mydbConfig.pool._freeConnections.indexOf(node.mydbConfig.connection) === -1) {
// node.mydbConfig.connection.release();
// }
}); });
}) })
} }
else { else {
if (typeof msg.topic !== 'string') { node.error("msg.topic : "+RED._("mysql.errors.notstring")); done(); } if (typeof msg.topic !== 'string') { node.error("msg.topic : "+RED._("mysql.errors.notstring")); done(); }

View File

@ -2,7 +2,7 @@
<script type="text/html" data-help-name="MySQLdatabase"> <script type="text/html" data-help-name="MySQLdatabase">
<p>データベースにアクセスするための認証情報を追加します。</p> <p>データベースにアクセスするための認証情報を追加します。</p>
<p>タイムゾーンには、GMT, EST5EDT, UTC のような値を設定します。</p> <p>タイムゾーンには、GMT, EST5EDT, UTC のような値を設定します。</p>
<p>The Charset defaults to the "old" 3 byte Mysql UTF8. 絵文字などをサポートする必要がある場合は、UTF8MB4 を使用してください。</p> <p>文字セットのデフォルトは「古い」3バイトのMysql UTF8です。絵文字などをサポートする必要がある場合は、UTF8MB4 を使用してください。</p>
</script> </script>
<script type="text/html" data-help-name="mysql"> <script type="text/html" data-help-name="mysql">

View File

@ -1,9 +1,9 @@
{ {
"name": "node-red-node-mysql", "name": "node-red-node-mysql",
"version": "0.3.0", "version": "1.0.0-beta",
"description": "A Node-RED node to read and write to a MySQL database", "description": "A Node-RED node to read and write to a MySQL database",
"dependencies": { "dependencies": {
"mysql": "^2.18.1" "mysql2": "^2.3.3"
}, },
"repository": { "repository": {
"type": "git", "type": "git",