node-red-contrib-periph-gnss 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/examples/neo6/demo.json +75 -0
- package/nodes/neo6/neo6.html +98 -0
- package/nodes/neo6/neo6.js +85 -0
- package/package.json +4 -2
- package/examples/.gitkeep +0 -0
- package/nodes/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -2,15 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Node-RED nodes for GNSS/GPS peripheral chips — part of the [Periph](https://github.com/tuhde/Periph) library.
|
|
4
4
|
|
|
5
|
-
> **Coming soon.** Nodes will be added as chips in this category are implemented.
|
|
6
|
-
|
|
7
5
|
## Install
|
|
8
6
|
|
|
7
|
+
Open Node-RED, go to **Manage Palette → Install** and search for `node-red-contrib-periph-gnss`.
|
|
8
|
+
|
|
9
|
+
Or from the command line in your Node-RED user directory:
|
|
10
|
+
|
|
9
11
|
```sh
|
|
10
12
|
npm install node-red-contrib-periph-gnss
|
|
11
13
|
```
|
|
12
14
|
|
|
15
|
+
## Nodes
|
|
16
|
+
|
|
17
|
+
| Node | Kind | Description |
|
|
18
|
+
|------|------|-------------|
|
|
19
|
+
| `periph-neo6` | input | Reads NMEA position, altitude, and fix status from a u-blox NEO-6 GNSS receiver over UART, I²C (DDC), or SPI. |
|
|
20
|
+
|
|
13
21
|
## Links
|
|
14
22
|
|
|
15
23
|
- [GitHub](https://github.com/tuhde/Periph)
|
|
16
|
-
- [
|
|
24
|
+
- [periph JS driver](https://www.npmjs.com/package/periph)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "neo6-tab-1",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "NEO-6 GPS Logger Demo",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Injects a timestamp trigger every second into the periph-neo6 node, which reads the current NMEA fix over UART. A Function node formats the output as a '$lat,$lon' CSV string once a fix is available (and shows a waiting indicator with the satellite count while there is none), feeding a WorldMap node that plots the live position. A Debug node logs the full raw fix object (lat, lon, alt, fix, satellites, speed, course, time, date, hdop) to the sidebar.\n\nCold-start TTFF is ~26 s typical outdoors with a clear sky view; the fix quality field stays 0 until then, so expect the WorldMap marker to appear a little after the flow is deployed.",
|
|
8
|
+
"locked": false
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": "neo6-read-1",
|
|
12
|
+
"type": "periph-neo6",
|
|
13
|
+
"z": "neo6-tab-1",
|
|
14
|
+
"name": "NEO-6 GPS",
|
|
15
|
+
"busType": "uart",
|
|
16
|
+
"port": "/dev/ttyS0",
|
|
17
|
+
"baud": "9600",
|
|
18
|
+
"bus": "1",
|
|
19
|
+
"device": "0",
|
|
20
|
+
"addr": "0x42",
|
|
21
|
+
"x": 260,
|
|
22
|
+
"y": 200,
|
|
23
|
+
"wires": [["neo6-format-1", "debug-1"]]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "inject-timer-1",
|
|
27
|
+
"type": "inject",
|
|
28
|
+
"z": "neo6-tab-1",
|
|
29
|
+
"name": "Every second",
|
|
30
|
+
"topic": "",
|
|
31
|
+
"payload": "",
|
|
32
|
+
"payloadType": "date",
|
|
33
|
+
"repeat": "1",
|
|
34
|
+
"crontab": "",
|
|
35
|
+
"onceDelay": "0.1",
|
|
36
|
+
"x": 80,
|
|
37
|
+
"y": 200,
|
|
38
|
+
"wires": [["neo6-read-1"]]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"id": "neo6-format-1",
|
|
42
|
+
"type": "function",
|
|
43
|
+
"z": "neo6-tab-1",
|
|
44
|
+
"name": "Format as CSV",
|
|
45
|
+
"func": "if (msg.payload.fix === 0) {\n node.status({ fill: 'yellow', shape: 'ring', text: 'waiting for fix (' + msg.payload.satellites + ' sats)' });\n return null;\n}\nnode.status({ fill: 'green', shape: 'dot', text: 'fix: ' + msg.payload.fix });\nmsg.payload = msg.payload.lat.toFixed(6) + ',' + msg.payload.lon.toFixed(6);\nreturn msg;",
|
|
46
|
+
"outputs": 1,
|
|
47
|
+
"x": 480,
|
|
48
|
+
"y": 240,
|
|
49
|
+
"wires": [["worldmap-1"]]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "debug-1",
|
|
53
|
+
"type": "debug",
|
|
54
|
+
"z": "neo6-tab-1",
|
|
55
|
+
"name": "Raw fix data",
|
|
56
|
+
"active": true,
|
|
57
|
+
"tosidebar": true,
|
|
58
|
+
"console": false,
|
|
59
|
+
"tostatus": false,
|
|
60
|
+
"complete": "payload",
|
|
61
|
+
"targetType": "msg",
|
|
62
|
+
"x": 480,
|
|
63
|
+
"y": 160,
|
|
64
|
+
"wires": []
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "worldmap-1",
|
|
68
|
+
"type": "worldmap",
|
|
69
|
+
"z": "neo6-tab-1",
|
|
70
|
+
"name": "GPS logger position",
|
|
71
|
+
"x": 700,
|
|
72
|
+
"y": 240,
|
|
73
|
+
"wires": []
|
|
74
|
+
}
|
|
75
|
+
]
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('periph-neo6', {
|
|
3
|
+
category: 'periph',
|
|
4
|
+
color: '#a6d8ff',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
busType: { value: 'uart', required: true },
|
|
8
|
+
port: { value: '/dev/ttyS0' },
|
|
9
|
+
baud: { value: '9600', validate: RED.validators.number() },
|
|
10
|
+
bus: { value: '1', validate: RED.validators.number() },
|
|
11
|
+
device: { value: '0', validate: RED.validators.number() },
|
|
12
|
+
addr: { value: '0x42' }
|
|
13
|
+
},
|
|
14
|
+
inputs: 1,
|
|
15
|
+
outputs: 1,
|
|
16
|
+
icon: 'font-awesome/fa-map-marker',
|
|
17
|
+
label: function() {
|
|
18
|
+
return this.name || 'NEO-6 (' + this.busType + ')';
|
|
19
|
+
},
|
|
20
|
+
oneditprepare: function() {
|
|
21
|
+
function updateVisibility() {
|
|
22
|
+
const busType = $('#node-input-busType').val();
|
|
23
|
+
$('.neo6-uart-row').toggle(busType === 'uart');
|
|
24
|
+
$('.neo6-i2c-row').toggle(busType === 'i2c');
|
|
25
|
+
$('.neo6-spi-row').toggle(busType === 'spi');
|
|
26
|
+
}
|
|
27
|
+
$('#node-input-busType').on('change', updateVisibility);
|
|
28
|
+
updateVisibility();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<script type="text/html" data-template-name="periph-neo6">
|
|
34
|
+
<div class="form-row">
|
|
35
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
36
|
+
<input type="text" id="node-input-name" placeholder="NEO-6">
|
|
37
|
+
</div>
|
|
38
|
+
<div class="form-row">
|
|
39
|
+
<label for="node-input-busType"><i class="fa fa-random"></i> Bus type</label>
|
|
40
|
+
<select id="node-input-busType" style="width:150px">
|
|
41
|
+
<option value="uart">UART</option>
|
|
42
|
+
<option value="i2c">I²C (DDC)</option>
|
|
43
|
+
<option value="spi">SPI</option>
|
|
44
|
+
</select>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="form-row neo6-uart-row">
|
|
47
|
+
<label for="node-input-port"><i class="fa fa-plug"></i> Serial port</label>
|
|
48
|
+
<input type="text" id="node-input-port" placeholder="/dev/ttyS0">
|
|
49
|
+
</div>
|
|
50
|
+
<div class="form-row neo6-uart-row">
|
|
51
|
+
<label for="node-input-baud"><i class="fa fa-tachometer"></i> Baud rate</label>
|
|
52
|
+
<input type="number" id="node-input-baud" style="width:100px">
|
|
53
|
+
</div>
|
|
54
|
+
<div class="form-row neo6-i2c-row neo6-spi-row">
|
|
55
|
+
<label for="node-input-bus"><i class="fa fa-microchip"></i> Bus number</label>
|
|
56
|
+
<input type="number" id="node-input-bus" min="0" style="width:80px">
|
|
57
|
+
</div>
|
|
58
|
+
<div class="form-row neo6-spi-row">
|
|
59
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> SPI CS/device</label>
|
|
60
|
+
<input type="number" id="node-input-device" min="0" style="width:80px">
|
|
61
|
+
</div>
|
|
62
|
+
<div class="form-row neo6-i2c-row">
|
|
63
|
+
<label for="node-input-addr"><i class="fa fa-microchip"></i> I²C address</label>
|
|
64
|
+
<input type="text" id="node-input-addr" style="width:100px" placeholder="0x42">
|
|
65
|
+
</div>
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<script type="text/html" data-help-name="periph-neo6">
|
|
69
|
+
<p>Reads NMEA position, altitude, and fix status from a u-blox NEO-6 GNSS receiver over UART, I²C (DDC), or SPI.</p>
|
|
70
|
+
<h3>Inputs</h3>
|
|
71
|
+
<dl class="message-properties">
|
|
72
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
73
|
+
<dd>Any incoming message triggers the node to drain currently buffered bytes and report the latest parsed fix.</dd>
|
|
74
|
+
</dl>
|
|
75
|
+
<h3>Outputs</h3>
|
|
76
|
+
<dl class="message-properties">
|
|
77
|
+
<dt>payload.lat <span class="property-type">number | null</span></dt>
|
|
78
|
+
<dd>Latitude in decimal degrees, positive north. <code>null</code> until a fix is acquired.</dd>
|
|
79
|
+
<dt>payload.lon <span class="property-type">number | null</span></dt>
|
|
80
|
+
<dd>Longitude in decimal degrees, positive east. <code>null</code> until a fix is acquired.</dd>
|
|
81
|
+
<dt>payload.alt <span class="property-type">number | null</span></dt>
|
|
82
|
+
<dd>Altitude above mean sea level, in meters.</dd>
|
|
83
|
+
<dt>payload.fix <span class="property-type">number</span></dt>
|
|
84
|
+
<dd>GGA fix quality: 0 = no fix, 1 = GPS, 2 = DGPS.</dd>
|
|
85
|
+
<dt>payload.satellites <span class="property-type">number</span></dt>
|
|
86
|
+
<dd>Number of satellites used in the fix.</dd>
|
|
87
|
+
<dt>payload.speed <span class="property-type">number | null</span></dt>
|
|
88
|
+
<dd>Speed over ground in m/s.</dd>
|
|
89
|
+
<dt>payload.course <span class="property-type">number | null</span></dt>
|
|
90
|
+
<dd>Course over ground in degrees, 0-360.</dd>
|
|
91
|
+
<dt>payload.time / payload.date <span class="property-type">string | null</span></dt>
|
|
92
|
+
<dd>UTC time (<code>hhmmss.ss</code>) and date (<code>ddmmyy</code>) of the last fix sentence.</dd>
|
|
93
|
+
<dt>payload.hdop <span class="property-type">number | null</span></dt>
|
|
94
|
+
<dd>Horizontal dilution of precision.</dd>
|
|
95
|
+
</dl>
|
|
96
|
+
<h3>Configuration</h3>
|
|
97
|
+
<p>Select the bus type (UART, I²C/DDC, or SPI) and set the matching serial port / bus number / I²C address (default <code>0x42</code>). Achieving a fix requires a clear sky view and can take up to ~26 s (cold start).</p>
|
|
98
|
+
</script>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { UARTConnection } = require('periph/src/connection/uart');
|
|
5
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
6
|
+
const { SPIConnection } = require('periph/src/connection/spi');
|
|
7
|
+
const { NEO6Full } = require('periph/src/chips/gnss/neo6');
|
|
8
|
+
|
|
9
|
+
function NEO6Node(config) {
|
|
10
|
+
RED.nodes.createNode(this, config);
|
|
11
|
+
const node = this;
|
|
12
|
+
node.busType = config.busType || 'uart';
|
|
13
|
+
node.ready = false;
|
|
14
|
+
|
|
15
|
+
(async () => {
|
|
16
|
+
try {
|
|
17
|
+
let connection;
|
|
18
|
+
if (node.busType === 'i2c') {
|
|
19
|
+
const addr = parseInt(config.addr) || 0x42;
|
|
20
|
+
connection = new I2CConnection(parseInt(config.bus) || 1, addr);
|
|
21
|
+
} else if (node.busType === 'spi') {
|
|
22
|
+
connection = new SPIConnection(parseInt(config.bus) || 0, parseInt(config.device) || 0,
|
|
23
|
+
{ mode: 0, maxSpeedHz: 200_000 });
|
|
24
|
+
} else {
|
|
25
|
+
connection = new UARTConnection(config.port || '/dev/ttyS0',
|
|
26
|
+
{ baudRate: parseInt(config.baud) || 9600 });
|
|
27
|
+
await connection.open();
|
|
28
|
+
}
|
|
29
|
+
node.connection = connection;
|
|
30
|
+
node.driver = new NEO6Full(connection, node.busType);
|
|
31
|
+
node.ready = true;
|
|
32
|
+
} catch (e) {
|
|
33
|
+
node.error('NEO-6 init failed: ' + e.message);
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
36
|
+
|
|
37
|
+
node.on('input', async function(msg, send, done) {
|
|
38
|
+
if (!node.ready || !node.driver) {
|
|
39
|
+
node.error('NEO-6 not ready', msg);
|
|
40
|
+
done();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
// A GPS burst (~7 sentences at the module's 1 Hz output rate)
|
|
45
|
+
// is far more than one byte; drain what's currently buffered
|
|
46
|
+
// each time this node fires rather than reading a single
|
|
47
|
+
// byte. Time-boxed rather than a fixed iteration count: on
|
|
48
|
+
// UART a byte-less update() only resolves after the
|
|
49
|
+
// connection's read timeout, so an unbounded iteration count
|
|
50
|
+
// could block this node for a very long time once the
|
|
51
|
+
// stream goes quiet between bursts.
|
|
52
|
+
const deadline = Date.now() + 900;
|
|
53
|
+
while (Date.now() < deadline) {
|
|
54
|
+
await node.driver.update();
|
|
55
|
+
}
|
|
56
|
+
const d = node.driver;
|
|
57
|
+
msg.payload = {
|
|
58
|
+
lat: d.latitude(),
|
|
59
|
+
lon: d.longitude(),
|
|
60
|
+
alt: d.altitude(),
|
|
61
|
+
fix: d.fix(),
|
|
62
|
+
satellites: d.satellites(),
|
|
63
|
+
speed: d.speed(),
|
|
64
|
+
course: d.course(),
|
|
65
|
+
time: d.utcTime(),
|
|
66
|
+
date: d.utcDate(),
|
|
67
|
+
hdop: d.hdop()
|
|
68
|
+
};
|
|
69
|
+
send(msg);
|
|
70
|
+
done();
|
|
71
|
+
} catch (e) {
|
|
72
|
+
done(e);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
node.on('close', async function(done) {
|
|
77
|
+
if (node.connection) {
|
|
78
|
+
try { await node.connection.close(); } catch (_) { /* already closed */ }
|
|
79
|
+
}
|
|
80
|
+
done();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
RED.nodes.registerType('periph-neo6', NEO6Node);
|
|
85
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-gnss",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Node-RED nodes for GNSS/GPS peripheral chips",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"peripheral"
|
|
12
12
|
],
|
|
13
13
|
"node-red": {
|
|
14
|
-
"nodes": {
|
|
14
|
+
"nodes": {
|
|
15
|
+
"neo6": "nodes/neo6/neo6.js"
|
|
16
|
+
}
|
|
15
17
|
},
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"periph": "*"
|
package/examples/.gitkeep
DELETED
|
File without changes
|
package/nodes/.gitkeep
DELETED
|
File without changes
|