Code Monkey home page Code Monkey logo

opc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opc's Issues

Example not working

opc.NewConnection not resolved

package main

import (
	"fmt"

	"github.com/konimarti/opc"
)

func main() {
	client, err := opc.NewConnection(
		"Graybox.Simulator",
		[]string{"localhost"},
		[]string{"numeric.sin.int64", "numeric.saw.float"},
	)
	defer client.Close()

	if err != nil {
		panic(err)
	}

	// read single tag: value, quality, timestamp
	fmt.Println(client.ReadItem("numeric.sin.int64"))

	// read all added tags
	fmt.Println(client.Read())
}

DCOM hardening in gray box module

I checked the dependent dll used in this project (auto DA wrapper from gray box) and found out that dll was compiled in 2008/2011 respectively for 32/64 bit OS. This would be an issue for servers which have applied MS DCOM hardening in recent years. Has anyone encountered any connection issue?

Another alternative is this. Since Go supports WebSocket, so we can take advantage of this to retrieve DA data back without this auto DA wrapper. Has anyone tried? There is no client sample code on Go from that repository unfortunately.

opcapi panic: unknown type

I installed OPC API to test reading and writing in tags. I can read my tags without problems.
But I have an error when I want to write in a tag with opcapi.
I launch an HTTP request with a PUT method and the following json:

{"Value": "mavalue", "type": "VT_BSTR"}.

I get this error: http: panic serving **: unkown type.

Is this the right way to call this API ?

opc-cli.exe扫描不到Matrikon.OPC.Simulation.1

你好,我本地有两台opc模拟仿真服务器,分别是:Kepware.KEPServerEX.V6和Matrikon.OPC.Simulation.1,但是我通过“opc-cli.exe list localhost”命令只能扫描到Kepware.KEPServerEX.V6,扫描不到Matrikon.OPC.Simulation.1,但是通过第三方客户端(opcclient)两台都可以扫描到。 有空请看一下,谢谢

Minor release request

Hi all,
I checked the code and there are some fixes that are not in the latest release.
Some of the changes solve some of the problems I am currently having. Would it be possible to make a minor release?

Connection not closed after function "CreateBrowser" execution

//CreateBrowser creates an opc browser representation
func CreateBrowser(server string, nodes []string) (*Tree, error) {
object := NewAutomationObject()
defer object.Close()
_, err := object.TryConnect(server, nodes)
if err != nil {
return nil, err
}
return object.CreateBrowser()
}

object.TryConnect(server, nodes) will create one connection ,however connection does`'t close after execution

tag/{id} api not support slash

tag name have "/" like: ES11_ES::211SG1/GROUP.#StatusPermanent
execute /tag/ES11_ES%3A%3A211SG1%2FM1.CNT2_OS will result "404 page not found"

strange issue

First, i can read the date from the remote Matrikon Simulation Server using your package
Second, i try to connect another OPC sever, but what is strange is that Matrikon Explore can connect the remote server, but the application with your package cannot, error is "TryConnect was not successful: Connection failed".
And explore and the application on the same machine. OPC Sever is in the another PC.
Could you please suggest something for me?

Timeout setting?

I'm connecting to remote OPC and looks like something is closing connection by timeout after 40 seconds:

OPC 2019/09/14 23:42:27 Could not load OPC Automation object with wrapper OPC.Automation.1
OPC 2019/09/14 23:42:28 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
OPC 2019/09/14 23:42:28 Connecting to XXXXXXXX.FSGateway.1 on node 1xx.xxx.xxx.xxx
OPC 2019/09/14 23:43:10 Connection failed.
panic: TryConnect was not successful: Connection failed

OPC by itself is fine, I successfully connecting to it using OPC Expert tool.

So give me an advice please, is it possible somehow to manipulate timeout?

Reading OPC data from device

from connection.go

//OPCDataSource defines constants for Sources when reading data from OPC:
//Default implementation is OPCCache.
//From the cache
OPCCache int32 = 1
//From the device
OPCDevice int32 = 2

there doesn't seem to be a way to read from device, can you confirm this?

Influxdb Authentication

Hello, this is my first time doing this so bear with me.

Following your guide, I'm trying to write to a test database, except I have authentication enabled on influxdb. I get this error:

Writing to test a http://192.168.x.x:8086
<"error":"unable to parse authentication credentials">

So I looked into the main.go file in the opcflux folder, and found

//setup influxdb client
//TODO: get username and password for influx from environment variables
c, err := client.NewHTTPClient(client.HTTPConfig{
Addr: conf.Influx.Addr,
//Username: conf.Influx.Username,
//Password: conf.Influx.Password,

Other than disabling auth on the database, how can I go about hard coding the username and password into go, at least until this part of the project gets finished.

How to deal with concurrent reading of tags

Now for one opc server, we only can read the tags one by one, If one of the tags cannot be read, the delay will increase.

Did you ever try the interface AddItems & SyncRead/ASyncRead for batch read?

I try to add the method, but it always return type mismatch error.

you can view detailed information through this issue, go-ole/go-ole#227.

Need help! Looks like client.Read() has a memory leak

Hi, I just used the sample program with for loop and noticed that when using client.Read() the memory usage keeps on growing. However, when reading single tag or tag by tag, it doesn't occur.

`
package main

