Unable to write to bit in integer tag or BOOL[] array
mainint is defined as an INT tag in Controller scope. boolarray is defined as BOOL[32] in Controller scope.
Reading from "mainint.1" works with no error.
Reading from "boolarray.1" works with no error.
Writing to "mainint.1" throws a blank exception (no message or error). Writing to "boolarray.1" throws a blank exception (no message or error)
UPDATE: if the exception is caught and output as console.error(JSON.stringify(err)) it's blank.
If not caught, the console outputs the following:
connected to PLC
Uncaught Error Error: Bit Indexes can only be used on SINT, INT, DINT, or BIT_STRING data types.
at generateWriteMessageRequestForBitIndex (---/node_modules\st-ethernet-ip\dist\tag\index.js:594:23)
at generateWriteMessageRequest (---node_modules\st-ethernet-ip\dist\tag\index.js:557:25)
at _writeTag (---node_modules\st-ethernet-ip\dist\controller\index.js:805:24)
at _runTask (---node_modules\task-easy\src\index.js:118:9)
at _next (---node_modules\task-easy\src\index.js:138:18)
at <anonymous> (---node_modules\task-easy\src\index.js:56:22)
at schedule (---node_modules\task-easy\src\index.js:51:16)
at writeTag (---node_modules\st-ethernet-ip\dist\controller\index.js:608:35)
at run (---test\st-ethernet-ip.test.js:24:13)
at <anonymous> (---test\st-ethernet-ip.test.js:11:2)
at processTicksAndRejections (internal/process/task_queues:95:5)
Process exited with code 1
Here's the code:
const { Controller, Tag, TagList, EthernetIP } = require('st-ethernet-ip');
const { SINT, INT, DINT, REAL, BOOL, USINT, UINT, UDINT, WORD, DWORD } = EthernetIP.CIP.DataTypes.Types;
const plc = new Controller();
plc.connect('192.168.1.77', 0)
.then(() => {
console.log(`connected to PLC`)
run();
})
async function run()
{
const t = new Tag('boolarray.5', null, BOOL);
t.value = true;
await plc.writeTag(t);
}
Current Behavior
See above
Expected Behavior
Expect to write to a bit field of INT tag via "mainint.1" Expect to write a bit in "boolarray"
Possible Solution (Optional)
Context
Unable to write bits of integer tags or elements of BOOL array tags.
Steps to Reproduce (for bugs only)
See above
Your Environment
- Package version (Use
npm list- e.g. 1.0.6): 2.7.2 - Node Version (Use
node --version- e.g. 9.8.0): 21.7.1 - Operating System and version: Windows 10 x64 22H2
- Controller Type (eg 1756-L83E/B): 1769-L35E
- Controller Firmware (eg 30.11): 20.019
Boolean array is not stored as BOOL. It is probably DINT. The type of tag is based on the type before you use the bit index.