Skip to content

Commit

Permalink
Small changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoga committed May 30, 2024
1 parent 6490da7 commit 17e00b4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion module/robot/robot.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func New(ub unitybridge.UnityBridge, l *logger.Logger,

rb.BaseModule = internal.NewBaseModule(ub, l, "Robot",
key.KeyRobomasterSystemConnection, func(r *result.Result) {
if r == nil || !r.Succeeded() {
if !r.Succeeded() {
rb.Logger().Error(
"Connection: Unexpected result.", "result", r)
return
Expand Down
17 changes: 4 additions & 13 deletions tests/chassis/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import (
"github.com/brunoga/robomaster/module/chassis"
"github.com/brunoga/robomaster/module/controller"
"github.com/brunoga/robomaster/support"
"github.com/brunoga/robomaster/support/logger"
)

var chassisModule *chassis.Chassis

func TestMain(m *testing.M) {
c, err := robomaster.NewWithModules(nil, support.AnyAppID,
l := logger.New(logger.LevelTrace, "unity_bridge", "wrapper")

c, err := robomaster.NewWithModules(l, support.AnyAppID,
module.TypeConnection|module.TypeRobot|module.TypeController|module.TypeChassis)
if err != nil {
panic(err)
Expand All @@ -31,18 +34,6 @@ func TestMain(m *testing.M) {

chassisModule = c.Chassis()

// Enable robot movement.
//err = c.Robot().EnableFunction(robot.FunctionTypeMovementControl, true)
//if err != nil {
// panic(err)
//}
//defer func() {
// err := c.Robot().EnableFunction(robot.FunctionTypeMovementControl, false)
// if err != nil {
// panic(err)
// }
//}()

// Set controller mode to SDK for the tests here.
err = c.Controller().SetMode(controller.ModeSDK)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tests/gimbal/main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gimbal

import (
"log/slog"
"os"
"testing"

Expand All @@ -16,7 +15,7 @@ import (
var gimbalModule *gimbal.Gimbal

func TestMain(m *testing.M) {
c, err := robomaster.NewWithModules(logger.New(slog.LevelDebug), support.AnyAppID,
c, err := robomaster.NewWithModules(logger.New(logger.LevelTrace, "wrapper"), support.AnyAppID,
module.TypeConnection|module.TypeRobot|module.TypeController|module.TypeGimbal)
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion tests/gimbal/set_rotation_speed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func TestSetRotationSpeed(t *testing.T) {
err := gimbalModule.SetRotationSpeed(0, 10)
err := gimbalModule.SetRotationSpeed(10, 10)
if err != nil {
t.Errorf("SetRotationSpeed() failed, got: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions unitybridge/internal/unitybridgeimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ func (u *UnityBridgeImpl) notifyEventTypeListeners(e *event.Event,
}

func (u *UnityBridgeImpl) notifyKeyListeners(k *key.Key, data []byte) {
endTrace := u.l.Trace("notifyKeyListeners", "key", k, "data", data)
endTrace := u.l.Trace("notifyKeyListeners", "key", k, "data", string(data))
defer endTrace()

u.m.RLock()
Expand All @@ -654,7 +654,7 @@ func (u *UnityBridgeImpl) notifyKeyListeners(k *key.Key, data []byte) {
}

func (u *UnityBridgeImpl) notifyCallbacks(data []byte, tag uint64) {
endTrace := u.l.Trace("notifyCallbacks", "data", data, "tag", tag)
endTrace := u.l.Trace("notifyCallbacks", "data", string(data), "tag", tag)
defer endTrace()

u.m.Lock()
Expand Down

0 comments on commit 17e00b4

Please sign in to comment.