Repository: edgexfoundry/device-modbus-go
Pull request #422 (2023-03-13 03:53:54)

refactor!: consume device-sdk-go breaking changes
BREAKING CHANGE:
- update ProtocolDriver implementation for the new interface changes
- update 'Port', 'UnitID', 'Timeout', 'IdleTimeout' of modbus-tcp properties
from string to integer
- update 'UnitID', 'BaudRate', 'DataBits', 'StopBits', 'Timeout',
'IdleTimeout' of modbus-rtu properties from string to integer

<!-- Expected Commit Message Description (imported automatically by GitHub) -->
<!-- Must conform to [conventional commits guidelines](https://github.com/edgexfoundry/device-modbus-go/blob/main/.github/Contributing.md) -->
<!-- Expected Commit message must contain Closes/Fixes #IssueNumber statement when there is a related issue -->

<!-- Add additional detailed description of need for change if no related issue -->

**If your build fails** due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/device-modbus-go/blob/main/.github/Contributing.md

## PR Checklist
Please check if your PR fulfills the following requirements:

- [ ] I am not introducing a breaking change (if you are, flag in conventional commit message with `BREAKING CHANGE:` describing the break)
- [x] I am not introducing a new dependency (add notes below if you are)
- [ ] I have added unit tests for the new feature or bug fix (if not, why?)
- [ ] I have fully tested (add details below) this the new feature or bug fix (if not, why?)
- [ ] I have opened a PR for the related docs change (if not, why?)
  <link to docs PR>

## Testing Instructions
<!-- How can the reviewers test your change? -->

## New Dependency Instructions (If applicable)
<!-- Please follow [vetting instructions](https://wiki.edgexfoundry.org/display/FA/Vetting+Process+for+3rd+Party+Dependencies) and place results here -->

codecov-commenter: ## [Codecov](https://codecov.io/gh/edgexfoundry/device-modbus-go/pull/422?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=edgexfoundry) Report
> Merging [#422](https://codecov.io/gh/edgexfoundry/device-modbus-go/pull/422?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=edgexfoundry) (514b1fc) into [main](https://codecov.io/gh/edgexfoundry/device-modbus-go/commit/01efde03cde14ec0060c1876119bb983deb5481b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=edgexfoundry) (01efde0) will **decrease** coverage by `0.16%`.
> The diff coverage is `58.62%`.

:mega: This organization is not using Codecov’s [GitHub App Integration](https://github.com/apps/codecov). We recommend you install it so Codecov can continue to function properly for your repositories. [Learn more](https://about.codecov.io/blog/codecov-is-updating-its-github-integration/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=edgexfoundry)

```diff
@@            Coverage Diff             @@
##             main     #422      +/-   ##
==========================================
- Coverage   42.67%   42.52%   -0.16%     
==========================================
  Files           6        6              
  Lines         546      555       +9     
==========================================
+ Hits          233      236       +3     
- Misses        273      276       +3     
- Partials       40       43       +3     
```


| [Impacted Files](https://codecov.io/gh/edgexfoundry/device-modbus-go/pull/422?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=edgexfoundry) | Coverage Δ | |
|---|---|---|
| [internal/driver/driver.go](https://codecov.io/gh/edgexfoundry/device-modbus-go/pull/422?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=edgexfoundry#diff-aW50ZXJuYWwvZHJpdmVyL2RyaXZlci5nbw==) | `10.59% <0.00%> (ø)` | |
| [internal/driver/config.go](https://codecov.io/gh/edgexfoundry/device-modbus-go/pull/422?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=edgexfoundry#diff-aW50ZXJuYWwvZHJpdmVyL2NvbmZpZy5nbw==) | `62.26% <68.00%> (-2.69%)` | :arrow_down: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=edgexfoundry). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=edgexfoundry)


Patch:
diff --git a/go.mod b/go.mod
index e358ec5..2cfffe1 100644
--- a/go.mod
+++ b/go.mod
@@ -3,8 +3,8 @@ module github.com/edgexfoundry/device-modbus-go
 go 1.18
 
 require (
-	github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.43
-	github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.24
+	github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.50
+	github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.26
 	github.com/goburrow/modbus v0.1.0
 	github.com/spf13/cast v1.5.0
 	github.com/stretchr/testify v1.8.2
@@ -17,9 +17,9 @@ require (
 	github.com/cenkalti/backoff v2.2.1+incompatible // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
 	github.com/eclipse/paho.mqtt.golang v1.4.2 // indirect
-	github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.36 // indirect
-	github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.6 // indirect
-	github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.13 // indirect
+	github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.44 // indirect
+	github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7 // indirect
+	github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.16 // indirect
 	github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.5 // indirect
 	github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.8 // indirect
 	github.com/fatih/color v1.9.0 // indirect
@@ -61,7 +61,7 @@ require (
 	github.com/spiffe/go-spiffe/v2 v2.1.2 // indirect
 	github.com/x448/float16 v0.8.4 // indirect
 	github.com/zeebo/errs v1.3.0 // indirect
-	golang.org/x/crypto v0.5.0 // indirect
+	golang.org/x/crypto v0.6.0 // indirect
 	golang.org/x/mod v0.7.0 // indirect
 	golang.org/x/net v0.7.0 // indirect
 	golang.org/x/sync v0.1.0 // indirect
diff --git a/go.sum b/go.sum
index 5fce343..e47ca12 100644
--- a/go.sum
+++ b/go.sum
@@ -27,16 +27,16 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/eclipse/paho.mqtt.golang v1.4.2 h1:66wOzfUHSSI1zamx7jR6yMEI5EuHnT1G6rNA5PM12m4=
 github.com/eclipse/paho.mqtt.golang v1.4.2/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA=
-github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.43 h1:eB9pJcZ9NyzMPZPKCU/Jl5kjpwRQETuH1jIKW3HXP/c=
-github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.43/go.mod h1:h3xqzuXIERX0Q2Pyc6F8DbZGblFiw0SM1I7GM4XIwmk=
-github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.36 h1:mGHVEYWhPuKPoV6qnOW5dW4+neBSkUsvGpRZKOw66e4=
-github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.36/go.mod h1:cUnEMDq/b54W6pTx5F3LMCQ5IlunDLl0LX781MQGGIQ=
-github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.6 h1:x/QErFpfer2vbOGrQx46FWxPw4Ye51f72YOAnEKW5Fk=
-github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.6/go.mod h1:ZZbOu7K0/P8B1VKhZygVujLQyhvWuPe0E2vC/k2yscw=
-github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.24 h1:EdQ36s2hBwieNf2nEwpchfZnxEu4VQKyl3H7IVl/ZRE=
-github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.24/go.mod h1:QBzXOAoyLzBm5k9CshgH9CR9nWMNXxZjknBFMnGJN/A=
-github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.13 h1:90ySsYvuXMbuemAuLYsqOLQSmPJtg3ai0BPFPvLbuOs=
-github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.13/go.mod h1:H5N80pdJZ/uKJ19C3kui1AEmli3hdTkIa2s19EsYOPQ=
+github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.50 h1:v2vtVunOCcRJ9d6AI9zakHawNbdMLU2a4EHv+chfcs0=
+github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.50/go.mod h1:zhdvWnfPu2cqVasAV1BClT9puUwS3D0JmJ6OFg7WPRQ=
+github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.44 h1:bzROMV3XZzFB5uBFTeQRuqBQyHE8DJjHSl3UWoqacds=
+github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.44/go.mod h1:qiG4HABtB+mnFBOby/ZUpIWcQD0TZa8jIG7p/jeVuzc=
+github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7 h1:pOH2GLDg1KB4EmAzo6IEvl4NEVFAw3ywxPUMa5Wi1Vw=
+github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7/go.mod h1:ZZbOu7K0/P8B1VKhZygVujLQyhvWuPe0E2vC/k2yscw=
+github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.26 h1:vTTaaM3NErQRoNQKkbQ9f9x/FMJqzZX6OAQuXvU6HN8=
+github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.26/go.mod h1:QBzXOAoyLzBm5k9CshgH9CR9nWMNXxZjknBFMnGJN/A=
+github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.16 h1:JdZiqZ6CAboZ3+GuWZLyXc42y8HfsH1CmsIKNPY+0PY=
+github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.16/go.mod h1:3q+Ys51HwpR9/kOv6sT7+EwAANgOfFWi509sEP5iPEo=
 github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.5 h1:FUUfsQUKHJqSwOXEj0j/qAn+uoWzM8nV7IOapGf7D80=
 github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.5/go.mod h1:MroNeX/i6ymRu8cyuRB4U5zdBusyUpFhUphko6pInTQ=
 github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.8 h1:rvoSu4fWQNAundG1eRKKCjZkzSBJQoYqCtEfzzV91CY=
@@ -133,7 +133,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
 github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
-github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw=
+github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -178,7 +178,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
 github.com/nats-io/jwt/v2 v2.3.0 h1:z2mA1a7tIf5ShggOFlR1oBPgd6hGqcDYsISxZByUzdI=
-github.com/nats-io/nats-server/v2 v2.9.14 h1:n2GscWVgXpA14vQSRP/MM1SGi4wyazR9l19/gWxqgXQ=
+github.com/nats-io/nats-server/v2 v2.9.15 h1:MuwEJheIwpvFgqvbs20W8Ish2azcygjf4Z0liVu2I4c=
 github.com/nats-io/nats.go v1.24.0 h1:CRiD8L5GOQu/DcfkmgBcTTIQORMwizF+rPk6T0RaHVQ=
 github.com/nats-io/nats.go v1.24.0/go.mod h1:dVQF+BK3SzUZpwyzHedXsvH3EO38aVKuOPkkHlv5hXA=
 github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8=
@@ -247,8 +247,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
 golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
-golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
-golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
+golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
+golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
 golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
 golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
diff --git a/internal/driver/config.go b/internal/driver/config.go
index bb68ecc..bdced1e 100644
--- a/internal/driver/config.go
+++ b/internal/driver/config.go
@@ -1,6 +1,6 @@
 // -*- Mode: Go; indent-tabs-mode: t -*-
 //
-// Copyright (C) 2019-2021 IOTech Ltd
+// Copyright (C) 2019-2023 IOTech Ltd
 //
 // SPDX-License-Identifier: Apache-2.0
 
@@ -54,30 +54,36 @@ func createConnectionInfo(protocols map[string]models.ProtocolProperties) (info
 	return info, nil
 }
 
-func parseIntValue(properties map[string]string, key string) (int, error) {
-	str, ok := properties[key]
+func parseIntValue(properties map[string]any, key string) (int, error) {
+	value, ok := properties[key]
 	if !ok {
 		return 0, fmt.Errorf("protocol config '%s' not exist", key)
 	}
-	val, err := strconv.Atoi(str)
-	if err != nil {
-		return 0, fmt.Errorf("fail to parse protocol config '%s', %v", key, err)
+
+	res, ok := value.(int)
+	if !ok {
+		return 0, fmt.Errorf("cannot transfrom protocol config %s value %v to int", key, value)
 	}
-	return val, nil
+
+	return res, nil
 }
 
-func createRTUConnectionInfo(rtuProtocol map[string]string) (info *ConnectionInfo, err error) {
+func createRTUConnectionInfo(rtuProtocol map[string]any) (info *ConnectionInfo, err error) {
 	errorMessage := "unable to create RTU connection info, protocol config '%s' not exist"
-	address, ok := rtuProtocol[Address]
+	value, ok := rtuProtocol[Address]
 	if !ok {
 		return nil, fmt.Errorf(errorMessage, Address)
 	}
+	address, ok := value.(string)
+	if !ok {
+		return nil, fmt.Errorf("cannot transform '%s' value %v to string", Address, value)
+	}
 
 	us, ok := rtuProtocol[UnitID]
 	if !ok {
 		return nil, fmt.Errorf(errorMessage, UnitID)
 	}
-	unitID, err := strconv.ParseUint(us, 0, 8)
+	unitID, err := strconv.ParseUint(fmt.Sprintf("%v", us), 0, 8)
 	if err != nil {
 		return nil, fmt.Errorf("uintID value out of range(0–255). Error: %v", err)
 	}
@@ -97,10 +103,14 @@ func createRTUConnectionInfo(rtuProtocol map[string]string) (info *ConnectionInf
 		return nil, err
 	}
 
-	parity, ok := rtuProtocol[Parity]
+	value, ok = rtuProtocol[Parity]
 	if !ok {
 		return nil, fmt.Errorf(errorMessage, Parity)
 	}
+	parity, ok := value.(string)
+	if !ok {
+		return nil, fmt.Errorf("cannot transform '%s' value %v to string", Parity, parity)
+	}
 	if parity != "N" && parity != "O" && parity != "E" {
 		return nil, fmt.Errorf("invalid parity value, it should be N(None) or O(Odd) or E(Even)")
 	}
@@ -128,27 +138,31 @@ func createRTUConnectionInfo(rtuProtocol map[string]string) (info *ConnectionInf
 	}, nil
 }
 
-func createTcpConnectionInfo(tcpProtocol map[string]string) (info *ConnectionInfo, err error) {
+func createTcpConnectionInfo(tcpProtocol map[string]any) (info *ConnectionInfo, err error) {
 	errorMessage := "unable to create TCP connection info, protocol config '%s' not exist"
-	address, ok := tcpProtocol[Address]
+	value, ok := tcpProtocol[Address]
 	if !ok {
 		return nil, fmt.Errorf(errorMessage, Address)
 	}
+	address, ok := value.(string)
+	if !ok {
+		return nil, fmt.Errorf("cannot transform '%s' value %v to string", Address, value)
+	}
 
-	portString, ok := tcpProtocol[Port]
+	value, ok = tcpProtocol[Port]
 	if !ok {
 		return nil, fmt.Errorf(errorMessage, Port)
 	}
-	port, err := strconv.ParseUint(portString, 0, 16)
+	port, err := strconv.ParseUint(fmt.Sprintf("%v", value), 0, 16)
 	if err != nil {
 		return nil, fmt.Errorf("port value out of range(0–65535). Error: %v", err)
 	}
 
-	unitIDString, ok := tcpProtocol[UnitID]
+	value, ok = tcpProtocol[UnitID]
 	if !ok {
 		return nil, fmt.Errorf(errorMessage, UnitID)
 	}
-	unitID, err := strconv.ParseUint(unitIDString, 0, 8)
+	unitID, err := strconv.ParseUint(fmt.Sprintf("%v", value), 0, 8)
 	if err != nil {
 		return nil, fmt.Errorf("uintID value out of range(0–255). Error: %v", err)
 	}
diff --git a/internal/driver/driver.go b/internal/driver/driver.go
index 9fc79f0..49de6cc 100644
--- a/internal/driver/driver.go
+++ b/internal/driver/driver.go
@@ -1,6 +1,6 @@
 // -*- Mode: Go; indent-tabs-mode: t -*-
 //
-// Copyright (C) 2018-2021 IOTech Ltd
+// Copyright (C) 2018-2023 IOTech Ltd
 //
 // SPDX-License-Identifier: Apache-2.0
 
@@ -12,6 +12,7 @@ import (
 	"sync"
 	"time"
 
+	"github.com/edgexfoundry/device-sdk-go/v3/pkg/interfaces"
 	sdkModel "github.com/edgexfoundry/device-sdk-go/v3/pkg/models"
 	"github.com/edgexfoundry/go-mod-core-contracts/v3/clients/logger"
 	"github.com/edgexfoundry/go-mod-core-contracts/v3/models"
@@ -220,9 +221,9 @@ func handleWriteCommandRequest(deviceClient DeviceClient, req sdkModel.CommandRe
 	return nil
 }
 
-func (d *Driver) Initialize(lc logger.LoggingClient, asyncCh chan<- *sdkModel.AsyncValues, deviceCh chan<- []sdkModel.DiscoveredDevice) error {
-	d.Logger = lc
-	d.AsyncCh = asyncCh
+func (d *Driver) Initialize(sdk interfaces.DeviceServiceSDK) error {
+	d.Logger = sdk.LoggingClient()
+	d.AsyncCh = sdk.AsyncValuesChannel()
 	d.addressMap = make(map[string]chan bool)
 	d.workingAddressCount = make(map[string]int)
 	return nil
@@ -269,7 +270,7 @@ func (d *Driver) RemoveDevice(deviceName string, protocols map[string]models.Pro
 	return nil
 }
 
-func NewProtocolDriver() sdkModel.ProtocolDriver {
+func NewProtocolDriver() interfaces.ProtocolDriver {
 	once.Do(func() {
 		driver = new(Driver)
 	})


Test patch:
diff --git a/cmd/res/devices/modbus.test.devices.toml b/cmd/res/devices/modbus.test.devices.toml
index 0c5f2c1..e3cec7a 100644
--- a/cmd/res/devices/modbus.test.devices.toml
+++ b/cmd/res/devices/modbus.test.devices.toml
@@ -7,10 +7,10 @@
   [DeviceList.Protocols]
     [DeviceList.Protocols.modbus-tcp]
        Address = "0.0.0.0"
-       Port = "1502"
-       UnitID = "1"
-       Timeout = "5"
-       IdleTimeout = "5"
+       Port = 1502
+       UnitID = 1
+       Timeout = 5
+       IdleTimeout = 5
   [[DeviceList.AutoEvents]]
     Interval = "20s"
     OnChange = false
@@ -24,13 +24,13 @@
   [DeviceList.Protocols]
     [DeviceList.Protocols.modbus-rtu]
        Address = "/tmp/slave"
-       BaudRate = "19200"
-       DataBits = "8"
-       StopBits = "1"
+       UnitID = 1
+       BaudRate = 19200
+       DataBits = 8
+       StopBits = 1
        Parity = "N"
-       UnitID = "1"
-       Timeout = "5"
-       IdleTimeout = "5"
+       Timeout = 5
+       IdleTimeout = 5
 
 # Pre-define Devices
 [[DeviceList]]
@@ -41,10 +41,10 @@
   [DeviceList.Protocols]
     [DeviceList.Protocols.modbus-tcp]
       Address = "0.0.0.0"
-      Port = "1502"
-      UnitID = "1"
-      Timeout = "5"
-      IdleTimeout = "5"
+      Port = 1502
+      UnitID = 1
+      Timeout = 5
+      IdleTimeout = 5
   [[DeviceList.AutoEvents]]
     Interval = "20s"
     OnChange = false
diff --git a/internal/driver/config_test.go b/internal/driver/config_test.go
index 1e26549..9121aa1 100644
--- a/internal/driver/config_test.go
+++ b/internal/driver/config_test.go
@@ -1,6 +1,6 @@
 // -*- Mode: Go; indent-tabs-mode: t -*-
 //
-// Copyright (C) 2019-2021 IOTech Ltd
+// Copyright (C) 2019-2023 IOTech Ltd
 //
 // SPDX-License-Identifier: Apache-2.0
 
@@ -23,13 +23,13 @@ func TestCreateRTUConnectionInfo_unitID255(t *testing.T) {
 	protocols := map[string]models.ProtocolProperties{
 		ProtocolRTU: {
 			Address:     address,
-			UnitID:      "255",
-			BaudRate:    "19200",
-			DataBits:    "8",
-			StopBits:    "1",
+			UnitID:      255,
+			BaudRate:    19200,
+			DataBits:    8,
+			StopBits:    1,
 			Parity:      "N",
-			Timeout:     "5",
-			IdleTimeout: "5",
+			Timeout:     5,
+			IdleTimeout: 5,
 		},
 	}
 
@@ -55,13 +55,13 @@ func TestCreateConnectionInfo_unitID0(t *testing.T) {
 	protocols := map[string]models.ProtocolProperties{
 		ProtocolRTU: {
 			Address:     address,
-			UnitID:      "0",
-			BaudRate:    "19200",
-			DataBits:    "8",
-			StopBits:    "1",
+			UnitID:      0,
+			BaudRate:    19200,
+			DataBits:    8,
+			StopBits:    1,
 			Parity:      "N",
-			Timeout:     "5",
-			IdleTimeout: "5",
+			Timeout:     5,
+			IdleTimeout: 5,
 		},
 	}
 
@@ -79,17 +79,17 @@ func TestCreateConnectionInfo_unitID0(t *testing.T) {
 
 func TestCreateConnectionInfo_unitIdOutOfRange(t *testing.T) {
 	address := "/dev/USB0tty"
-	unitID := "256"
+	unitID := 256
 	protocols := map[string]models.ProtocolProperties{
 		ProtocolRTU: {
 			Address:     address,
 			UnitID:      unitID,
-			BaudRate:    "19200",
-			DataBits:    "8",
-			StopBits:    "1",
+			BaudRate:    19200,
+			DataBits:    8,
+			StopBits:    1,
 			Parity:      "N",
-			Timeout:     "5",
-			IdleTimeout: "5",
+			Timeout:     5,
+			IdleTimeout: 5,
 		},
 	}
 
@@ -106,13 +106,13 @@ func TestCreateConnectionInfo_invalidParity(t *testing.T) {
 	protocols := map[string]models.ProtocolProperties{
 		ProtocolRTU: {
 			Address:     address,
-			UnitID:      "1",
-			BaudRate:    "19200",
-			DataBits:    "8",
-			StopBits:    "1",
+			UnitID:      1,
+			BaudRate:    19200,
+			DataBits:    8,
+			StopBits:    1,
 			Parity:      parity,
-			Timeout:     "5",
-			IdleTimeout: "5",
+			Timeout:     5,
+			IdleTimeout: 5,
 		},
 	}
 
@@ -130,10 +130,10 @@ func TestCreateTCPConnectionInfo(t *testing.T) {
 	protocols := map[string]models.ProtocolProperties{
 		ProtocolTCP: {
 			Address:     address,
-			Port:        "502",
-			UnitID:      "255",
-			Timeout:     "5",
-			IdleTimeout: "5",
+			Port:        502,
+			UnitID:      255,
+			Timeout:     5,
+			IdleTimeout: 5,
 		},
 	}
 
@@ -150,14 +150,14 @@ func TestCreateTCPConnectionInfo(t *testing.T) {
 
 func TestCreateTCPConnectionInfo_unitIdOutOfRange(t *testing.T) {
 	address := "0.0.0.0"
-	unitID := "256"
+	unitID := 256
 	protocols := map[string]models.ProtocolProperties{
 		ProtocolTCP: {
 			Address:     address,
-			Port:        "502",
+			Port:        502,
 			UnitID:      unitID,
-			Timeout:     "5",
-			IdleTimeout: "5",
+			Timeout:     5,
+			IdleTimeout: 5,
 		},
 	}
 
@@ -170,14 +170,14 @@ func TestCreateTCPConnectionInfo_unitIdOutOfRange(t *testing.T) {
 
 func TestCreateTCPConnectionInfo_portOutOfRange(t *testing.T) {
 	address := "0.0.0.0"
-	port := "65536"
+	port := 65536
 	protocols := map[string]models.ProtocolProperties{
 		ProtocolTCP: {
 			Address:     address,
 			Port:        port,
-			UnitID:      "1",
-			Timeout:     "5",
-			IdleTimeout: "5",
+			UnitID:      1,
+			Timeout:     5,
+			IdleTimeout: 5,
 		},
 	}