node-red-contrib-periph-gnss 1.5.1 → 1.5.2
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 +2 -1
- package/examples/neo6/demo.json +30 -11
- package/nodes/neo6/neo6.html +50 -25
- package/nodes/neo6/neo6.js +19 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,8 @@ npm install node-red-contrib-periph-gnss
|
|
|
16
16
|
|
|
17
17
|
| Node | Kind | Description |
|
|
18
18
|
|------|------|-------------|
|
|
19
|
-
| `
|
|
19
|
+
| `neo6-device` | config | Bus configuration for a NEO6 |
|
|
20
|
+
| `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
21
|
|
|
21
22
|
## Links
|
|
22
23
|
|
package/examples/neo6/demo.json
CHANGED
|
@@ -4,23 +4,34 @@
|
|
|
4
4
|
"type": "tab",
|
|
5
5
|
"label": "NEO-6 GPS Logger Demo",
|
|
6
6
|
"disabled": false,
|
|
7
|
-
"info": "Injects a timestamp trigger every second into the
|
|
7
|
+
"info": "Injects a timestamp trigger every second into the 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
8
|
"locked": false
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
|
-
"id": "neo6-
|
|
12
|
-
"type": "
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"busType": "uart",
|
|
11
|
+
"id": "neo6-device-1",
|
|
12
|
+
"type": "neo6-device",
|
|
13
|
+
"name": "NEO6",
|
|
14
|
+
"bus": "1",
|
|
16
15
|
"port": "/dev/ttyS0",
|
|
16
|
+
"busType": "uart",
|
|
17
17
|
"baud": "9600",
|
|
18
|
-
"bus": "1",
|
|
19
18
|
"device": "0",
|
|
20
|
-
"addr": "0x42"
|
|
19
|
+
"addr": "0x42"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "neo6-read-1",
|
|
23
|
+
"type": "neo6",
|
|
24
|
+
"z": "neo6-tab-1",
|
|
25
|
+
"name": "NEO-6 GPS",
|
|
26
|
+
"device": "neo6-device-1",
|
|
21
27
|
"x": 260,
|
|
22
28
|
"y": 200,
|
|
23
|
-
"wires": [
|
|
29
|
+
"wires": [
|
|
30
|
+
[
|
|
31
|
+
"neo6-format-1",
|
|
32
|
+
"debug-1"
|
|
33
|
+
]
|
|
34
|
+
]
|
|
24
35
|
},
|
|
25
36
|
{
|
|
26
37
|
"id": "inject-timer-1",
|
|
@@ -35,7 +46,11 @@
|
|
|
35
46
|
"onceDelay": "0.1",
|
|
36
47
|
"x": 80,
|
|
37
48
|
"y": 200,
|
|
38
|
-
"wires": [
|
|
49
|
+
"wires": [
|
|
50
|
+
[
|
|
51
|
+
"neo6-read-1"
|
|
52
|
+
]
|
|
53
|
+
]
|
|
39
54
|
},
|
|
40
55
|
{
|
|
41
56
|
"id": "neo6-format-1",
|
|
@@ -46,7 +61,11 @@
|
|
|
46
61
|
"outputs": 1,
|
|
47
62
|
"x": 480,
|
|
48
63
|
"y": 240,
|
|
49
|
-
"wires": [
|
|
64
|
+
"wires": [
|
|
65
|
+
[
|
|
66
|
+
"worldmap-1"
|
|
67
|
+
]
|
|
68
|
+
]
|
|
50
69
|
},
|
|
51
70
|
{
|
|
52
71
|
"id": "debug-1",
|
package/nodes/neo6/neo6.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
1
2
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType('
|
|
3
|
-
category: '
|
|
4
|
-
color: '#a6d8ff',
|
|
3
|
+
RED.nodes.registerType('neo6-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
busType: { value: 'uart', required: true },
|
|
@@ -11,61 +11,86 @@
|
|
|
11
11
|
device: { value: '0', validate: RED.validators.number() },
|
|
12
12
|
addr: { value: '0x42' }
|
|
13
13
|
},
|
|
14
|
-
inputs: 1,
|
|
15
|
-
outputs: 1,
|
|
16
|
-
icon: 'font-awesome/fa-map-marker',
|
|
17
14
|
label: function() {
|
|
18
|
-
return this.name || '
|
|
15
|
+
return this.name || ('NEO6 @ ' + this.addr + ' (bus ' + this.bus + ')');
|
|
19
16
|
},
|
|
20
17
|
oneditprepare: function() {
|
|
21
18
|
function updateVisibility() {
|
|
22
|
-
const busType = $('#node-input-busType').val();
|
|
19
|
+
const busType = $('#node-config-input-busType').val();
|
|
23
20
|
$('.neo6-uart-row').toggle(busType === 'uart');
|
|
24
21
|
$('.neo6-i2c-row').toggle(busType === 'i2c');
|
|
25
22
|
$('.neo6-spi-row').toggle(busType === 'spi');
|
|
26
23
|
}
|
|
27
|
-
$('#node-input-busType').on('change', updateVisibility);
|
|
24
|
+
$('#node-config-input-busType').on('change', updateVisibility);
|
|
28
25
|
updateVisibility();
|
|
29
26
|
}
|
|
30
27
|
});
|
|
31
28
|
</script>
|
|
32
29
|
|
|
33
|
-
<script type="text/html" data-template-name="
|
|
30
|
+
<script type="text/html" data-template-name="neo6-device">
|
|
34
31
|
<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="
|
|
32
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
33
|
+
<input type="text" id="node-config-input-name" placeholder="NEO6">
|
|
37
34
|
</div>
|
|
38
35
|
<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">
|
|
36
|
+
<label for="node-config-input-busType"><i class="fa fa-random"></i> Bus type</label>
|
|
37
|
+
<select id="node-config-input-busType" style="width:150px">
|
|
41
38
|
<option value="uart">UART</option>
|
|
42
39
|
<option value="i2c">I²C (DDC)</option>
|
|
43
40
|
<option value="spi">SPI</option>
|
|
44
41
|
</select>
|
|
45
42
|
</div>
|
|
46
43
|
<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">
|
|
44
|
+
<label for="node-config-input-port"><i class="fa fa-plug"></i> Serial port</label>
|
|
45
|
+
<input type="text" id="node-config-input-port" placeholder="/dev/ttyS0">
|
|
49
46
|
</div>
|
|
50
47
|
<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">
|
|
48
|
+
<label for="node-config-input-baud"><i class="fa fa-tachometer"></i> Baud rate</label>
|
|
49
|
+
<input type="number" id="node-config-input-baud" style="width:100px">
|
|
53
50
|
</div>
|
|
54
51
|
<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">
|
|
52
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> Bus number</label>
|
|
53
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px">
|
|
57
54
|
</div>
|
|
58
55
|
<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">
|
|
56
|
+
<label for="node-config-input-device"><i class="fa fa-microchip"></i> SPI CS/device</label>
|
|
57
|
+
<input type="number" id="node-config-input-device" min="0" style="width:80px">
|
|
61
58
|
</div>
|
|
62
59
|
<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">
|
|
60
|
+
<label for="node-config-input-addr"><i class="fa fa-microchip"></i> I²C address</label>
|
|
61
|
+
<input type="text" id="node-config-input-addr" style="width:100px" placeholder="0x42">
|
|
62
|
+
</div>
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<!-- Read node -->
|
|
66
|
+
<script type="text/javascript">
|
|
67
|
+
RED.nodes.registerType('neo6', {
|
|
68
|
+
category: 'Peripheral',
|
|
69
|
+
color: '#C084FC',
|
|
70
|
+
defaults: {
|
|
71
|
+
name: { value: '' },
|
|
72
|
+
device: { value: '', type: 'neo6-device', required: true }
|
|
73
|
+
},
|
|
74
|
+
inputs: 1,
|
|
75
|
+
outputs: 1,
|
|
76
|
+
icon: 'font-awesome/fa-map-marker',
|
|
77
|
+
label: function() { return this.name || 'NEO6'; },
|
|
78
|
+
paletteLabel: 'NEO6'
|
|
79
|
+
});
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<script type="text/html" data-template-name="neo6">
|
|
83
|
+
<div class="form-row">
|
|
84
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
85
|
+
<input type="text" id="node-input-name" placeholder="NEO6">
|
|
86
|
+
</div>
|
|
87
|
+
<div class="form-row">
|
|
88
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
89
|
+
<input type="text" id="node-input-device">
|
|
65
90
|
</div>
|
|
66
91
|
</script>
|
|
67
92
|
|
|
68
|
-
<script type="text/html" data-help-name="
|
|
93
|
+
<script type="text/html" data-help-name="neo6">
|
|
69
94
|
<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
95
|
<h3>Inputs</h3>
|
|
71
96
|
<dl class="message-properties">
|
package/nodes/neo6/neo6.js
CHANGED
|
@@ -6,7 +6,7 @@ module.exports = function(RED) {
|
|
|
6
6
|
const { SPIConnection } = require('periph/src/connection/spi');
|
|
7
7
|
const { NEO6Full } = require('periph/src/chips/gnss/neo6');
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function NEO6DeviceNode(config) {
|
|
10
10
|
RED.nodes.createNode(this, config);
|
|
11
11
|
const node = this;
|
|
12
12
|
node.busType = config.busType || 'uart';
|
|
@@ -34,8 +34,22 @@ module.exports = function(RED) {
|
|
|
34
34
|
}
|
|
35
35
|
})();
|
|
36
36
|
|
|
37
|
+
node.on('close', async function(done) {
|
|
38
|
+
if (node.connection) {
|
|
39
|
+
try { await node.connection.close(); } catch (_) { /* already closed */ }
|
|
40
|
+
}
|
|
41
|
+
done();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
RED.nodes.registerType('neo6-device', NEO6DeviceNode);
|
|
45
|
+
|
|
46
|
+
function NEO6ReadNode(config) {
|
|
47
|
+
RED.nodes.createNode(this, config);
|
|
48
|
+
const node = this;
|
|
49
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
50
|
+
|
|
37
51
|
node.on('input', async function(msg, send, done) {
|
|
38
|
-
if (!
|
|
52
|
+
if (!deviceNode.ready || !deviceNode.driver) {
|
|
39
53
|
node.error('NEO-6 not ready', msg);
|
|
40
54
|
done();
|
|
41
55
|
return;
|
|
@@ -51,9 +65,9 @@ module.exports = function(RED) {
|
|
|
51
65
|
// stream goes quiet between bursts.
|
|
52
66
|
const deadline = Date.now() + 900;
|
|
53
67
|
while (Date.now() < deadline) {
|
|
54
|
-
await
|
|
68
|
+
await deviceNode.driver.update();
|
|
55
69
|
}
|
|
56
|
-
const d =
|
|
70
|
+
const d = deviceNode.driver;
|
|
57
71
|
msg.payload = {
|
|
58
72
|
lat: d.latitude(),
|
|
59
73
|
lon: d.longitude(),
|
|
@@ -72,14 +86,6 @@ module.exports = function(RED) {
|
|
|
72
86
|
done(e);
|
|
73
87
|
}
|
|
74
88
|
});
|
|
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
89
|
}
|
|
83
|
-
|
|
84
|
-
RED.nodes.registerType('periph-neo6', NEO6Node);
|
|
90
|
+
RED.nodes.registerType('neo6', NEO6ReadNode);
|
|
85
91
|
};
|