This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/cdutz/go-ads-ng
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/feature/cdutz/go-ads-ng by
this push:
new 41a19c190 feat(ads): ADS Auto-Discovery
41a19c190 is described below
commit 41a19c190e30ef4a3d476c09076ff568bca264b7
Author: Christofer Dutz <[email protected]>
AuthorDate: Wed Nov 2 10:27:14 2022 +0100
feat(ads): ADS Auto-Discovery
- Switched to using a pre-allocated buffer
---
plc4go/internal/ads/Discoverer.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/plc4go/internal/ads/Discoverer.go
b/plc4go/internal/ads/Discoverer.go
index 7179af8ab..62e2c8fb6 100644
--- a/plc4go/internal/ads/Discoverer.go
+++ b/plc4go/internal/ads/Discoverer.go
@@ -20,6 +20,7 @@
package ads
import (
+ "bytes"
"context"
"encoding/binary"
"fmt"
@@ -213,7 +214,8 @@ func (d *Discoverer) Discover(ctx context.Context, callback
func(event apiModel.
discoveryRequestMessage :=
model.NewAdsDiscovery(0, model.Operation_DISCOVERY_REQUEST, amsNetId,
model.AdsPortNumbers_SYSTEM_SERVICE, []model.AdsDiscoveryBlock{})
// Serialize the message
- writeBuffer :=
utils.NewLittleEndianWriteBufferByteBased()
+ buffer := bytes.NewBuffer(make([]byte,
discoveryRequestMessage.GetLengthInBytes()))
+ writeBuffer :=
utils.NewCustomWriteBufferByteBased(buffer, binary.LittleEndian)
discoveryRequestMessage.Serialize(writeBuffer)
// Create a not-connected UDP connection to the
broadcast address