import (
"fmt"
"github.com/konimarti/opc"
)

func main() {
client, err := opc.NewConnection(
"Prosys.OPC.Simulation",
[]string{"localhost"},
[]string{"Random.PsInteger1", "Static.PsString1"},
)
defer client.Close()

if err != nil {
	panic(err)
}
for {
	// read single tag: value, quality, timestamp
	//fmt.Println(client.ReadItem("Random.PsInteger1"))

	// read all added tags
	fmt.Println(client.Read()) //memory keeps on growing
}

}
`

reconnect & read opc data is zero

I test the connect lost & reconnect, than read opc data is zero.
there may be a bug here

func (conn *opcConnectionImpl) fix() {
	var err error
	if !conn.IsConnected() {
		for {
			tags := conn.Tags() // tags empty

If I have misinterpreted the expected behavior here, and there is a better way to do this please let me know.
thank you.

Error While Reading Config File

Hello,
I am getting the following error while reading the config file:

2020/05/16 11:41:16 config file: influx.yml
2020/05/16 11:41:16 error reading config file influx.yml
exit status 1

Not sure why, I have checked the config file , there seems to be no problem with it..

Subscribe example

Hello,
I have successfully browsed server for tags, and read their content. Great software and guidelines provided - thanks for that.

I am required to subscribe to be notified when a group of items was changed. Can you please refer me to a relevant example ? I am reading the OPC specification, but in go-ole package only reference I was able to find is calling a method and accessing a property.
How to get an event ?
Thanks for your support!
Alex

some questions

func main() {
opc.Debug()

client, err := opc.NewConnection("Kepware.KEPServerEX.V6", []string{"localhost"}, []string{"test.test1.1", "test.test1.2", "test.test1.3"})
if err != nil {
	fmt.Println(err)
	return
}

for i := 0; i < 100; i++ {
	v := client.ReadItem("test.test1.1")
	fmt.Println("i: ", i, ", value: ", v)

	v = client.ReadItem("test.test1.2")
	fmt.Println("i: ", i, ", value: ", v)

	v = client.ReadItem("test.test1.3")
	fmt.Println("i: ", i, ", value: ", v)
	time.Sleep(time.Second)
	fmt.Println("//--------------------------------------------------//")
}

defer client.Close()

}

output:
2019/08/21 08:52:32 Could not load OPC Automation object with wrapper OPC.Automation.1
2019/08/21 08:52:32 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
2019/08/21 08:52:32 Connecting to Kepware.KEPServerEX.V6 on node localhost
2019/08/21 08:54:32 Connected.
i: 0 , value: { 8 2019-08-21 00:54:32 +0000 UTC}
i: 0 , value: { 8 2019-08-21 00:54:32 +0000 UTC}
i: 0 , value: { 8 2019-08-21 00:54:32 +0000 UTC}
//--------------------------------------------------//
i: 1 , value: {3 192 2019-08-21 00:54:33 +0000 UTC}
i: 1 , value: {true 192 2019-08-21 00:54:33 +0000 UTC}
i: 1 , value: {false 192 2019-08-21 00:54:33 +0000 UTC}
//--------------------------------------------------//
i: 2 , value: {3 192 2019-08-21 00:54:34 +0000 UTC}
i: 2 , value: {true 192 2019-08-21 00:54:34 +0000 UTC}
i: 2 , value: {false 192 2019-08-21 00:54:34 +0000 UTC}
//--------------------------------------------------//
i: 3 , value: {3 192 2019-08-21 00:54:35 +0000 UTC}
i: 3 , value: {true 192 2019-08-21 00:54:35 +0000 UTC}
i: 3 , value: {false 192 2019-08-21 00:54:35 +0000 UTC}
//--------------------------------------------------//
i: 4 , value: {3 192 2019-08-21 00:54:36 +0000 UTC}
i: 4 , value: {true 192 2019-08-21 00:54:36 +0000 UTC}
i: 4 , value: {false 192 2019-08-21 00:54:36 +0000 UTC}
//--------------------------------------------------//
i: 5 , value: {3 192 2019-08-21 00:54:37 +0000 UTC}
i: 5 , value: {true 192 2019-08-21 00:54:37 +0000 UTC}
i: 5 , value: {false 192 2019-08-21 00:54:37 +0000 UTC}
//--------------------------------------------------//

question:
The value of the first reading is not right The values read the second time and after that are correct.

Question regarding program sometimes crashes at readFromOpc

I use readFromOpc & Read once a second asynchronously. Program sometimes crashes and irregularly.

goVersion:(go1.14.4) GOARCH:amd64
The read types include Random.Real8, Bool, Int1, String, Time, I use MatrikonOpc server for simulation.

//[email protected]
Exception 0xc0000005 0x0 0xc0005ad8a0 0x2a62adb3
PC=0x2a62adb3

syscall.Syscall9(0x2a62c3cc, 0x9, 0x2ac1f540, 0x60020011, 0xc0000188f0, 0x404, 0x1, 0xc0005c1648, 0xc00034a020, 0xc0005c16e8, ...)
        C:/go/src/runtime/syscall_windows.go:214 +0xf2
github.com/go-ole/go-ole.invoke(0x2ac1f540, 0x160020011, 0xc0005c1930, 0x4, 0x4, 0xc00034a020, 0x0, 0x0)
        D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch_windows.go:175 +0x228
github.com/go-ole/go-ole.(*IDispatch).Invoke(...)
        D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:27
github.com/go-ole/go-ole.(*IDispatch).InvokeWithOptionalArgs(0x2ac1f540, 0xb025be, 0x4, 0x1, 0xc0005ad930, 0x4, 0x4, 0x4e8d48, 0x104ebc0, 0xaeab40)
        D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:71 +0x103
github.com/go-ole/go-ole/oleutil.CallMethod(...)
        D:/go/pkg/mod/github.com/go-ole/[email protected]/oleutil/oleutil.go:51


//[email protected]
Exception 0xc0000005 0x0 0xc000675c48 0x2a65adb3
PC=0x2a65adb3

syscall.Syscall9(0x2a65c3cc, 0x9, 0x2adf7b30, 0x60020011, 0xc0000188f0, 0x404, 0x1, 0xc0005f1a50, 0xc000248000, 0xc0005f1af0, ...)
        C:/go/src/runtime/syscall_windows.go:214 +0xf2
github.com/go-ole/go-ole.invoke(0x2adf7b30, 0x160020011, 0xc0005f1cd8, 0x4, 0x4, 0xc000248000, 0x0, 0x0)
        D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch_windows.go:175 +0x229
github.com/go-ole/go-ole.(*IDispatch).Invoke(...)
        D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:27
github.com/go-ole/go-ole.(*IDispatch).InvokeWithOptionalArgs(0x2adf7b30, 0xb02f1e, 0x4, 0x410001, 0xc000675cd8, 0x4, 0x4, 0xc000307fc0, 0x746000000000000, 0x6)
        D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:71 +0x103
github.com/go-ole/go-ole/oleutil.CallMethod(...)
        D:/go/pkg/mod/github.com/go-ole/[email protected]/oleutil/oleutil.go:51
usi/dcs-adapter/internal/opclibary.(*AutomationItems).readFromOpc(0xc000833e20, 0x2adf7b30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)

goroutine 60 [select]:
net/http.(*persistConn).writeLoop(0xc000216480)
        C:/go/src/net/http/transport.go:2277 +0x123
created by net/http.(*Transport).dialConn
        C:/go/src/net/http/transport.go:1648 +0xc82
rax     0x1d7d326befb30b0
rbx     0x0
rcx     0xffffdff3
rdi     0xc0003a1c78
rsi     0x2a9d7690
rbp     0xc0003a1c90
rsp     0x2986f860
r8      0x1826730
r9      0x7dd
r10     0x2a9d7700
r11     0xc0
r12     0xc0005e1c60
r13     0x2a889268
r14     0x2986f950
r15     0x2986f970
rip     0x2a86adb3
rflags  0x10206
cs      0x33
fs      0x53
gs      0x2b

Is this a network problem or a problem caused by COM?

Why I can not find the server in the localhost?

I have start the IntellutionGateWayOPCServer, and my IntellutionGateWayOPCClient can find this OPCDAServer. But I can not find this server by running the follow code:
opc.Debug()
servers_found := opc.NewAutomationObject().GetOPCServers("localhost")
fmt.Printf("Found %d server(s) on '%s':\n", len(servers_found), "localhost")

the result is:
API server listening at: 127.0.0.1:54240
2019/07/15 11:08:50 Could not load OPC Automation object with wrapper OPC.Automation.1
2019/07/15 11:08:50 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
Found 0 server(s) on 'localhost':
2019/07/15 11:08:50 GetOPCServers call failed.

How to deal with it?
thank you !

The opc server Matrikon.OPC.Simulation.1 cannot be obtained using opc-cli.exe

Hello, I have two opc simulation servers locally, namely: Kepware.KEPServerEX.V6 and Matrikon.OPC.Simulation.1, but I can only get Kepware.KEPServerEX.V6 with the "opc-cli.exe list localhost" command, Matrikon.OPC.Simulation.1 cannot be obtained, and both can be obtained with other third-party clients. Please take a look if you have time, thanks

GetOPCServers return empty string array?

with code:
`

			object, err := opc.NewAutomationObject()

			if err != nil {
				panic(err)
			}

			fmt.Println(object.GetOPCServers(""))

