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-extras.git


The following commit(s) were added to refs/heads/develop by this push:
     new 327eb94  feat(plc4go): update upstream version part2
327eb94 is described below

commit 327eb945bdf882bead25b62603790871ef4ac18d
Author: Sebastian Rühl <[email protected]>
AuthorDate: Mon Nov 24 12:50:18 2025 +0100

    feat(plc4go): update upstream version part2
---
 plc4go/examples/ads/browse/Browse.go               | 13 +++++++----
 plc4go/examples/ads/subscribe/Subscribe.go         | 12 ++++++----
 .../hello_world_plc4go_bacnet_discovery.go         | 14 ++++++------
 .../discovery/hello_world_plc4go_knx_discovery.go  | 23 +++++++++----------
 .../hello_world_plc4go_knx_read_group_address.go   | 19 +++++++---------
 .../hello_world_plc4go_knx_subscription.go         | 26 ++++++++++------------
 plc4go/examples/read/hello_world_plc4go_read.go    | 16 ++++++-------
 plc4go/examples/write/hello_world_plc4go_write.go  | 16 ++++++-------
 8 files changed, 70 insertions(+), 69 deletions(-)

diff --git a/plc4go/examples/ads/browse/Browse.go 
b/plc4go/examples/ads/browse/Browse.go
index c7c3bf2..35e3d85 100644
--- a/plc4go/examples/ads/browse/Browse.go
+++ b/plc4go/examples/ads/browse/Browse.go
@@ -20,11 +20,14 @@
 package main
 
 import (
+       "context"
+
        plc4go "github.com/apache/plc4x/plc4go/pkg/api"
        "github.com/apache/plc4x/plc4go/pkg/api/drivers"
 )
 
 func main() {
+       ctx := context.Background()
        driverManager := plc4go.NewPlcDriverManager()
        defer func() {
                if err := driverManager.Close(); err != nil {
@@ -32,13 +35,15 @@ func main() {
                }
        }()
        drivers.RegisterAdsDriver(driverManager)
-       connectionChan := 
driverManager.GetConnection("ads:tcp://192.168.23.20?sourceAmsNetId=192.168.23.200.1.1&sourceAmsPort=65534&targetAmsNetId=192.168.23.20.1.1&targetAmsPort=851")
-       connection := <-connectionChan
-       browseRequest, err := 
connection.GetConnection().BrowseRequestBuilder().AddQuery("all", 
"MAIN.rivianTest01.RotationalPosition").Build()
+       connection, err := driverManager.GetConnection(ctx, 
"ads:tcp://192.168.23.20?sourceAmsNetId=192.168.23.200.1.1&sourceAmsPort=65534&targetAmsNetId=192.168.23.20.1.1&targetAmsPort=851")
+       if err != nil {
+               panic(err)
+       }
+       browseRequest, err := connection.BrowseRequestBuilder().AddQuery("all", 
"MAIN.rivianTest01.RotationalPosition").Build()
        if err != nil {
                panic(err)
        }
-       browseResponseChannel := browseRequest.Execute()
+       browseResponseChannel := browseRequest.Execute(ctx)
        browseResponse := <-browseResponseChannel
        print(browseResponse)
 }
diff --git a/plc4go/examples/ads/subscribe/Subscribe.go 
b/plc4go/examples/ads/subscribe/Subscribe.go
index fd067b7..8061969 100644
--- a/plc4go/examples/ads/subscribe/Subscribe.go
+++ b/plc4go/examples/ads/subscribe/Subscribe.go
@@ -20,6 +20,7 @@
 package main
 
 import (
+       "context"
        "time"
 
        plc4go "github.com/apache/plc4x/plc4go/pkg/api"
@@ -30,6 +31,7 @@ import (
 )
 
 func main() {
+       ctx := context.Background()
        zerolog.SetGlobalLevel(zerolog.InfoLevel)
 
        driverManager := plc4go.NewPlcDriverManager()
@@ -39,10 +41,12 @@ func main() {
                }
        }()
        drivers.RegisterAdsDriver(driverManager)
-       connectionChan := 
driverManager.GetConnection("ads:tcp://192.168.23.20?sourceAmsNetId=192.168.23.200.1.1&sourceAmsPort=65534&targetAmsNetId=192.168.23.20.1.1&targetAmsPort=851")
-       connection := <-connectionChan
+       connection, err := driverManager.GetConnection(ctx, 
"ads:tcp://192.168.23.20?sourceAmsNetId=192.168.23.200.1.1&sourceAmsPort=65534&targetAmsNetId=192.168.23.20.1.1&targetAmsPort=851")
+       if err != nil {
+               panic(err)
+       }
 
-       subscriptionRequest, err := 
connection.GetConnection().SubscriptionRequestBuilder().
+       subscriptionRequest, err := connection.SubscriptionRequestBuilder().
                AddChangeOfStateTagAddress("value-int", 
"MAIN.rivianTest01.HorizontalPosition").
                AddPreRegisteredConsumer("value-int", func(event 
apiModel.PlcSubscriptionEvent) {
                        value := event.GetValue("value-int")
@@ -52,7 +56,7 @@ func main() {
        if err != nil {
                panic(err)
        }
-       subscriptionResponseChannel := subscriptionRequest.Execute()
+       subscriptionResponseChannel := subscriptionRequest.Execute(ctx)
        subscriptionResult := <-subscriptionResponseChannel
        if subscriptionResult.GetErr() != nil {
                log.Error().Err(subscriptionResult.GetErr()).Msg("error in 
response")
diff --git 
a/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go 
b/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go
index 4f360dc..4dd8a7e 100644
--- a/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go
+++ b/plc4go/examples/bacnet/discovery/hello_world_plc4go_bacnet_discovery.go
@@ -20,6 +20,7 @@
 package main
 
 import (
+       "context"
        "fmt"
        "os"
        "time"
@@ -32,6 +33,7 @@ import (
 )
 
 func main() {
+       ctx := context.Background()
        logger := log.With().Str("myCustomLogger", "example").Logger()
 
        driverManager := plc4go.NewPlcDriverManager(
@@ -48,7 +50,7 @@ func main() {
        var connectionStrings []string
        if len(os.Args) < 2 {
                // Try to auto-find bacnet devices via broadcast-message 
discovery
-               if err := driverManager.Discover(func(event 
apiModel.PlcDiscoveryItem) {
+               if err := driverManager.Discover(ctx, func(event 
apiModel.PlcDiscoveryItem) {
                        connStr := event.GetProtocolCode() + "://" + 
event.GetTransportUrl().Host
                        log.Info().Str("connection string", 
connStr).Stringer("event", event.(fmt.Stringer)).Msg("Found Bacnet Gateway")
 
@@ -75,16 +77,14 @@ func main() {
 
        for _, connStr := range connectionStrings {
                log.Info().Str("connection string", connStr).Msg("Connecting")
-               crc := driverManager.GetConnection(connStr)
+               connection, err := driverManager.GetConnection(ctx, connStr)
 
                // Wait for the driver to connect (or not)
-               connectionResult := <-crc
-               if connectionResult.GetErr() != nil {
-                       log.Error().Err(connectionResult.GetErr()).Msg("error 
connecting to PLC")
+               if err != nil {
+                       log.Error().Err(err).Msg("error connecting to PLC")
                        return
                }
                log.Info().Str("connection string", connStr).Msg("Connected")
-               connection := connectionResult.GetConnection()
-               connection.BlockingClose()
+               connection.Close()
        }
 }
diff --git a/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go 
b/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go
index fd72bdb..8880827 100644
--- a/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go
+++ b/plc4go/examples/knx/discovery/hello_world_plc4go_knx_discovery.go
@@ -20,21 +20,20 @@
 package main
 
 import (
+       "context"
        "fmt"
        "os"
        "time"
 
        "github.com/apache/plc4x/plc4go/pkg/api"
        "github.com/apache/plc4x/plc4go/pkg/api/drivers"
-       "github.com/apache/plc4x/plc4go/pkg/api/logging"
        apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
        "github.com/apache/plc4x/plc4go/spi/utils"
        "github.com/rs/zerolog/log"
 )
 
 func main() {
-       // Set logging to INFO
-       logging.InfoLevel()
+       ctx := context.Background()
 
        driverManager := plc4go.NewPlcDriverManager()
        defer func() {
@@ -47,7 +46,7 @@ func main() {
        var connectionStrings []string
        if len(os.Args) < 2 {
                // Try to auto-find KNX gateways via broadcast-message discovery
-               _ = driverManager.Discover(func(event 
apiModel.PlcDiscoveryItem) {
+               _ = driverManager.Discover(ctx, func(event 
apiModel.PlcDiscoveryItem) {
                        connStr := event.GetProtocolCode() + "://" + 
event.GetTransportUrl().Host
                        log.Info().Str("connection string", connStr).Msg("Found 
KNX Gateway")
 
@@ -63,17 +62,15 @@ func main() {
 
        for _, connStr := range connectionStrings {
                log.Info().Str("connection string", connStr).Msg("Connecting")
-               crc := driverManager.GetConnection(connStr)
+               connection, err := driverManager.GetConnection(ctx, connStr)
 
                // Wait for the driver to connect (or not)
-               connectionResult := <-crc
-               if connectionResult.GetErr() != nil {
-                       log.Error().Err(connectionResult.GetErr()).Msg("error 
connecting to PLC")
+               if err != nil {
+                       log.Error().Err(err).Msg("error connecting to PLC")
                        return
                }
                log.Info().Str("connection string", connStr).Msg("Connected")
-               connection := connectionResult.GetConnection()
-               connection.BlockingClose()
+               defer connection.Close() // Bad example, don't defer in loop
 
                // Try to find all KNX devices on the current network
                browseRequest, err := connection.BrowseRequestBuilder().
@@ -85,7 +82,7 @@ func main() {
                        log.Error().Err(err).Msg("error creating browse 
request")
                        return
                }
-               brr := browseRequest.ExecuteWithInterceptor(func(result 
apiModel.PlcBrowseItem) bool {
+               brr := browseRequest.ExecuteWithInterceptor(ctx, func(result 
apiModel.PlcBrowseItem) bool {
                        knxTag := result.GetTag()
                        knxAddress := knxTag.GetAddressString()
                        log.Info().Str("knxAddress", 
knxAddress).Msg("Inspecting detected Device at KNX Address")
@@ -98,7 +95,7 @@ func main() {
                                log.Error().Err(err).Msg("error creating read 
request")
                                return false
                        }
-                       brr := browseRequest.Execute()
+                       brr := browseRequest.Execute(ctx)
                        browseResult := <-brr
                        if browseResult.GetErr() != nil {
                                
log.Error().Err(browseResult.GetErr()).Msg("error executing the browse request 
for com-objects")
@@ -137,7 +134,7 @@ func main() {
                                return false
                        }
 
-                       rrr := readRequest.Execute()
+                       rrr := readRequest.Execute(ctx)
                        readRequestResult := <-rrr
 
                        if readRequestResult.GetErr() != nil {
diff --git 
a/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go
 
b/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go
index 9572ed5..a70d14e 100644
--- 
a/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go
+++ 
b/plc4go/examples/knx/groupAddressRead/hello_world_plc4go_knx_read_group_address.go
@@ -20,17 +20,16 @@
 package main
 
 import (
+       "context"
        "fmt"
 
        "github.com/apache/plc4x/plc4go/pkg/api"
        "github.com/apache/plc4x/plc4go/pkg/api/drivers"
-       "github.com/apache/plc4x/plc4go/pkg/api/logging"
        apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
 )
 
 func main() {
-       // Set logging to INFO
-       logging.InfoLevel()
+       ctx := context.Background()
 
        driverManager := plc4go.NewPlcDriverManager()
        defer func() {
@@ -41,18 +40,16 @@ func main() {
        drivers.RegisterKnxDriver(driverManager)
 
        // Get a connection to a remote PLC
-       crc := driverManager.GetConnection("knxnet-ip:udp://192.168.42.11")
+       connection, err := driverManager.GetConnection(ctx, 
"knxnet-ip:udp://192.168.42.11")
 
        // Wait for the driver to connect (or not)
-       connectionResult := <-crc
-       if connectionResult.GetErr() != nil {
-               fmt.Printf("error connecting to PLC: %s", 
connectionResult.GetErr().Error())
+       if err != nil {
+               fmt.Printf("error connecting to PLC: %s", err.Error())
                return
        }
-       connection := connectionResult.GetConnection()
 
        // Make sure the connection is closed at the end
-       defer connection.BlockingClose()
+       defer connection.Close()
 
        // Prepare a read-request
        readRequest, err := connection.ReadRequestBuilder().
@@ -60,12 +57,12 @@ func main() {
                AddTagAddress("secondFlorTemperatures", 
"3/[2,3,4,6]/10:DPT_Value_Temp").
                Build()
        if err != nil {
-               fmt.Printf("error preparing read-request: %s", 
connectionResult.GetErr().Error())
+               fmt.Printf("error preparing read-request: %s", err.Error())
                return
        }
 
        // Execute a read-request
-       rrc := readRequest.Execute()
+       rrc := readRequest.Execute(ctx)
 
        // Wait for the response to finish
        rrr := <-rrc
diff --git 
a/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go 
b/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go
index 8a0dafe..a0eb4fe 100644
--- a/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go
+++ b/plc4go/examples/knx/subscribe/hello_world_plc4go_knx_subscription.go
@@ -20,21 +20,19 @@
 package main
 
 import (
+       "context"
        "fmt"
        "strings"
        "time"
 
        "github.com/apache/plc4x/plc4go/pkg/api"
        "github.com/apache/plc4x/plc4go/pkg/api/drivers"
-       "github.com/apache/plc4x/plc4go/pkg/api/logging"
        apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
        apiValues "github.com/apache/plc4x/plc4go/pkg/api/values"
 )
 
 func main() {
-       // Set logging to INFO
-       logging.InfoLevel()
-
+       ctx := context.Background()
        driverManager := plc4go.NewPlcDriverManager()
        defer func() {
                if err := driverManager.Close(); err != nil {
@@ -44,21 +42,20 @@ func main() {
        drivers.RegisterKnxDriver(driverManager)
 
        // Get a connection to a remote PLC
-       crc := driverManager.GetConnection("knxnet-ip:udp://192.168.42.11")
+       connection, err := driverManager.GetConnection(ctx, 
"knxnet-ip:udp://192.168.42.11")
 
        // Wait for the driver to connect (or not)
-       connectionResult := <-crc
-       if connectionResult.GetErr() != nil {
-               fmt.Printf("error connecting to PLC: %s", 
connectionResult.GetErr().Error())
+       if err != nil {
+               fmt.Printf("error connecting to PLC: %s", err.Error())
                return
        }
-       connection := connectionResult.GetConnection()
 
        // Make sure the connection is closed at the end
-       defer connection.BlockingClose()
+       defer connection.Close()
 
        // Prepare a subscription-request
-       if subscriptionRequest, err := connection.SubscriptionRequestBuilder().
+       if subscriptionRequest, err := connection.
+               SubscriptionRequestBuilder().
                // Intentionally catching all without datatype and the 
temperature apiValues of the first floor with type
                AddChangeOfStateTagAddress("all", "*/*/*").
                AddChangeOfStateTagAddress("firstFlorTemperatures", 
"2/[1,2,4,6]/10:DPT_Value_Temp").
@@ -96,9 +93,10 @@ func main() {
                                        }
                                }
                        }
-               }).Build(); err == nil {
+               }).
+               Build(); err == nil {
                // Execute a subscription-request
-               rrc := subscriptionRequest.Execute()
+               rrc := subscriptionRequest.Execute(ctx)
 
                // Wait for the response to finish
                rrr := <-rrc
@@ -117,7 +115,7 @@ func main() {
 
                time.Sleep(time.Minute * 5)
        } else {
-               fmt.Printf("error preparing subscription-request: %s", 
connectionResult.GetErr().Error())
+               fmt.Printf("error preparing subscription-request: %s", 
err.Error())
                return
        }
 }
diff --git a/plc4go/examples/read/hello_world_plc4go_read.go 
b/plc4go/examples/read/hello_world_plc4go_read.go
index dfe89e4..a41cdbc 100644
--- a/plc4go/examples/read/hello_world_plc4go_read.go
+++ b/plc4go/examples/read/hello_world_plc4go_read.go
@@ -20,6 +20,7 @@
 package main
 
 import (
+       "context"
        "fmt"
 
        "github.com/apache/plc4x/plc4go/pkg/api"
@@ -28,6 +29,7 @@ import (
 )
 
 func main() {
+       ctx := context.Background()
        driverManager := plc4go.NewPlcDriverManager()
        defer func() {
                if err := driverManager.Close(); err != nil {
@@ -37,30 +39,28 @@ func main() {
        drivers.RegisterModbusTcpDriver(driverManager)
 
        // Get a connection to a remote PLC
-       crc := driverManager.GetConnection("modbus-tcp://192.168.23.30")
+       connection, err := driverManager.GetConnection(ctx, 
"modbus-tcp://192.168.23.30")
 
        // Wait for the driver to connect (or not)
-       connectionResult := <-crc
-       if connectionResult.GetErr() != nil {
-               fmt.Printf("error connecting to PLC: %s", 
connectionResult.GetErr().Error())
+       if err != nil {
+               fmt.Printf("error connecting to PLC: %s", err.Error())
                return
        }
-       connection := connectionResult.GetConnection()
 
        // Make sure the connection is closed at the end
-       defer connection.BlockingClose()
+       defer connection.Close()
 
        // Prepare a read-request
        readRequest, err := connection.ReadRequestBuilder().
                AddTagAddress("tag", "holding-register:26:REAL").
                Build()
        if err != nil {
-               fmt.Printf("error preparing read-request: %s", 
connectionResult.GetErr().Error())
+               fmt.Printf("error preparing read-request: %s", err.Error())
                return
        }
 
        // Execute a read-request
-       rrc := readRequest.Execute()
+       rrc := readRequest.Execute(ctx)
 
        // Wait for the response to finish
        rrr := <-rrc
diff --git a/plc4go/examples/write/hello_world_plc4go_write.go 
b/plc4go/examples/write/hello_world_plc4go_write.go
index 6f5765c..fd1ff06 100644
--- a/plc4go/examples/write/hello_world_plc4go_write.go
+++ b/plc4go/examples/write/hello_world_plc4go_write.go
@@ -20,6 +20,7 @@
 package main
 
 import (
+       "context"
        "fmt"
 
        "github.com/apache/plc4x/plc4go/pkg/api"
@@ -28,6 +29,7 @@ import (
 )
 
 func main() {
+       ctx := context.Background()
        driverManager := plc4go.NewPlcDriverManager()
        defer func() {
                if err := driverManager.Close(); err != nil {
@@ -37,30 +39,28 @@ func main() {
        drivers.RegisterModbusTcpDriver(driverManager)
 
        // Get a connection to a remote PLC
-       crc := driverManager.GetConnection("modbus-tcp://192.168.23.30")
+       connection, err := driverManager.GetConnection(ctx, 
"modbus-tcp://192.168.23.30")
 
        // Wait for the driver to connect (or not)
-       connectionResult := <-crc
-       if connectionResult.GetErr() != nil {
-               fmt.Printf("error connecting to PLC: %s", 
connectionResult.GetErr().Error())
+       if err != nil {
+               fmt.Printf("error connecting to PLC: %s", err.Error())
                return
        }
-       connection := connectionResult.GetConnection()
 
        // Make sure the connection is closed at the end
-       defer connection.BlockingClose()
+       defer connection.Close()
 
        // Prepare a write-request
        writeRequest, err := connection.WriteRequestBuilder().
                AddTagAddress("tag", "holding-register:26:REAL", 2.7182818284).
                Build()
        if err != nil {
-               fmt.Printf("error preparing read-request: %s", 
connectionResult.GetErr().Error())
+               fmt.Printf("error preparing read-request: %s", err.Error())
                return
        }
 
        // Execute a read-request
-       wrc := writeRequest.Execute()
+       wrc := writeRequest.Execute(ctx)
 
        // Wait for the response to finish
        wrr := <-wrc

Reply via email to