You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2023/02/23 22:19:40 UTC

[plc4x] 02/02: chore(driver/eip): Made the EIP connection request run.

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch fix/cdutz/reenable-golang-driver-testsuites
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit db91a6abb62dd55a49630818a0d8e54b4d515712
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Feb 23 23:19:27 2023 +0100

    chore(driver/eip): Made the EIP connection request run.
---
 plc4go/internal/eip/Connection.go             | 4 ++--
 plc4go/internal/eip/MessageCodec.go           | 5 +++--
 plc4go/tests/drivers/tests/eip_driver_test.go | 2 ++
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/plc4go/internal/eip/Connection.go b/plc4go/internal/eip/Connection.go
index 9f9cbea906..82aa6f9915 100644
--- a/plc4go/internal/eip/Connection.go
+++ b/plc4go/internal/eip/Connection.go
@@ -187,10 +187,10 @@ func (m *Connection) setupConnection(ctx context.Context, ch chan plc4go.PlcConn
 		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 		// Connect Register Session
 
-		log.Debug().Msg("Sending ListServices Request")
+		log.Debug().Msg("Sending EipConnectionRequest")
 		connectionResponseChan := make(chan readWriteModel.EipConnectionResponse)
 		connectionResponseErrorChan := make(chan error)
-		if err := m.messageCodec.SendRequest(ctx, readWriteModel.NewListServicesRequest(EmptySessionHandle, uint32(readWriteModel.CIPStatus_Success), []byte(DefaultSenderContext), uint32(0)), func(message spi.Message) bool {
+		if err := m.messageCodec.SendRequest(ctx, readWriteModel.NewEipConnectionRequest(EmptySessionHandle, uint32(readWriteModel.CIPStatus_Success), []byte(DefaultSenderContext), uint32(0)), func(message spi.Message) bool {
 			eipPacket := message.(readWriteModel.EipPacket)
 			return eipPacket != nil
 		}, func(message spi.Message) error {
diff --git a/plc4go/internal/eip/MessageCodec.go b/plc4go/internal/eip/MessageCodec.go
index 37aa4650b1..9606863525 100644
--- a/plc4go/internal/eip/MessageCodec.go
+++ b/plc4go/internal/eip/MessageCodec.go
@@ -51,13 +51,14 @@ func (m *MessageCodec) Send(message spi.Message) error {
 	// Cast the message to the correct type of struct
 	eipPacket := message.(model.EipPacket)
 	// Serialize the request
-	theBytes, err := eipPacket.Serialize()
+	wb := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian))
+	err := eipPacket.SerializeWithWriteBuffer(context.Background(), wb)
 	if err != nil {
 		return errors.Wrap(err, "error serializing request")
 	}
 
 	// Send it to the PLC
-	err = m.GetTransportInstance().Write(theBytes)
+	err = m.GetTransportInstance().Write(wb.GetBytes())
 	if err != nil {
 		return errors.Wrap(err, "error sending request")
 	}
diff --git a/plc4go/tests/drivers/tests/eip_driver_test.go b/plc4go/tests/drivers/tests/eip_driver_test.go
index a60f902f0f..f3a05a4edc 100644
--- a/plc4go/tests/drivers/tests/eip_driver_test.go
+++ b/plc4go/tests/drivers/tests/eip_driver_test.go
@@ -26,8 +26,10 @@ import (
 	"github.com/apache/plc4x/plc4go/protocols/eip/readwrite"
 	"github.com/apache/plc4x/plc4go/spi/testutils"
 	_ "github.com/apache/plc4x/plc4go/tests/initializetest"
+	"github.com/rs/zerolog"
 )
 
 func TestEIPDriver(t *testing.T) {
+	zerolog.SetGlobalLevel(zerolog.DebugLevel)
 	testutils.RunDriverTestsuite(t, eip.NewDriver(), "assets/testing/protocols/eip/DriverTestsuite.xml", readwrite.EipXmlParserHelper{})
 }