Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to write to bit in integer tag or BOOL[] array #69

Open
ryangriggs opened this issue Jun 14, 2024 · 1 comment
Open

Unable to write to bit in integer tag or BOOL[] array #69

ryangriggs opened this issue Jun 14, 2024 · 1 comment

Comments

@ryangriggs
Copy link

ryangriggs commented Jun 14, 2024

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
@ryangriggs ryangriggs changed the title Unable to write to bit in integer tag Unable to write to bit in integer tag or BOOL[] array Jun 14, 2024
@SerafinTech
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants