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 2023/01/13 13:53:21 UTC
[plc4x] 01/02: fix(plc4go/bacnet): smaller fixes relating udp comm
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
commit 75872b46ef3d274d94d53265833e2e70d91ea76b
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Jan 12 16:35:00 2023 +0100
fix(plc4go/bacnet): smaller fixes relating udp comm
---
plc4go/internal/bacnetip/ApplicationModule.go | 2 ++
plc4go/internal/bacnetip/MessageCodec.go | 5 ++++-
plc4go/internal/bacnetip/UDPCommunicationsModule.go | 5 ++++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/plc4go/internal/bacnetip/ApplicationModule.go b/plc4go/internal/bacnetip/ApplicationModule.go
index 444ccc0a90..ac815d5358 100644
--- a/plc4go/internal/bacnetip/ApplicationModule.go
+++ b/plc4go/internal/bacnetip/ApplicationModule.go
@@ -448,6 +448,8 @@ func NewBIPSimpleApplication(localDevice *LocalDeviceObject, localAddress Addres
return nil, errors.Wrap(err, "error read write property services")
}
+ b.localAddress = localAddress
+
// include a application decoder
b.asap, err = NewApplicationServiceAccessPoint(nil, nil)
if err != nil {
diff --git a/plc4go/internal/bacnetip/MessageCodec.go b/plc4go/internal/bacnetip/MessageCodec.go
index ee70b515da..335cb46813 100644
--- a/plc4go/internal/bacnetip/MessageCodec.go
+++ b/plc4go/internal/bacnetip/MessageCodec.go
@@ -21,6 +21,7 @@ package bacnetip
import (
"context"
+ "fmt"
"github.com/apache/plc4x/plc4go/protocols/bacnetip/readwrite/model"
"github.com/apache/plc4x/plc4go/spi"
"github.com/apache/plc4x/plc4go/spi/default"
@@ -49,7 +50,6 @@ func NewApplicationLayerMessageCodec(udpTransport *udp.Transport, transportUrl u
if err != nil {
return nil, errors.Wrap(err, "error creating transport instance")
}
- _ = transportInstance
a := &ApplicationLayerMessageCodec{
localAddress: localAddress,
remoteAddress: remoteAddress,
@@ -58,6 +58,9 @@ func NewApplicationLayerMessageCodec(udpTransport *udp.Transport, transportUrl u
if err != nil {
return nil, errors.Wrap(err, "error creating address")
}
+ // TODO: workaround for strange address parsing
+ at := AddressTuple[string, uint16]{fmt.Sprintf("%d.%d.%d.%d", address.AddrAddress[0], address.AddrAddress[1], address.AddrAddress[2], address.AddrAddress[3]), *address.AddrPort}
+ address.AddrTuple = &at
application, err := NewBIPSimpleApplication(&LocalDeviceObject{}, *address, &a.deviceInfoCache, nil)
if err != nil {
return nil, err
diff --git a/plc4go/internal/bacnetip/UDPCommunicationsModule.go b/plc4go/internal/bacnetip/UDPCommunicationsModule.go
index b29bfbb994..8d5984f369 100644
--- a/plc4go/internal/bacnetip/UDPCommunicationsModule.go
+++ b/plc4go/internal/bacnetip/UDPCommunicationsModule.go
@@ -149,6 +149,9 @@ func NewUDPDirector(address AddressTuple[string, uint16], timeout *int, reuse *b
return nil, errors.Wrap(err, "error resolving udp address")
}
d.ti = udp.NewTransportInstance(resolvedAddress, nil, d.timeout, d.reuse, nil)
+ if err := d.ti.Connect(); err != nil {
+ return nil, errors.Wrap(err, "error connecting transport instance")
+ }
d.running = true
go func() {
@@ -164,7 +167,7 @@ func NewUDPDirector(address AddressTuple[string, uint16], timeout *int, reuse *b
}()
// start with an empty peer pool
- d.peers = nil
+ d.peers = map[string]*UDPActor{}
return d, nil
}