smithtek-mako-rf 2.9.8 → 2.9.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smithtek-mako-rf",
3
- "version": "2.9.8",
3
+ "version": "2.9.10",
4
4
  "description": "Smithtek dedicated node for communicating with the Mako PLC over RS485 or RF",
5
5
  "keywords": [
6
6
  "node-red",
Binary file
Binary file
@@ -227,7 +227,16 @@ state._rssiCleanup = cleanup;
227
227
  const regIndex = Math.floor(byteOffset / 2);
228
228
 
229
229
  const w = (i) => (regs[i] & 0xffff);
230
+ const isBoolArray = (Array.isArray(regs) && typeof regs[0] === "boolean");
230
231
 
232
+ function coilWord(wordIndex) {
233
+ let out = 0;
234
+ const base = wordIndex * 16;
235
+ for (let b = 0; b < 16; b++) {
236
+ if (regs[base + b]) out |= (1 << b);
237
+ }
238
+ return out >>> 0;
239
+ }
231
240
  // 4 bytes from two 16-bit words in common Modbus orders
232
241
  function bytesABCD(a, b) {
233
242
  return Buffer.from([(a >> 8) & 0xff, a & 0xff, (b >> 8) & 0xff, b & 0xff]);
@@ -302,12 +311,25 @@ state._rssiCleanup = cleanup;
302
311
  return buf.readFloatBE(0);
303
312
  }
304
313
 
305
- case "digital to unsigned binary encoder":
306
- return w(regIndex) >>> 0;
314
+ case "digital to unsigned binary encoder": {
315
+ const word = w(regIndex) >>> 0;
316
+
317
+ // If the UI provided a bit (0–15), return that bit as TRUE/FALSE
318
+ const bit = clampInt(offsetBit, 0, 15, 0);
319
+ return ((word >> bit) & 1) === 1;
320
+ }
321
+
307
322
 
308
- // optional internal bool support
309
323
  case "bool": {
310
324
  const bit = clampInt(offsetBit, 0, 15, 0);
325
+
326
+ // If this is FC1/FC2 data (boolean array), read bit directly
327
+ if (isBoolArray) {
328
+ const idx = (regIndex * 16) + bit;
329
+ return !!regs[idx];
330
+ }
331
+
332
+ // Otherwise treat as 16-bit register
311
333
  return ((w(regIndex) >> bit) & 1) === 1;
312
334
  }
313
335