SerafinTech / ST-node-ethernet-ip

Connect to PLC controllers with Node and Ethernet/ip
MIT License
36 stars 20 forks source link

Cannot write to a tag (BOOL) unless reading from it first #26

Closed skykep closed 1 year ago

skykep commented 1 year ago

Supposedly you can write to a tag without reading from it first so long as you declare the data type. This does not work.

Current Behavior

let heartbeatTag = new Tag("collectorHeartBeat", null, BOOL);
 await PLC[i][0].writeTag(heartbeatTag, true);

produces this: 2022-11-10 05:45:36Heartbeat Error: undefined which is my catch block when the heartbeat tag write fails

Expected Behavior

Write the tag successfully

Possible Solution (Optional)

Context

Steps to Reproduce (for bugs only)

1. 2. 3. 4.

Your Environment

skykep commented 1 year ago

For the heck of it, I just tried to modify the code to this instead, and it actually worked. So that's a minor bug, but workable.

          heartbeatTag.value = true;
          await PLC[i][0].writeTag(heartbeatTag);