update gomodbus

remove mb package
run go tidy
This commit is contained in:
thinkgo 2021-02-02 20:29:53 +08:00
parent 740ceafbcb
commit f4bd009c42
3 changed files with 10 additions and 26 deletions

5
go.mod
View File

@ -26,13 +26,10 @@ require (
github.com/stretchr/testify v1.5.1 // indirect
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
github.com/tebeka/strftime v0.1.5 // indirect
github.com/thinkgos/gomodbus/v2 v2.2.1
github.com/thinkgos/mb v0.0.1
github.com/thinkgos/timing/v4 v4.1.1 // indirect
github.com/thinkgos/gomodbus/v2 v2.2.2
github.com/yuin/gluamapper v0.0.0-20150323120927-d836955830e7
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f // indirect
gopkg.in/ini.v1 v1.57.0
layeh.com/gopher-luar v1.0.8

17
go.sum
View File

@ -81,7 +81,6 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
@ -89,15 +88,8 @@ github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 h1:UyzmZLoiDWMRywV4DUY
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tebeka/strftime v0.1.5 h1:1NQKN1NiQgkqd/2moD6ySP/5CoZQsKa1d3ZhJ44Jpmg=
github.com/tebeka/strftime v0.1.5/go.mod h1:29/OidkoWHdEKZqzyDLUyC+LmgDgdHo4WAFCDT7D/Ig=
github.com/thinkgos/gomodbus/v2 v2.2.0/go.mod h1:YynqZtDx2kFRhA+Ajy9qtmWOUIs5BOi3EaX6WQwH/jo=
github.com/thinkgos/gomodbus/v2 v2.2.1 h1:eFTeFvkN8z7DuKUnExPzJs3eNE+O0kgoRRDD7cnzmSA=
github.com/thinkgos/gomodbus/v2 v2.2.1/go.mod h1:YynqZtDx2kFRhA+Ajy9qtmWOUIs5BOi3EaX6WQwH/jo=
github.com/thinkgos/mb v0.0.1 h1:cXhxZRBJ2K64Ac9CAwjX6K9qx4vwgxmWFSszSXboQ38=
github.com/thinkgos/mb v0.0.1/go.mod h1:Aew9EaLHFevy9zPT4VKpv/mf5SUf6475fuDVB8DFJhY=
github.com/thinkgos/timing/v4 v4.1.0 h1:A91sdbxRa2VGgqEnbi7BW3Atqnk9iG3b9AAzTyjEOJE=
github.com/thinkgos/timing/v4 v4.1.0/go.mod h1:UJHH/waV/JvqmHbK8phLp9w2EUgRVN6oDAlr8k+WAZY=
github.com/thinkgos/timing/v4 v4.1.1 h1:/Fte/3ChyO21ucWsrjTT/iaHz6h9elzOiw7zp/4Hh18=
github.com/thinkgos/timing/v4 v4.1.1/go.mod h1:UJHH/waV/JvqmHbK8phLp9w2EUgRVN6oDAlr8k+WAZY=
github.com/thinkgos/gomodbus/v2 v2.2.2 h1:2ZkVxPShxg9ew0UCANdRxL7ZGA6anwRo66e8zifo+6w=
github.com/thinkgos/gomodbus/v2 v2.2.2/go.mod h1:YynqZtDx2kFRhA+Ajy9qtmWOUIs5BOi3EaX6WQwH/jo=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
@ -108,21 +100,16 @@ github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583/go.mod h1:gqRgreBU
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da h1:NimzV1aGyq29m5ukMK0AMWEhFaL/lrEOaephfuoiARg=
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f h1:gWF768j/LaZugp8dyS4UwsslYCYz9XgFxvlgsn0n9H8=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

View File

@ -4,14 +4,14 @@ import (
"encoding/binary"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/goburrow/serial"
modbus "github.com/thinkgos/gomodbus/v2"
"github.com/thinkgos/mb"
"net/http"
"strconv"
"strings"
"time"
"github.com/gin-gonic/gin"
"github.com/goburrow/serial"
modbus "github.com/thinkgos/gomodbus/v2"
)
type MbParam struct {
@ -21,7 +21,7 @@ type MbParam struct {
Data string `json:"Data"`
}
var client *mb.Client
var client modbus.Client
var mbParam MbParam
func NewMbParam(addr byte, regAddr, regCnt uint16) *MbParam {
@ -45,9 +45,9 @@ func mbParamOpenPort(port string) bool {
Timeout: 100 * time.Millisecond,
}))
client = mb.New(p)
client = modbus.NewClient(p)
client.LogMode(true)
err := client.Start()
err := client.Connect()
if err != nil {
fmt.Println("start err,", err)
return status