Skip to content

Commit 99260c3

Browse files
committed
[feature] Make network connection a bit more robust
1 parent 5d5e3bc commit 99260c3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/vision/receiver.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ func (r *Receiver) Receive(multicastAddress string) {
4848
n, _, err := listener.ReadFrom(data)
4949
if err != nil {
5050
log.Println("ReadFromUDP failed:", err)
51+
break
5152
}
5253

5354
message, err := parseVisionWrapperPacket(data[:n])
5455
if err != nil {
5556
log.Print("Could not parse referee message: ", err)
57+
break
5658
} else {
5759
if message.Detection != nil {
5860
r.mutex.Lock()
@@ -66,6 +68,11 @@ func (r *Receiver) Receive(multicastAddress string) {
6668
}
6769
}
6870
}
71+
72+
// wait a second and restart
73+
listener.Close()
74+
time.Sleep(time.Second)
75+
r.Receive(multicastAddress)
6976
}
7077

7178
func (r *Receiver) CombinedDetectionFrames() (f *sslproto.SSL_DetectionFrame) {

0 commit comments

Comments
 (0)