Skip to content

Commit

Permalink
Log unknown TCP packets from driver station.
Browse files Browse the repository at this point in the history
  • Loading branch information
patfair committed Jul 29, 2024
1 parent 786f39e commit a1e64b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions field/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ func (arena *Arena) Update() {
msSinceLastDsPacket := int(time.Since(arena.lastDsPacketTime).Seconds() * 1000)
if sendDsPacket || msSinceLastDsPacket >= dsPacketPeriodMs {
if msSinceLastDsPacket >= dsPacketWarningMs && arena.lastDsPacketTime.After(time.Time{}) {
log.Printf("Too long since last driver station packet: %dms", msSinceLastDsPacket)
log.Printf("Warning: Long time since last driver station packet: %dms", msSinceLastDsPacket)
}
arena.sendDsPacket(auto, enabled)
arena.ArenaStatusNotifier.Notify()
Expand Down Expand Up @@ -683,7 +683,7 @@ func (arena *Arena) Run() {
go arena.runPeriodicTasks()
}
if time.Since(loopStartTime).Microseconds() > arenaLoopWarningUs {
log.Printf("Arena loop iteration took too long: %dus", time.Since(loopStartTime).Microseconds())
log.Printf("Warning: Arena loop iteration took a long time: %dus", time.Since(loopStartTime).Microseconds())
}

time.Sleep(time.Millisecond * arenaLoopPeriodMs)
Expand Down
15 changes: 9 additions & 6 deletions field/driver_station_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,22 @@ func (dsConn *DriverStationConnection) handleTcpConnection(arena *Arena) {

packetType := int(buffer[2])
switch packetType {
case 28:
case 29:
// DS keepalive packet; do nothing.
continue
case 22:
// Robot status packet.
var statusPacket [36]byte
copy(statusPacket[:], buffer[2:38])
dsConn.decodeStatusPacket(statusPacket)
}

// Log the packet if the match is in progress.
matchTimeSec := arena.MatchTimeSec()
if matchTimeSec > 0 && dsConn.log != nil {
dsConn.log.LogDsPacket(matchTimeSec, packetType, dsConn)
// Create a log entry if the match is in progress.
matchTimeSec := arena.MatchTimeSec()
if matchTimeSec > 0 && dsConn.log != nil {
dsConn.log.LogDsPacket(matchTimeSec, packetType, dsConn)
}
default:
log.Printf("Received unknown packet type %d from Team %d", packetType, dsConn.TeamId)
}
}
}
Expand Down

0 comments on commit a1e64b7

Please sign in to comment.