node-red-contrib-modbus-modpackqt 3.3.8 → 3.3.9

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/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ All notable changes to **node-red-contrib-modbus-modpackqt** are documented
4
4
  here. This project follows [Semantic Versioning](https://semver.org/) — pin a
5
5
  major version (`^2.0.0`) in production.
6
6
 
7
+ ## [3.3.9] — 2026-05-10
8
+
9
+ ### Added
10
+
11
+ - **Master Write** now has a **Quantity** field — fixes how many registers
12
+ the write covers. Payload arrays longer than this are truncated; shorter
13
+ ones are padded with the last value (or 0 if empty). For FC5 / FC6
14
+ (single-register writes) Quantity is forced to 1.
15
+
7
16
  ## [3.3.8] — 2026-05-10
8
17
 
9
18
  ### Changed
@@ -18,7 +18,7 @@
18
18
  const http = require('http');
19
19
  const { URL } = require('url');
20
20
 
21
- const PALETTE_VERSION = '3.3.8';
21
+ const PALETTE_VERSION = '3.3.9';
22
22
  const DEFAULT_PORT = parseInt(process.env.MODPACKQT_PROBE_PORT, 10) || 8502;
23
23
  const BIND_HOST = process.env.MODPACKQT_PROBE_HOST || '127.0.0.1';
24
24
  const PORT_RETRY = 5;
@@ -9,7 +9,8 @@
9
9
  targetPort: { value: 0, validate: function (v) { return v === '' || v === 0 || RED.validators.number()(v); } },
10
10
  unitId: { value: 0, validate: function (v) { return v === '' || v === 0 || RED.validators.number()(v); } },
11
11
  functionCode: { value: '6', required: true },
12
- address: { value: 0, required: true, validate: RED.validators.number() }
12
+ address: { value: 0, required: true, validate: RED.validators.number() },
13
+ quantity: { value: 1, required: true, validate: RED.validators.number() }
13
14
  },
14
15
  inputs: 1,
15
16
  outputs: 1,
@@ -47,6 +48,15 @@
47
48
  <label for="node-input-address"><i class="fa fa-map-marker"></i> Start Address</label>
48
49
  <input type="number" id="node-input-address" min="0" max="65535" placeholder="0">
49
50
  </div>
51
+ <div class="form-row">
52
+ <label for="node-input-quantity"><i class="fa fa-sort-numeric-asc"></i> Quantity</label>
53
+ <input type="number" id="node-input-quantity" min="1" max="125" placeholder="1">
54
+ </div>
55
+ <div class="form-tips" style="font-size:11px;color:#6b7280;margin:-8px 0 12px 105px">
56
+ Number of registers to write. Payload arrays longer than this are truncated;
57
+ shorter ones are padded with the last value (or 0 if empty). For FC5 / FC6
58
+ (single-register writes) Quantity is forced to 1.
59
+ </div>
50
60
 
51
61
  <input type="hidden" id="node-input-targetHost">
52
62
  <input type="hidden" id="node-input-targetPort">
@@ -14,6 +14,7 @@ module.exports = function (RED) {
14
14
  node.unitId = parseInt(config.unitId, 10) || 0;
15
15
  node.functionCode = parseInt(config.functionCode, 10) || 6;
16
16
  node.address = parseInt(config.address, 10) || 0;
17
+ node.quantity = parseInt(config.quantity, 10) || 1;
17
18
 
18
19
  node.on('input', async function (msg) {
19
20
  if (!server) {
@@ -26,7 +27,16 @@ module.exports = function (RED) {
26
27
  try { raw = JSON.parse(raw); } catch (_) { raw = Number(raw); }
27
28
  }
28
29
  const isCoilWrite = (node.functionCode === 5 || node.functionCode === 15);
29
- const arr = Array.isArray(raw) ? raw : [raw];
30
+ const isSingle = (node.functionCode === 5 || node.functionCode === 6);
31
+ const targetQty = isSingle ? 1 : Math.max(1, node.quantity);
32
+ let arr = Array.isArray(raw) ? raw.slice() : [raw];
33
+ // Pad / truncate to targetQty
34
+ if (arr.length > targetQty) {
35
+ arr = arr.slice(0, targetQty);
36
+ } else if (arr.length < targetQty) {
37
+ const filler = arr.length ? arr[arr.length - 1] : (isCoilWrite ? 0 : 0);
38
+ while (arr.length < targetQty) arr.push(filler);
39
+ }
30
40
  const values = arr.map((v) => {
31
41
  if (isCoilWrite) return v ? 1 : 0;
32
42
  const n = Number(v);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-modbus-modpackqt",
3
- "version": "3.3.8",
3
+ "version": "3.3.9",
4
4
  "description": "Modbus commissioning, testing & analysis tools for Node-RED. Embedded Modbus TCP/RTU master + slave server, FC1/FC2/FC3/FC4 reads, FC5/FC6/FC15/FC16 writes, built-in slave register store, and a passive traffic monitor for debugging. 100% free, MIT, no usage limits. By ModPackQT — open the matching web console at modpackqt.com for register decoding, simulation and AI assistance.",
5
5
  "keywords": [
6
6
  "node-red",