Use correct data from DS for ping and lost packets status#259
Use correct data from DS for ping and lost packets status#259patfair merged 4 commits intoTeam254:mainfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughRemoved DS status decoding and Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
field/driver_station_connection.go (1)
104-108: Discarded UDP read error can cause a hot spin loop.If
listener.Readreturns a persistent error (e.g., socket closed), the error is silently ignored andcountwill be 0, causing thecount < 8branch to log continuously in a tight loop. Consider checking the error and breaking or sleeping on non-transient errors.Suggested handling
- count, _ := listener.Read(data[:]) - if count < 8 { - log.Printf("Received packet with insufficient length: %d", count) + count, err := listener.Read(data[:]) + if err != nil { + log.Printf("Error reading from driver station UDP socket: %v", err) + continue + } + if count < 8 { + log.Printf("Received packet with insufficient length: %d", count)
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
field/driver_station_connection_test.go (1)
202-211:⚠️ Potential issue | 🔴 CriticalTest is broken — assertions rely on removed TCP status-decoding path (CI failure).
The production code no longer decodes
MissedPacketCount/DsRobotTripTimeMsfrom TCP packet type 22; these are now sourced from UDP tag-encoded data. The assertions on lines 209-210 will always see0, which matches the pipeline failure:
expected: 103, actual: 0;expected: 14, actual: 0Either remove these two assertions (and the stale comment on line 202) or replace them with a UDP-based test that sends a packet containing a tag-1 payload to the
driverStationUdpReceivePortlistener.Minimal fix — remove stale assertions
- // Check that an unknown packet type gets ignored and a status packet gets decoded. + // Check that an unknown packet type gets ignored. dataSend = [5]byte{0, 3, 37, 0, 0} tcpConn.Write(dataSend[:]) time.Sleep(time.Millisecond * 10) - dataSend2 := [38]byte{0, 36, 22, 28, 103, 19, 192, 0, 246} - tcpConn.Write(dataSend2[:]) - time.Sleep(time.Millisecond * 10) - assert.Equal(t, 103, dsConn.MissedPacketCount) - assert.Equal(t, 14, dsConn.DsRobotTripTimeMs)Ideally, add a dedicated test that exercises the new UDP tag-parsing path (send a crafted UDP packet with tag 1, length 6, and verify
MissedPacketCountandDsRobotTripTimeMsare updated).
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@field/driver_station_connection.go`:
- Around line 104-108: The loop currently ignores the error returned by
listener.Read (call at listener.Read(data[:])) and only checks count, which can
cause an infinite spin/log spam if the socket is closed; update the read
handling in the same function so you capture the returned err alongside count,
check if err != nil, treat temporary/net.Error with Temporary() as a retry (log
and continue), and for permanent errors (including EOF or non-temporary errors)
log the error and break/return (or call log.Fatalf if appropriate) instead of
continuing; keep the existing insufficient-length check for count < 8 after
handling err.
Summary by CodeRabbit
Improvements
Behavior Change
Tests