Giter Club home page Giter Club logo

Comments (8)

jhenson29 avatar jhenson29 commented on July 3, 2024 1

This looks familiar. I was getting some weird error (I think this one) and I think it came down to group reads with a bad tag, but it was a while ago so I can’t be sure.

I’m in the habit now of always reading tags individually first to check that they work, then only adding them to a group if they were successful on the individual read.

from node-ethernet-ip.

cmseaton42 avatar cmseaton42 commented on July 3, 2024

Okay, can you share the snippet of code that seems to be causing the issue. This is a new one so I'd like to gather a little more context.

Thanks πŸ˜„

from node-ethernet-ip.

ajcanterbury avatar ajcanterbury commented on July 3, 2024

I don't know where this is coming from exactly. Most of the time everything works great. The error is random and not frequent.

I create a connection and then every three seconds I create a tag, read it, add that number of tags to a tag group, read it, then write to the tag group. Sort of like so:

// client.PLC Controller() and client.group TagGroup() is created the first time before the 3 sec loop
const strLen = new Tag('myTag.LEN', 'myProgram', DINT);
try {
  await client.PLC.readTag(strLen);
} catch (err) {
   throw err;
}

// first I clean out the old .DATA before adding the new to the group
client.group.forEach((oldTag) => {
  if (oldTag.name.includes(`myTag.DATA[`)) {
    client.group.remove(oldTag);
  }
});
for (let i=0; i<strLen[newTag].value; i++) {
  client.group.add(new Tag(`myTag.DATA[${i}]`, 'myProgram'));
}
// there are various other tags added to the group I'm leaving out
try {
  await client.PLC.readTagGroup(client.group);
} catch (err) {
  throw err;
}

// the writing is much more involved since data is coming from a separate source but for simplicity
const someText = 'Hello';
client.group.forEach((tag) => {
  charIndex = parseInt(tag.name.substring(tag.name.indexOf('.DATA[')+6, tag.name.length - 1), 10);
  tag.value = someText.charCodeAt(charIndex);
}

try {
  await client.PLC.writeTagGroup(client.group);
} catch (err) {
  throw err;
}

Sorry I don't have much more. The error could also be coming directly after the connect or shutdown.

from node-ethernet-ip.

cmseaton42 avatar cmseaton42 commented on July 3, 2024

@ajcanterbury Did you double to check to make sure every tag in the group read existed? If so, did this help resolve the issue?

from node-ethernet-ip.

ajcanterbury avatar ajcanterbury commented on July 3, 2024

I've not been able to link this error to a bad tag, not that this is not the case. There were multiple tests being performed when I saw this uncaught error. The problem is that I believe it would be very inefficient to check each individual tag programmatically since my group can be very large.

from node-ethernet-ip.

cmseaton42 avatar cmseaton42 commented on July 3, 2024

hmmmm, so you would prefer an option to let the group fail silently in the case that a bad tag is detected. Possibly auto-remove the bad tag from the group? just thinking out loud

from node-ethernet-ip.

ajcanterbury avatar ajcanterbury commented on July 3, 2024

Auto-remove could work if that's possible. Easy fix might be to throw an error for a bad buffer message and allowing the read to fail.

from node-ethernet-ip.

gfcittolin avatar gfcittolin commented on July 3, 2024

hmmmm, so you would prefer an option to let the group fail silently in the case that a bad tag is detected. Possibly auto-remove the bad tag from the group? just thinking out loud

Something like this might be a good idea. The Node-RED node for this library currently have issues in this case, as if there's a single tag that cannot be read, the whole reading fail. I even have a script to read a list of them individually, so I can check before reading them in a group.
Dropping them out of the group and emitting an event to signalize it would make it much easier :)

from node-ethernet-ip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.