GithubHelp home page GithubHelp logo

Comments (10)

awcullen avatar awcullen commented on August 15, 2024

Thanks for question.
The InputArguments need to be an empty array to be encoded correctly.

func ExampleClient_Call() {

	ctx := context.Background()

	// open a connection to testserver running locally. Testserver is started if not already running.
	ch, err := client.Dial(
		ctx,
		"opc.tcp://localhost:48010",
		client.WithClientCertificatePaths("./pki/client.crt", "./pki/client.key"), // need secure channel to send password
		client.WithUserNameIdentity("root", "secret"),                             // need role of "operator" to call this method
		client.WithInsecureSkipVerify(),                                           // skips verification of server certificate
	)
	if err != nil {
		fmt.Printf("Error opening client connection. %s\n", err.Error())
		return
	}

	// prepare call request
	req := &ua.CallRequest{
		MethodsToCall: []ua.CallMethodRequest{
			{
				ObjectID:       ua.ObjectIDServerConfiguration,
				MethodID:       ua.MethodIDServerConfigurationApplyChanges,
				InputArguments: []ua.Variant{},
			},
		},
	}

	// send request to server. receive response or error
	res, err := ch.Call(ctx, req)
	if err != nil {
		fmt.Printf("Error calling method. %s\n", err.Error())
		ch.Abort(ctx)
		return
	}

	// print results
	fmt.Printf("Call method result:\n")
	fmt.Println(res.Results[0].StatusCode)

	// close connection
	err = ch.Close(ctx)
	if err != nil {
		ch.Abort(ctx)
		return
	}

	// Output:
	// Call method result:
	// The operation completed successfully.
}

from opcua.

BernhardH2 avatar BernhardH2 commented on August 15, 2024

Hi Andrew,

Many thanks for the quick reply. Although I'm fairly certain I tried it that way already, I'll double check on Monday and will post the results here.

from opcua.

BernhardH2 avatar BernhardH2 commented on August 15, 2024

Hi Andrew,

Unfortunately, the example does not yield any different results from what I've seen before. Let me try to illustrate what's currently happening and what is expected.

Current situation:
The Siemens PLC is in provisioning mode and all method calls to open, write, close and update the trustlists works as expected. As does creating a singing request and consequently updating the certificates. Only ApplyChanges is not showing the expected behaviour as seen in TIA Portal:
image
which overlaps with the trace of the method call:

2024/06/03 08:18:33 CallRequest{
 "AuthenticationToken": "i=2470488320",
 "Timestamp": "2024-06-03T08:18:33.9970046+02:00",
 "RequestHandle": 5,
 "ReturnDiagnostics": 0,
 "AuditEntryID": "",
 "TimeoutHint": 15000,
 "AdditionalHeader": null,
 "MethodsToCall": [
  {
   "ObjectID": "i=12637",
   "MethodID": "i=12740",
   "InputArguments": []
  }
 ]
}
2024/06/03 08:18:34 CallResponse{
 "Timestamp": "2024-06-03T06:18:38.8290046Z",
 "RequestHandle": 5,
 "ServiceResult": 0,
 "ServiceDiagnostics": {},
 "StringTable": null,
 "AdditionalHeader": null,
 "Results": [
  {
   "StatusCode": 0,
   "InputArgumentResults": null,
   "InputArgumentDiagnosticInfos": null,
   "OutputArguments": null
  }
 ],
 "DiagnosticInfos": null
}

However, when the method call is executed through UA Expert (or python for that matter), the method call is actually executed and the Diagnostics buffer indicates that provisioning has been successful:
image

So even though the operation is completed successfully, something seems to be going wrong.

Again, any help would be greatly appreciated and if I can provide any additional information to better understand the problem I would be happy to do so.

from opcua.

awcullen avatar awcullen commented on August 15, 2024

Is it possible you are connecting with different security mode or user identity?

Also, I have a S7-1500. I don't see the ServerConfiguration node. I'll have to do some reading :(

from opcua.

BernhardH2 avatar BernhardH2 commented on August 15, 2024

Hi Andrew,

I've just created a pull request with some GDS push example code. A connected PLC should be in provisioning mode, which can be achieved after following section 2.3 in this Siemens guide:
https://cache.industry.siemens.com/dl/files/888/109799888/att_1082229/v4/109799888_OPCUA_GDSPush_DOC_V1.0_en.pdf

The endpointURL and UserNameIdentitiy should probably be modified in cmd/testGDSPush/main.go, but all required certificates should generate automatically.

A hint on where the issue might originate from is that the method call returns BadInvalidState when executed from the example code. However, this should not be the case. The fact that the method can be successfully called from UA Expert and Python after OpenWriteCloseAndUpdate() demonstrates that the function call should execute successfully using Go too.

Let me know if this is of any help!

from opcua.

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.