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 2021/03/30 10:01:51 UTC

[plc4x] branch develop updated: plc4go: use datatype length as read length

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 a80fbcb  plc4go: use datatype length as read length
a80fbcb is described below

commit a80fbcb14d35cc114a20ba143ae9f18dbb9c2681
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Mar 30 12:01:31 2021 +0200

    plc4go: use datatype length as read length
---
 plc4go/internal/plc4go/ads/Reader.go | 6 ++----
 plc4go/internal/plc4go/ads/Writer.go | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/plc4go/internal/plc4go/ads/Reader.go b/plc4go/internal/plc4go/ads/Reader.go
index e49f492..de73688 100644
--- a/plc4go/internal/plc4go/ads/Reader.go
+++ b/plc4go/internal/plc4go/ads/Reader.go
@@ -91,11 +91,9 @@ func (m *Reader) Read(readRequest model.PlcReadRequest) <-chan model.PlcReadRequ
 		}
 		switch adsField.FieldType {
 		case DirectAdsStringField:
-			// TODO: what is our read length?
-			userdata.Data = readWriteModel.NewAdsReadRequest(adsField.IndexGroup, adsField.IndexOffset, 1)
+			userdata.Data = readWriteModel.NewAdsReadRequest(adsField.IndexGroup, adsField.IndexOffset, uint32(adsField.Datatype.LengthInBytes()))
 		case DirectAdsField:
-			// TODO: what is our read length?
-			userdata.Data = readWriteModel.NewAdsReadRequest(adsField.IndexGroup, adsField.IndexOffset, 1)
+			userdata.Data = readWriteModel.NewAdsReadRequest(adsField.IndexGroup, adsField.IndexOffset, uint32(adsField.Datatype.LengthInBytes()))
 		case SymbolicStringField:
 			panic("implement me")
 		case SymbolicField:
diff --git a/plc4go/internal/plc4go/ads/Writer.go b/plc4go/internal/plc4go/ads/Writer.go
index a5fd175..253d91c 100644
--- a/plc4go/internal/plc4go/ads/Writer.go
+++ b/plc4go/internal/plc4go/ads/Writer.go
@@ -103,7 +103,6 @@ func (m Writer) Write(writeRequest model.PlcWriteRequest) <-chan model.PlcWriteR
 		}
 		switch adsField.FieldType {
 		case DirectAdsStringField:
-			// TODO: what is our read length?
 			userdata.Data = readWriteModel.NewAdsWriteRequest(adsField.IndexGroup, adsField.IndexOffset, data)
 			panic("implement me")
 		case DirectAdsField: