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

opcflux panic: runtime error: invalid memory address or nil pointer dereference #20

Closed
bnjroos opened this issue Oct 21, 2019 · 17 comments

Comments

@bnjroos
Copy link

bnjroos commented Oct 21, 2019

I've installed opcflux and I get the following:

opcflux.exe -conf influx.yml -rate 1s
refresh rate:  1s
2019/10/18 14:04:22 config file:  influx.yml
Writing to opc_da_test at http:https://localhost:8086
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x718fd4]

goroutine 1 [running]:
github.com/go-ole/go-ole.(*IDispatch).VTable(...)
        C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch.go:18
github.com/go-ole/go-ole.getIDsOfName(0x0, 0xc00008b7f8, 0x1, 0x1, 0x0, 0x0, 0xc00008bbb0, 0xc00010e050, 0x2f)
        C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch_windows.go:20 +0x104
github.com/go-ole/go-ole.(*IDispatch).GetIDsOfName(...)
        C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch.go:22
github.com/go-ole/go-ole.(*IDispatch).GetSingleIDOfName(0x0, 0x8e0c76, 0x7, 0xc000106150, 0x2f, 0x0)
        C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch.go:47 +0x6e
github.com/go-ole/go-ole.(*IDispatch).InvokeWithOptionalArgs(0x0, 0x8e0c76, 0x7, 0xc000080001, 0xc00008b918, 0x2, 0x2, 0xc71d00, 0x11c06b0, 0x0)
        C:/Users/Administrator/go/src/github.com/go-ole/go-ole/idispatch.go:63 +0x4a
github.com/go-ole/go-ole/oleutil.CallMethod(...)
        C:/Users/Administrator/go/src/github.com/go-ole/go-ole/oleutil/oleutil.go:51
github.com/konimarti/opc.(*AutomationObject).Connect(0xc0000dc270, 0xc000120660, 0xe, 0xc000120670, 0x9, 0x4ce6c8, 0x0, 0x8e4353)
        C:/Users/Administrator/go/src/github.com/konimarti/opc/connection_windows.go:126 +0x1fa
github.com/konimarti/opc.(*AutomationObject).TryConnect(0xc0000dc270, 0xc000120660, 0xe, 0xc000108560, 0x2, 0x2, 0xc64580, 0x8cf940, 0xc000110b60)
        C:/Users/Administrator/go/src/github.com/konimarti/opc/connection_windows.go:161 +0xae
github.com/konimarti/opc.NewConnection(0xc000120660, 0xe, 0xc000108560, 0x2, 0x2, 0xc000136200, 0x6, 0x8, 0x0, 0x0, ...)
        C:/Users/Administrator/go/src/github.com/konimarti/opc/connection_windows.go:444 +0x8a
main.main()
        C:/Users/Administrator/go/src/github.com/konimarti/opc/cmds/opcflux/main.go:105 +0x972

Any idea how to make it work ?

thanks,

@konimarti
Copy link
Owner

@bnjroos What OPC DA Automation Wrapper do you have installed? Do the examples in the example folder work? Please add opc.Debug() to your code.

@bnjroos
Copy link
Author

bnjroos commented Oct 21, 2019

I've reinstalled gbda_aut.dll once again, no more errors however my server is not detected (cf opc-cli output). I manage to browse it using several tools such as MatrikonOPC Explorer, OpenOPC and another java library.

C:\Users\Administrator\go\bin>opc-cli.exe list localhost -d
OPC 2019/10/21 15:06:28 Could not load OPC Automation object with wrapper OPC.Automation.1
OPC 2019/10/21 15:06:28 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
Found 0 server(s) on 'localhost':

My opc server is codesys v2.3 server.

@konimarti
Copy link
Owner

