jisotalo / ads-client

Unofficial Node.js ADS library for connecting to Beckhoff TwinCAT automation systems using ADS protocol.
https://jisotalo.fi/ads-client/
MIT License
77 stars 18 forks source link

idea: ads-client with Blockly, organization: VisualPLC, problem port 301 without address, #121

Closed runtimevic closed 7 months ago

runtimevic commented 9 months ago

Hi, idea suggestion: does this exist ads-client with blockly? I think it would be very good, thanks.

jisotalo commented 9 months ago

Could you elaborate more? What do you mean?

runtimevic commented 9 months ago

Hi @jisotalo , with blocks custom and with node.js and with your library to be able to read and write the variables, and create programs... https://blockly-demo.appspot.com/static/demos/code/index.html

runtimevic commented 7 months ago

Hello @jisotalo , @Hopperpop: If anyone wants to collaborate, you are invited.

VisualPLC

runtimevic commented 7 months ago

Hi @jisotalo , @Hopperpop ,

TwinCAT_ads-client_port301_error

Beckhoff_TwinCAT_port301

How can I send the connection without address, only with port? thanks Víctor.

runtimevic commented 7 months ago

Hello happy new year 2024: @jisotalo , @Hopperpop How can I send the connection without address, only with port 301? thanks Víctor.

jisotalo commented 7 months ago

Sorry @runtimevic , I don't understand what do you mean? If you leave localAmsNetId empty (or set is as localhost) it will connect to the local runtime.

runtimevic commented 7 months ago

Hi @jisotalo not work ... Setup 4 - Connect to the localhost (PLC and client on the same machine) targetAmsNetId = "localhost" port = 301 click create symbols , view image Blockly_TwinCAT_port_301_create_symbols Blockly_TwinCAT_port_301_log Blockly_TwinCAT_port_301 Blockly_TwinCAT_port_301_connect

runtimevic commented 7 months ago

Hi, I finally solved it:

  static async connect(address:string, port:number){

    Environment.client = new ads.Client({
      targetAmsNetId: address, //or 'localhost'
      targetAdsPort: port,
      bareClient: true, //NOTE
    })
Hopperpop commented 7 months ago

The problem is that with default settings it checks if the PLC runtime is running. As you don't have one configured it causes errors. For that you have the allowHalfOpen and bareClient option. As i understood allowHalfOpen will still checks if it finds the system manager to see if the system is in RUN or CONFIG. With bareClient is also skips that check. (@jisotalo Correct me if I'm wrong.)

runtimevic commented 7 months ago

Hi @Hopperpop , @jisotalo I solved it this way by adding the bareClient parameter:

Blockly_TwinCAT_port_301_without_PLC_bareClient

If you like the project and want to collaborate in the organization, you are welcome...

jisotalo commented 7 months ago

Good that you solved it!

@Hopperpop you absolutely right, thanks again!