Skip to content

Commit

Permalink
refactor(plc4go/bacnet): refined logging for Discoverer
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Jun 23, 2022
1 parent f219a65 commit e016585
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
12 changes: 6 additions & 6 deletions plc4go/internal/bacnetip/Discoverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ func broadcastAndDiscover(ctx context.Context, communicationChannels []communica
select {
case ok := <-blockingReadChan:
if !ok {
log.Debug().Msg("Ending reading")
log.Debug().Msg("Ending unicast reading")
return
}
log.Trace().Msg("Received something")
log.Trace().Msg("Received something unicast")
case <-ctx.Done():
log.Debug().Err(ctx.Err()).Msg("Ending unicast receive")
return
Expand All @@ -151,7 +151,7 @@ func broadcastAndDiscover(ctx context.Context, communicationChannels []communica
buf := make([]byte, 4096)
n, addr, err := communicationChannelInstance.broadcastConnection.ReadFrom(buf)
if err != nil {
log.Debug().Err(err).Msg("Ending unicast receive")
log.Debug().Err(err).Msg("Ending broadcast receive")
blockingReadChan <- false
return
}
Expand All @@ -167,12 +167,12 @@ func broadcastAndDiscover(ctx context.Context, communicationChannels []communica
select {
case ok := <-blockingReadChan:
if !ok {
log.Debug().Msg("Ending reading")
log.Debug().Msg("Ending broadcast reading")
return
}
log.Trace().Msg("Received something")
log.Trace().Msg("Received something broadcast")
case <-ctx.Done():
log.Debug().Err(ctx.Err()).Msg("Ending unicast receive")
log.Debug().Err(ctx.Err()).Msg("Ending broadcast receive")
return
}
}
Expand Down
5 changes: 2 additions & 3 deletions plc4go/tests/drivers/tests/manual_bacnet_PcapTest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/apache/plc4x/plc4go/pkg/api/logging"
"github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/require"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -66,9 +67,7 @@ func Test(t *testing.T) {
println(event)
}).
Build()
if err != nil {
panic(err)
}
require.NoError(t, err)
requestResult := <-build.Execute()
if requestResult.GetErr() != nil {
panic(requestResult.GetErr())
Expand Down
5 changes: 2 additions & 3 deletions plc4go/tests/drivers/tests/manual_bacnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/apache/plc4x/plc4go/internal/spi/utils"
"github.com/apache/plc4x/plc4go/protocols/bacnetip/readwrite/model"
_ "github.com/apache/plc4x/plc4go/tests/initializetest"
"github.com/stretchr/testify/require"
"testing"
)

Expand All @@ -37,7 +38,5 @@ func TestManualBacnet(t *testing.T) {
/*00000060*/ 0x3f, //|?|
}
_, err := model.BVLCParse(utils.NewReadBufferByteBased(rawBytes[42:]))
if err != nil {
panic(err)
}
require.NoError(t, err)
}

0 comments on commit e016585

Please sign in to comment.