This package uses the OPC Automation Interface (it loads the wrapper and executes the wrapper's code as you would in a VB application); it does not directly connect to the server unlike the applications you mentioned (see here for an OPC Automation Wrapper introduction).

If the examples work with the Graybox simulation server and Graybox wrapper than the code works. But, if it doesn't work in your setup, it has most likely something to do with the communication between your wrapper and the OPC server. To avoid this, I usually make sure that the entire application stack is 32bit or 64bit (opc da server, wrapper, and golang app). Hope this helps.

@bnjroos
Copy link
Author

bnjroos commented Oct 21, 2019

I've already put everything in 32bit, I've just installed Gray Box Simulator and my server now shows up however connection fails. Still trying to figure out why.

And gray box is not listed: screencap

@resoftw
Copy link
Contributor

resoftw commented Oct 28, 2019

Thank's :)

@navono
Copy link

navono commented Nov 14, 2019

I have the same problem with opc-cli list localhost.
I have installed gray_simulator and I can enum it in OPC Client:
OPC

In my Win10 64 bit system, how can I install OPC.Automation.1? The example also return the same error because in NewAutomationObject

wrappers := []string{"OPC.Automation.1", "Graybox.OPC.DAWrapper.1"}
	var err error
	var unknown *ole.IUnknown
	for _, wrapper := range wrappers {
		unknown, err = oleutil.CreateObject(wrapper)
		if err == nil {
			logger.Println("Loaded OPC Automation object with wrapper", wrapper)
			break
		}
		logger.Println("Could not load OPC Automation object with wrapper", wrapper)
	}
	if err != nil {
		return &AutomationObject{}
	}

return &AutomationObject{}

@konimarti
Copy link
Owner

konimarti commented Nov 14, 2019 via email

@navono
Copy link

navono commented Nov 14, 2019

@konimarti Yes, I have already installed OPC Core Components Redistributable (x64) 101.2 3.

@navono
Copy link

navono commented Nov 14, 2019

I checked my system with oleview, and found this:
OPC2

does it means need use OPC.Automation.2?

@konimarti
Copy link
Owner

konimarti commented Nov 14, 2019 via email

@navono
Copy link

navono commented Nov 14, 2019

OPC.Automation.1 does exist in the registry:

reg

but oleutil.CreateObject(wrapper) still failed. Are there any other clue I can follow up on?

@konimarti
Copy link
Owner

konimarti commented Nov 14, 2019 via email

@navono
Copy link

navono commented Nov 14, 2019

I try set GOARCH=386 in cmd, it works! Thank you very much!

I use goland x64, can't set 386 in it, also OS is 64 bit. So if I want it work in amd64, what do I need to do?

The version of OPC Core Components installed in my pc is x64:
COM

@ydwpython
Copy link

你好,可以提供一个供我调用的函数吗,我调用你这个函数,就可以列出电脑上面所有的opc服务器
而不是用cmd命令

@ydwpython
Copy link

我再次重新安装了gbda_aut.dll,没有更多错误,但是未检测到我的服务器(参见opc-cli输出)。我设法使用MatrikonOPC Explorer,OpenOPC和另一个Java库等几种工具进行浏览。

C:\Users\Administrator\go\bin>opc-cli.exe list localhost -d
OPC 2019/10/21 15:06:28 Could not load OPC Automation object with wrapper OPC.Automation.1
OPC 2019/10/21 15:06:28 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
Found 0 server(s) on 'localhost':

我的opc服务器是codesys v2.3服务器。

你好 请问你解决了吗,我也不行,

@annlumia
Copy link

annlumia commented May 7, 2020

I am done with Troubleshooting solution.

@linandli
Copy link

OPC 2020/09/19 18:17:15 Could not load OPC Automation object with wrapper OPC.Automation.1
OPC 2020/09/19 18:17:15 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
OPC 2020/09/19 18:17:15 Connecting to Matrikon.OPC.Simulation.1 on node localhost
OPC 2020/09/19 18:17:15 Connection failed.
err=========> TryConnect was not successful: Connection failed

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

7 participants