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

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

Open
wgg2015 opened this issue Dec 7, 2022 · 3 comments

Comments

@wgg2015
Copy link

wgg2015 commented Dec 7, 2022

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

@konimarti
Copy link
Owner

Have you compiled the binary with GOARCH=386?

@wgg2015
Copy link
Author

wgg2015 commented Dec 11, 2022

Have you compiled the binary with GOARCH=386?

I am sorry for forget set GOARCH=386. but something wrong still exist
When the program executes to this function [addSingle],item.ToIDispatch() is nil, The reason for this result is AddItem return item.Val is 0。I don't know how to further analyze , it's cgo and no other error log

_//addSingle adds the tag and returns an error. Client handles are not implemented yet.
func (ai *AutomationItems) addSingle(tag string) error {
clientHandle := int32(1)
item, err := oleutil.CallMethod(ai.addItemObject, "AddItem", tag, clientHandle)
if err != nil {
return errors.New(tag + ":" + err.Error())
}
fmt.Printf("tag is %+v, item is %+v item.ToIDispatch is %+v\n", tag, item, item.ToIDispatch())
ai.items[tag] = item.ToIDispatch()
return nil
}
print : tag is device1.t1, item is &{VT:VT_DISPATCH wReserved1:0 wReserved2:0 wReserved3:0 Val:0} item.ToIDispatch is

Thank you very much for helping me

@wgg2015
Copy link
Author

wgg2015 commented Dec 11, 2022

Have you compiled the binary with GOARCH=386?

Have you compiled the binary with GOARCH=386?

I am sorry for forget set GOARCH=386. but something wrong still exist When the program executes to this function [addSingle],item.ToIDispatch() is nil, The reason for this result is AddItem return item.Val is 0。I don't know how to further analyze , it's cgo and no other error log

_//addSingle adds the tag and returns an error. Client handles are not implemented yet. func (ai *AutomationItems) addSingle(tag string) error { clientHandle := int32(1) item, err := oleutil.CallMethod(ai.addItemObject, "AddItem", tag, clientHandle) if err != nil { return errors.New(tag + ":" + err.Error()) } fmt.Printf("tag is %+v, item is %+v item.ToIDispatch is %+v\n", tag, item, item.ToIDispatch()) ai.items[tag] = item.ToIDispatch() return nil } print : tag is device1.t1, item is &{VT:VT_DISPATCH wReserved1:0 wReserved2:0 wReserved3:0 Val:0} item.ToIDispatch is

Thank you very much for helping me

I read the tag of kepserverEx6 "device1.t1", the kepserverEx6 print "尝试添加项‘device1.t1 失败’"

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

2 participants