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/08/31 12:37:21 UTC

[plc4x] branch develop updated: feat(plc4go/cbus): added timeout to the read request on browse

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 a0b7d0b02 feat(plc4go/cbus): added timeout to the read request on browse
a0b7d0b02 is described below

commit a0b7d0b02806d1954a6f5b77adf3b7c52cdea477
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Aug 31 14:35:19 2022 +0200

    feat(plc4go/cbus): added timeout to the read request on browse
---
 plc4go/internal/cbus/Browser.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/plc4go/internal/cbus/Browser.go b/plc4go/internal/cbus/Browser.go
index a52b96163..c72d9fa2b 100644
--- a/plc4go/internal/cbus/Browser.go
+++ b/plc4go/internal/cbus/Browser.go
@@ -29,6 +29,7 @@ import (
 	_default "github.com/apache/plc4x/plc4go/spi/default"
 	"github.com/apache/plc4x/plc4go/spi/model"
 	"github.com/rs/zerolog/log"
+	"time"
 )
 
 type Browser struct {
@@ -105,7 +106,9 @@ func (m Browser) BrowseField(ctx context.Context, browseRequest apiModel.PlcBrow
 				readRequest, _ := m.connection.ReadRequestBuilder().
 					AddField(readFieldName, NewCALIdentifyField(unit, attribute, 1)).
 					Build()
-				requestResult := <-readRequest.Execute()
+				timeoutCtx, timeoutCancel := context.WithTimeout(ctx, time.Second*2)
+				requestResult := <-readRequest.ExecuteWithContext(timeoutCtx)
+				timeoutCancel()
 				if err := requestResult.GetErr(); err != nil {
 					if !allUnits && !allAttributes {
 						event.Err(err).Msgf("unit %d: Can't read attribute %s", unitAddress, attribute)