You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/05/12 09:33:29 UTC

[plc4x] branch develop updated: fix(plc4go): fix the error of value out of range when converting an in-range number string to IEC61131 unsigned integer or WORD-related type. (#363)

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 773aba60bb fix(plc4go): fix the error of value out of range when converting an in-range number string to IEC61131 unsigned integer or WORD-related type. (#363)
773aba60bb is described below

commit 773aba60bbc9a5a53400fce06cdf61ec38cd1158
Author: hongjinlin <89...@qq.com>
AuthorDate: Thu May 12 17:33:24 2022 +0800

    fix(plc4go): fix the error of value out of range when converting an in-range number string to IEC61131 unsigned integer or WORD-related type. (#363)
---
 .../internal/plc4go/spi/values/IEC61131ValueHandler.go   | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/plc4go/internal/plc4go/spi/values/IEC61131ValueHandler.go b/plc4go/internal/plc4go/spi/values/IEC61131ValueHandler.go
index 5989e1a6c4..1ba163ac97 100644
--- a/plc4go/internal/plc4go/spi/values/IEC61131ValueHandler.go
+++ b/plc4go/internal/plc4go/spi/values/IEC61131ValueHandler.go
@@ -142,7 +142,7 @@ func (m IEC61131ValueHandler) newPlcValue(typeName string, quantity uint16, valu
 		}
 	case IEC61131_BYTE:
 		if isString {
-			casted, err := strconv.ParseInt(stringValue, 10, 8)
+			casted, err := strconv.ParseUint(stringValue, 10, 8)
 			if err != nil {
 				return nil, errors.New("couldn't parse string value '" + stringValue + "' to byte")
 			}
@@ -156,7 +156,7 @@ func (m IEC61131ValueHandler) newPlcValue(typeName string, quantity uint16, valu
 		}
 	case IEC61131_WORD:
 		if isString {
-			casted, err := strconv.ParseInt(stringValue, 10, 16)
+			casted, err := strconv.ParseUint(stringValue, 10, 16)
 			if err != nil {
 				return nil, errors.New("couldn't parse string value '" + stringValue + "' to word")
 			}
@@ -170,7 +170,7 @@ func (m IEC61131ValueHandler) newPlcValue(typeName string, quantity uint16, valu
 		}
 	case IEC61131_DWORD:
 		if isString {
-			casted, err := strconv.ParseInt(stringValue, 10, 32)
+			casted, err := strconv.ParseUint(stringValue, 10, 32)
 			if err != nil {
 				return nil, errors.New("couldn't parse string value '" + stringValue + "' to dword")
 			}
@@ -184,7 +184,7 @@ func (m IEC61131ValueHandler) newPlcValue(typeName string, quantity uint16, valu
 		}
 	case IEC61131_LWORD:
 		if isString {
-			casted, err := strconv.ParseInt(stringValue, 10, 64)
+			casted, err := strconv.ParseUint(stringValue, 10, 64)
 			if err != nil {
 				return nil, errors.New("couldn't parse string value '" + stringValue + "' to lword")
 			}
@@ -200,7 +200,7 @@ func (m IEC61131ValueHandler) newPlcValue(typeName string, quantity uint16, valu
 	// Integers
 	case IEC61131_USINT:
 		if isString {
-			casted, err := strconv.ParseInt(stringValue, 10, 8)
+			casted, err := strconv.ParseUint(stringValue, 10, 8)
 			if err != nil {
 				return nil, errors.New("couldn't parse string value '" + stringValue + "' to usint")
 			}
@@ -214,7 +214,7 @@ func (m IEC61131ValueHandler) newPlcValue(typeName string, quantity uint16, valu
 		}
 	case IEC61131_UINT:
 		if isString {
-			casted, err := strconv.ParseInt(stringValue, 10, 16)
+			casted, err := strconv.ParseUint(stringValue, 10, 16)
 			if err != nil {
 				return nil, errors.New("couldn't parse string value '" + stringValue + "' to uint")
 			}
@@ -228,7 +228,7 @@ func (m IEC61131ValueHandler) newPlcValue(typeName string, quantity uint16, valu
 		}
 	case IEC61131_UDINT:
 		if isString {
-			casted, err := strconv.ParseInt(stringValue, 10, 32)
+			casted, err := strconv.ParseUint(stringValue, 10, 32)
 			if err != nil {
 				return nil, errors.New("couldn't parse string value '" + stringValue + "' to udint")
 			}
@@ -242,7 +242,7 @@ func (m IEC61131ValueHandler) newPlcValue(typeName string, quantity uint16, valu
 		}
 	case IEC61131_ULINT:
 		if isString {
-			casted, err := strconv.ParseInt(stringValue, 10, 64)
+			casted, err := strconv.ParseUint(stringValue, 10, 64)
 			if err != nil {
 				return nil, errors.New("couldn't parse string value '" + stringValue + "' to ulint")
 			}