Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [UNRELEASED]

- Reduce log metadata and volume

## [2.7.0] - 2025-10-15

### Added
Expand Down
4 changes: 2 additions & 2 deletions src/dividat-driver/senso/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ func (handle *Handle) Connect(address string) {
handle.broker.TryPub(data, "rx")
}

go connectTCP(ctx, handle.log.WithField("channel", "data"), address+":55568", handle.broker.Sub("noTx"), onReceive)
go connectTCP(ctx, handle.log.WithField("channel", "data"), address+":55568", handle.broker.Sub("noTx"), onReceive, true)
time.Sleep(1000 * time.Millisecond)
go connectTCP(ctx, handle.log.WithField("channel", "control"), address+":55567", handle.broker.Sub("tx"), onReceive)
go connectTCP(ctx, handle.log.WithField("channel", "control"), address+":55567", handle.broker.Sub("tx"), onReceive, false)

handle.cancelCurrentConnection = cancel
}
Expand Down
14 changes: 11 additions & 3 deletions src/dividat-driver/senso/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ const maxInterval = 30 * time.Second
type onReceive = func([]byte)

// connectTCP creates a persistent tcp connection to address
func connectTCP(ctx context.Context, baseLogger *logrus.Entry, address string, tx chan interface{}, onReceive onReceive) {
// isOptional is used when connecting to the data channel, which is used only in legacy Senso firmware
func connectTCP(ctx context.Context, baseLogger *logrus.Entry, address string, tx chan interface{}, onReceive onReceive, isOptional bool) {
var dialer net.Dialer

var log = baseLogger.WithField("address", address)

var connectionAttemptLogLevel logrus.Level
if isOptional {
connectionAttemptLogLevel = logrus.DebugLevel
} else {
connectionAttemptLogLevel = logrus.InfoLevel
}

var conn net.Conn
dialTCP := func() error {

Expand All @@ -34,11 +42,11 @@ func connectTCP(ctx context.Context, baseLogger *logrus.Entry, address string, t
conn.Close()
}

log.Info("Dialing TCP connection.")
log.Log(connectionAttemptLogLevel, "Dialing TCP connection.")
conn, connErr = dialer.DialContext(ctx, "tcp", address)

if connErr != nil {
log.WithError(connErr).Info("Could not connect with Senso.")
log.WithError(connErr).Log(connectionAttemptLogLevel, "Could not connect with Senso.")
}
return connErr
}
Expand Down
9 changes: 0 additions & 9 deletions src/dividat-driver/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ func Start(logger *logrus.Logger, origins []string) context.CancelFunc {
baseLog.WithError(err).Panic("Could not get system information.")
}

baseLog = baseLog.WithFields(logrus.Fields{
"machineId": systemInfo.MachineId,
"os": systemInfo.Os,
"arch": systemInfo.Arch,
})

baseLog.Info("Dividat Driver starting")

// Setup log endpoint
Expand All @@ -68,9 +62,6 @@ func Start(logger *logrus.Logger, origins []string) context.CancelFunc {
// Create a logger for server
log := baseLog.WithField("package", "server")

// Start the monitor
go startMonitor(baseLog.WithField("package", "monitor"))

// Setup HTTP Server
server := http.Server{Addr: "127.0.0.1:" + serverPort}

Expand Down
19 changes: 0 additions & 19 deletions src/dividat-driver/server/monitor.go

This file was deleted.