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

How to run? #30

Open
agn-7 opened this issue Jun 21, 2018 · 3 comments
Open

How to run? #30

agn-7 opened this issue Jun 21, 2018 · 3 comments

Comments

@agn-7
Copy link

agn-7 commented Jun 21, 2018

I'm new in GoLang.
I clone this project, how can I run a simple modbus/TCP holding register with these code files?

@ArlenFuCN
Copy link

Hi ,you don't clone this.
With Golang,you just use "go get " to download this package and install it.
then,in your project,you have to set the "GoPath".
and next, you just "import " this package,you can use this package's method.
about "go get" of goland,I think you can google it.you will get lots of information about it.

@agn-7
Copy link
Author

agn-7 commented Jun 29, 2018

Thanks, I set $GOPATH=$HOME/go in .bashrc and do go get github.com/goburrow/modbus.git in gopath location (~/go/) then I do go install github.com/goburrow/modbus/.
Then I create a go project and use go modbus library in my code.

This is my "gopath" tree:

go/
│── src
│   │── own_modbus
│   │   └── modbus.go
│   │
│   │── github.com
    │   └── goburrow
    │       ├── modbus
    │          ├──  . . .
              . . .

And this is my "own_modbus" code:

package main

import ("fmt"
	    "github.com/goburrow/modbus"
)

func main() {
	cli := modbus.TCPClient("192.168.1.150:502")
	res, err := cli.ReadHoldingRegisters(4096, 1)
	fmt.Println(res)
	fmt.Println(err)

}

Is there any "go modbus" documentation and examples such as pymodbus?

@nqv
Copy link
Member

nqv commented Jul 2, 2018

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

3 participants