`
while result is:

2019/06/25 12:57:26 Loaded OPC Automation object with wrapper OPC.Automation.1
[]

but i actually have a local Graybox.Simulator

panic: runtime error: invalid memory address or nil pointer dereference

I cloned the repo, and ran go test -v ./... but I keep getting this error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x1015168]

Manually testing this package by trying to follow the example on the main page with a running OPC server on my PC also yields this result.

I'm running go 1.17.1 on Windows 10. Here's my test code:

package main

import (
	"fmt"
	"github.com/konimarti/opc"
)

func main() {
	c, _ := opc.NewConnection(
		"Fluke.DAQ.OPC",
		[]string{"DESKTOP-<redacted>"},
		[]string{"Instrument 01.Module 3.Channel 304"},
	)
	defer c.Close()
	fmt.Println(c.Read())
}

Could not load OPC Automation object with wrapper OPC.Automation.1

my machine is x64
and i has copy x64 gbda_aut.dll on System32 path
but has title error yet.

i don't know the question reason.

Could not load OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
and has this error

they're different error?

i need you help,plz

Compilation finished with exit code 2

Hello! I have a problem with compilation. It says "Compilation finished with exit code 2" (I use windows 7 x64). Could you explan, how can I solve this problem and where can I get the "OPC DA Automation Wrapper 2.02" and "ÒPCDAAuto.dll" and in which folder should I extract them?

6vcn6ehu5-q

read() to get discribe and datatype info

hello,
if i want to get opcitem discribe and datatype info
v := ole.NewVariant(ole.VT_R4, 0)
q := ole.NewVariant(ole.VT_INT, 0)
ts := ole.NewVariant(ole.VT_DATE, 0)

how i should add the ole VT TYPE.

Crash on working with remote node

I trying to connect to the remote server.

client := opc.NewConnection(
		"Prosys.OPC.Service", // ProgId
		[]string{"192.168.7.51"}, //  OPC servers nodes
		[]string{"Bucket Brigade.ArrayOfReal8"},
	)
defer client.Close()

And I get a panic:

panic: TryConnect was not successful: Connection failed


goroutine 1 [running]:
github.com/konimarti/opc.NewConnection(0x83bbd0, 0x12, 0xc0000331b0, 0x1, 0x1, 0xc00003d500, 0x62, 0x62, 0x853678, 0xc00006c000)
	C:/projects/opcda2opcua/src/github.com/konimarti/opc/connection_windows.go:335 +0x269
main.main()
	C:/projects/opcda2opcua/src/gitlabinternal.litmusloop.com/loop-edge/opcda2opcua/main.go:10 +0xec

What I was doing wrong? Matrikon Explorer works with this server.

connection.Read returns 0 when reading a Kepware Server tag

I'm trying to read simulated values from a Kepware server but the connection.Read returns 0 while the tag i'm trying to read can't be 0.

package main

import (
	"fmt"

	"github.com/konimarti/opc"
)

func main() {
	opc.Debug()
	client, err := opc.NewConnection(
		"Kepware.KEPServerEX.V6",
		[]string{"localhost"},
		[]string{"Channel1.Device1.Sinus1"},
	)
	defer client.Close()
	if err != nil {
		panic(err)
	}
	// read single tag: value, quality, timestamp
	fmt.Println(client.ReadItem("Channel1.Device1.Sinus1"))
}

returns this:

2019/07/10 16:39:06 Could not load OPC Automation object with wrapper OPC.Automation.1                                                                                                                                   2019/07/10 16:39:06 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
2019/07/10 16:39:06 Connecting to Kepware.KEPServerEX.V6 on node localhost
2019/07/10 16:39:06 Connected.
{<nil> 8 2019-07-10 14:39:06 +0000 UTC}

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

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://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,

Higher versions of Golang will crash

At that time, I was using a higher version of Golang (Version>=1.14),when this method is executed, an error will be reported and the program will crash.
D:\go\pkg\mod\github.com\go-ole\[email protected]\oleutil\oleutil.go

func CallMethod(disp *ole.IDispatch, name string, params ...interface{}) (result *ole.VARIANT, err error) {
return disp.InvokeWithOptionalArgs(name, ole.DISPATCH_METHOD, params)
}

The panic error such as blows:
textual

  • textual.color
  • textual.number
  • textual.random
  • textual.weekday
    Exception 0xc0000005 0x0 0x566a7d10 0x1f51b1d9
    PC=0x1f51b1d9

runtime.cgocall(0x887d20, 0xd81c20)
D:/software/go/src/runtime/cgocall.go:158 +0x4a fp=0xc000129a28 sp=0xc0001299f0 pc=0x8248ea
syscall.SyscallN(0x0?, {0xc000129ac0?, 0x0?, 0xd81960?})
D:/software/go/src/runtime/syscall_windows.go:557 +0x109 fp=0xc000129aa0 sp=0xc000129a28 pc=0x882f69
syscall.Syscall9(0xc000000000?, 0x824987?, 0xc000046000?, 0xc000129bb8?, 0x882f9c?, 0x887d20?, 0xd81c20?, 0xc000129bd8?, 0x882f9c?, 0xc000129c70, ...)
D:/software/go/src/runtime/syscall_windows.go:507 +0x78 fp=0xc000129b18 sp=0xc000129aa0 pc=0x882e38
github.com/go-ole/go-ole.invoke(0x26b566a7a20, 0x6002000b, 0x1, {0xc000129db0, 0x2, 0x26b566a7a20?})
D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch_windows.go:175 +0x14e6 fp=0xc000129d00 sp=0xc000129b18 pc=0x92da66
github.com/go-ole/go-ole.(*IDispatch).Invoke(...)
D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:27
github.com/go-ole/go-ole.(*IDispatch).InvokeWithOptionalArgs(0x9?, {0xb2145e?, 0x11?}, 0x94e0?, {0xc000129db0, 0x2, 0x2})
D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:71 +0x85 fp=0xc000129d48 sp=0xc000129d00 pc=0x92c005
github.com/go-ole/go-ole/oleutil.CallMethod(...)
D:/go/pkg/mod/github.com/go-ole/[email protected]/oleutil/oleutil.go:51
github.com/konimarti/opc.(*AutomationItems).addSingle(0xc0000538c0, {0xc000076a20, 0xd})
D:/go/src/github.com/konimarti/opc/connection_windows.go:263 +0xb5 fp=0xc000129de0 sp=0xc000129d48 pc=0xaa6ad5
github.com/konimarti/opc.(*AutomationItems).Add(0xac94e0?, {0xc00005e400?, 0x4, 0xc000052220?})
D:/go/src/github.com/konimarti/opc/connection_windows.go:275 +0xe5 fp=0xc000129e40 sp=0xc000129de0 pc=0xaa6d05
github.com/konimarti/opc.NewConnection({0xb24e62, 0x11}, {0xc000052220, 0x1, 0x1}, {0xc00005e400, 0x4, 0x4})
D:/go/src/github.com/konimarti/opc/connection_windows.go:473 +0xcb fp=0xc000129ee8 sp=0xc000129e40 pc=0xaa84eb
main.main()
D:/go/src/github.com/konimarti/opc/example/browser.go:26 +0xd6 fp=0xc000129f80 sp=0xc000129ee8 pc=0xaa9e36
runtime.main()
D:/software/go/src/runtime/proc.go:250 +0x1fe fp=0xc000129fe0 sp=0xc000129f80 pc=0x85ba3e
runtime.goexit()
D:/software/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000129fe8 sp=0xc000129fe0 pc=0x886461

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
D:/software/go/src/runtime/proc.go:363 +0xd6 fp=0xc000049fb0 sp=0xc000049f90 pc=0x85bdd6
runtime.goparkunlock(...)
D:/software/go/src/runtime/proc.go:369
runtime.forcegchelper()
D:/software/go/src/runtime/proc.go:302 +0xb1 fp=0xc000049fe0 sp=0xc000049fb0 pc=0x85bc71
runtime.goexit()
D:/software/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000049fe8 sp=0xc000049fe0 pc=0x886461
created by runtime.init.6
D:/software/go/src/runtime/proc.go:290 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
D:/software/go/src/runtime/proc.go:363 +0xd6 fp=0xc00004bf90 sp=0xc00004bf70 pc=0x85bdd6
runtime.goparkunlock(...)
D:/software/go/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
D:/software/go/src/runtime/mgcsweep.go:278 +0x8e fp=0xc00004bfc8 sp=0xc00004bf90 pc=0x84552e
runtime.gcenable.func1()
D:/software/go/src/runtime/mgc.go:178 +0x26 fp=0xc00004bfe0 sp=0xc00004bfc8 pc=0x83a0c6
runtime.goexit()
D:/software/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004bfe8 sp=0xc00004bfe0 pc=0x886461
created by runtime.gcenable
D:/software/go/src/runtime/mgc.go:178 +0x6b

How config dcomcnfg.exe in win10

hi, i use this in win10

  1. first install graybox sm
  2. install auto wrap and register
  3. connect to opc ser

but has a connect error:
panic: TryConnect was not successful: Connection failed

how can i deal it, tks!

something wrong in cgo when I try read tag by "opc-cli.exe read localhost Graybox.Simulator.1 options.sinfreq numeric.sin.float"

sabozhao@sabozhao-PC2 MINGW64 /e/dev/opc ((v0.3.1))
$ opc-cli.exe read localhost Graybox.Simulator.1 options.sinfreq numeric.sin.float
Exception 0xc0000005 0x0 0x25e01800 0x1f51b1d9
PC=0x1f51b1d9

runtime.cgocall(0xa44da0, 0xfb6080)
C:/Users/sabozhao/sdk/go1.18beta1/src/runtime/cgocall.go:157 +0x4a fp=0xc0000cb7c0 sp=0xc0000cb788 pc=0x9e432a
syscall.SyscallN(0x0?, {0xc0000cb858?, 0x0?, 0xfb5da0?})
C:/Users/sabozhao/sdk/go1.18beta1/src/runtime/syscall_windows.go:538 +0x109 fp=0xc0000cb838 sp=0xc0000cb7c0 pc=0xa40049
syscall.Syscall9(0xc000000000?, 0x9e43c7?, 0xc000052000?, 0xc0000cb950?, 0xa4007c?, 0xa44da0?, 0xfb6080?, 0xc0000cb970?, 0xa4007c?, 0xc0000cba08, ...)
C:/Users/sabozhao/sdk/go1.18beta1/src/runtime/syscall_windows.go:488 +0x78 fp=0xc0000cb8b0 sp=0xc0000cb838 pc=0xa3ff18
github.com/go-ole/go-ole.invoke(0x1a625e012d0, 0x6002000b, 0x1, {0xc0000cbb48, 0x2, 0x1a625e012d0?})
C:/Users/sabozhao/go/pkg/mod/github.com/go-ole/[email protected]/idispatch_windows.go:175 +0x14c6 fp=0xc0000cba98 sp=0xc0000cb8b0 pc=0xaee366
github.com/go-ole/go-ole.(*IDispatch).Invoke(...)
C:/Users/sabozhao/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:27
github.com/go-ole/go-ole.(*IDispatch).InvokeWithOptionalArgs(0x9?, {0xd282e9?, 0x13?}, 0x6b40?, {0xc0000cbb48, 0x2, 0x2})
C:/Users/sabozhao/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:71 +0x85 fp=0xc0000cbae0 sp=0xc0000cba98 pc=0xaec925
github.com/go-ole/go-ole/oleutil.CallMethod(...)
C:/Users/sabozhao/go/pkg/mod/github.com/go-ole/[email protected]/oleutil/oleutil.go:51
github.com/konimarti/opc.(*AutomationItems).addSingle(0xc00005e3e0, {0xc0000aa0d0, 0xf})
E:/dev/opc/connection_windows.go:253 +0xb5 fp=0xc0000cbb78 sp=0xc0000cbae0 pc=0xc4efd5
github.com/konimarti/opc.(*AutomationItems).Add(0x9ed5a5?, {0xc00006a1a0?, 0x2, 0xc00005e380?})
E:/dev/opc/connection_windows.go:270 +0xe5 fp=0xc0000cbbd8 sp=0xc0000cbb78 pc=0xc4f205
github.com/konimarti/opc.NewConnection({0xc0000ae078, 0x13}, {0xc00005e380, 0x1, 0x1}, {0xc00006a1a0, 0x2, 0x2})
E:/dev/opc/connection_windows.go:468 +0xcb fp=0xc0000cbc80 sp=0xc0000cbbd8 pc=0xc509cb
main.main.func4(0xc00007e780?, {0xc00006a180, 0x4, 0x4})
E:/dev/opc/cmds/opc-cli/main.go:93 +0x1f1 fp=0xc0000cbd38 sp=0xc0000cbc80 pc=0xca2511
github.com/spf13/cobra.(*Command).execute(0xc00007e780, {0xc00006a100, 0x4, 0x4})
C:/Users/sabozhao/go/pkg/mod/github.com/spf13/[email protected]/command.go:830 +0x663 fp=0xc0000cbe10 sp=0xc0000cbd38 pc=0xc99c03
github.com/spf13/cobra.(*Command).ExecuteC(0xc00007ec80)
C:/Users/sabozhao/go/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x2ee fp=0xc0000cbec8 sp=0xc0000cbe10 pc=0xc9a0ce
github.com/spf13/cobra.(*Command).Execute(...)
C:/Users/sabozhao/go/pkg/mod/github.com/spf13/[email protected]/command.go:864
main.main()
E:/dev/opc/cmds/opc-cli/main.go:135 +0x388 fp=0xc0000cbf80 sp=0xc0000cbec8 pc=0xca2ce8
runtime.main()
C:/Users/sabozhao/sdk/go1.18beta1/src/runtime/proc.go:255 +0x217 fp=0xc0000cbfe0 sp=0xc0000cbf80 pc=0xa19477
runtime.goexit()
C:/Users/sabozhao/sdk/go1.18beta1/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0000cbfe8 sp=0xc0000cbfe0 pc=0xa43521
rax 0x0
rbx 0x25e01760
rcx 0xffffffff
rdi 0x1a67ed59a78
rsi 0x1
rbp 0x1a67ed5afd0
rsp 0x9d55dff4f0
r8 0x25e01800
r9 0x1a67ed5afd0
r10 0x0
r11 0x246
r12 0x1a67ed5b850
r13 0x1
r14 0x9d55dff7a0
r15 0xffffffff
rip 0x1f51b1d9
rflags 0x10246
cs 0x33
fs 0x53
gs 0x2b

opc.NewConnection error

main.go:

       opc.Debug()

	client, _ := opc.NewConnection(
		"Graybox.Simulator",   // ProgId
		[]string{"localhost"}, //  OPC servers nodes
		[]string{"numeric.sin.int64", "numeric.saw.float"}, // slice of OPC tags
	)
	defer client.Close()

	// read single tag: value, quality, timestamp
	fmt.Println(client.ReadItem("numeric.sin.int64"))

	// read all added tags
	fmt.Println(client.Read())

err log:

OPC 2024/01/31 13:44:03 Could not load OPC Automation object with wrapper OPC.Automation.1
OPC 2024/01/31 13:44:03 Loaded OPC Automation object with wrapper Graybox.OPC.DAWrapper.1
OPC 2024/01/31 13:44:03 Connecting to Graybox.Simulator on node localhost
OPC 2024/01/31 13:44:03 Connected.
Exception 0xc0000005 0x0 0xa00d5e40 0x1f51b1d9
PC=0x1f51b1d9

runtime.cgocall(0xfc3be0, 0x17bc8c0)
        D:/go/src/runtime/cgocall.go:157 +0x4a fp=0xc00007f1e8 sp=0xc00007f1b0 pc=0xf5544a
syscall.SyscallN(0x1f514ed4, {0xc00007f290?, 0x9, 0x8040178c180?})
        D:/go/src/runtime/syscall_windows.go:557 +0x12e fp=0xc00007f270 sp=0xc00007f1e8 pc=0xfbedee
syscall.Syscall9(0x0?, 0x3?, 0x1?, 0xc00007f330?, 0x10795cb?, 0xc000100500?, 0xc000100500?, 0xc00007f370?, 0xf90173?, 0xc00007f7e0, ...)
        D:/go/src/runtime/syscall_windows.go:507 +0x78 fp=0xc00007f2e8 sp=0xc00007f270 pc=0xfbead8
github.com/go-ole/go-ole.invoke(0x1a8a00d5720, 0x6002000b, 0x1, {0xc00007fb38, 0x2, 0x2})
        D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch_windows.go:176 +0x307 fp=0xc00007f860 sp=0xc00007f2e8 pc=0x115e407
github.com/go-ole/go-ole.(*IDispatch).Invoke(0x1a8a00d5720, 0x6002000b, 0x1, {0xc00007fb38, 0x2, 0x2})
        D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:27 +0x99 fp=0xc00007f8e0 sp=0xc00007f860 pc=0x115cff9
github.com/go-ole/go-ole.(*IDispatch).InvokeWithOptionalArgs(0x1a8a00d5720, {0x1519116, 0x7}, 0x1, {0xc00007fb38, 0x2, 0x2})
        D:/go/pkg/mod/github.com/go-ole/[email protected]/idispatch.go:71 +0x1f5 fp=0xc00007f9a0 sp=0xc00007f8e0 pc=0x115d615
github.com/go-ole/go-ole/oleutil.CallMethod(0x1a8a00d5720, {0x1519116, 0x7}, {0xc00007fb38, 0x2, 0x2})
        D:/go/pkg/mod/github.com/go-ole/[email protected]/oleutil/oleutil.go:51 +0xae fp=0xc00007fa30 sp=0xc00007f9a0 pc=0x116a12e
github.com/konimarti/opc.(*AutomationItems).addSingle(0xc000204070, {0x151dab2, 0x11})
        D:/go/pkg/mod/github.com/konimarti/[email protected]/connection_windows.go:263 +0x18e fp=0xc00007fb68 sp=0xc00007fa30 pc=0x1470cee
github.com/konimarti/opc.(*AutomationItems).Add(0xc000204070, {0xc00007fef0, 0x2, 0x2})
        D:/go/pkg/mod/github.com/konimarti/[email protected]/connection_windows.go:275 +0xd8 fp=0xc00007fc38 sp=0xc00007fb68 pc=0x1470f98
github.com/konimarti/opc.NewConnection({0x151d672, 0x11}, {0xc000204000, 0x1, 0x1}, {0xc00007fef0, 0x2, 0x2})
        D:/go/pkg/mod/github.com/konimarti/[email protected]/connection_windows.go:473 +0x1f8 fp=0xc00007fd48 sp=0xc00007fc38 pc=0x1473678
main.main()
        F:/unicom/unicom/src/hde-gateway-opcda-client/main.go:12 +0x16e fp=0xc00007ff80 sp=0xc00007fd48 pc=0x147518e
runtime.main()
        D:/go/src/runtime/proc.go:250 +0x1be fp=0xc00007ffe0 sp=0xc00007ff80 pc=0xf93a1e
runtime.goexit()
        D:/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00007ffe8 sp=0xc00007ffe0 pc=0xfc2221

goroutine 2 [force gc (idle)]:
runtime.gopark(0x15509e0, 0x17bb6b0, 0x11, 0x14, 0x1)
        D:/go/src/runtime/proc.go:381 +0xfd fp=0xc00003bf88 sp=0xc00003bf58 pc=0xf93e9d
runtime.goparkunlock(0x0?, 0x0?, 0x0?, 0x0?)
        D:/go/src/runtime/proc.go:387 +0x2a fp=0xc00003bfb8 sp=0xc00003bf88 pc=0xf93f2a
runtime.forcegchelper()
        D:/go/src/runtime/proc.go:305 +0xb0 fp=0xc00003bfe0 sp=0xc00003bfb8 pc=0xf93c70
runtime.goexit()
        D:/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00003bfe8 sp=0xc00003bfe0 pc=0xfc2221
created by runtime.init.6
        D:/go/src/runtime/proc.go:293 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x15509e0, 0x17bbc40, 0xc, 0x14, 0x1)
        D:/go/src/runtime/proc.go:381 +0xfd fp=0xc00003df58 sp=0xc00003df28 pc=0xf93e9d
runtime.goparkunlock(0x0?, 0x0?, 0x0?, 0x0?)
        D:/go/src/runtime/proc.go:387 +0x2a fp=0xc00003df88 sp=0xc00003df58 pc=0xf93f2a
runtime.bgsweep(0x0?)
        D:/go/src/runtime/mgcsweep.go:278 +0x98 fp=0xc00003dfc8 sp=0xc00003df88 pc=0xf7a698
runtime.gcenable.func1()
        D:/go/src/runtime/mgc.go:178 +0x26 fp=0xc00003dfe0 sp=0xc00003dfc8 pc=0xf6eaa6
runtime.goexit()
        D:/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00003dfe8 sp=0xc00003dfe0 pc=0xfc2221
created by runtime.gcenable
        D:/go/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0x15509e0, 0x17bc0e0, 0xd, 0x14, 0x2)
        D:/go/src/runtime/proc.go:381 +0xfd fp=0xc00004bf48 sp=0xc00004bf18 pc=0xf93e9d
runtime.goparkunlock(0x15701f8?, 0x1?, 0x0?, 0x0?)
        D:/go/src/runtime/proc.go:387 +0x2a fp=0xc00004bf78 sp=0xc00004bf48 pc=0xf93f2a
runtime.(*scavengerState).park(0x17bc0e0)
        D:/go/src/runtime/mgcscavenge.go:400 +0x4b fp=0xc00004bfa0 sp=0xc00004bf78 pc=0xf7814b
runtime.bgscavenge(0x0?)
        D:/go/src/runtime/mgcscavenge.go:628 +0x45 fp=0xc00004bfc8 sp=0xc00004bfa0 pc=0xf78725
runtime.gcenable.func2()
        D:/go/src/runtime/mgc.go:179 +0x26 fp=0xc00004bfe0 sp=0xc00004bfc8 pc=0xf6ea46
runtime.goexit()
        D:/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00004bfe8 sp=0xc00004bfe0 pc=0xfc2221
created by runtime.gcenable
        D:/go/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait]:
runtime.gopark(0x15506d8, 0x18120a8, 0x10, 0x14, 0x1)
        D:/go/src/runtime/proc.go:381 +0xfd fp=0xc00003fe28 sp=0xc00003fdf8 pc=0xf93e9d
runtime.runfinq()
        D:/go/src/runtime/mfinal.go:193 +0x107 fp=0xc00003ffe0 sp=0xc00003fe28 pc=0xf6db07
runtime.goexit()
        D:/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00003ffe8 sp=0xc00003ffe0 pc=0xfc2221
created by runtime.createfing
        D:/go/src/runtime/mfinal.go:163 +0x50
rax     0x0
rbx     0xa00d5da0
rcx     0xffffffff
rdi     0x1a8f8ce8c98
rsi     0x1
rbp     0x1a8f8ceb5c0
rsp     0x375a3ff680
r8      0xa00d5e40
r9      0x1a8f8ceb6e0
r10     0x1a8f8cb5000
r11     0x375a3ff650
r12     0x1a8f8ceb6e0
r13     0x1
r14     0x375a3ff930
r15     0xffffffff
rip     0x1f51b1d9
rflags  0x10246
cs      0x33
fs      0x53
gs      0x2b

debug into code "connection_windows.go", line of 473, "err = items.Add(tags...)", here items' addItemObject is with ole.IUnknown for "unreadable : could not resolve interface type", what's the problem?

Bug in opcConnectionImpl fix()

In the conn.fix() loop the conn.AutomationItems.Close() method causes the AutomationItems to be nil, this will result in the following panic:
panic: runtime error: invalid memory address or nil pointer dereference
@ line 396 in the conn.Tags() method and later @ line 322 in the conn.AutomationItems.Close() method when the first tryconnect was not successfull and it loops back. Maybe add a check to check if conn.AutomationItems != nil in these functions?

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.