Skip to content

Commit

Permalink
[feature] Make network connection a bit more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
g3force committed Dec 7, 2018
1 parent 5d5e3bc commit 99260c3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/vision/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ func (r *Receiver) Receive(multicastAddress string) {
n, _, err := listener.ReadFrom(data)
if err != nil {
log.Println("ReadFromUDP failed:", err)
break
}

message, err := parseVisionWrapperPacket(data[:n])
if err != nil {
log.Print("Could not parse referee message: ", err)
break
} else {
if message.Detection != nil {
r.mutex.Lock()
Expand All @@ -66,6 +68,11 @@ func (r *Receiver) Receive(multicastAddress string) {
}
}
}

// wait a second and restart
listener.Close()
time.Sleep(time.Second)
r.Receive(multicastAddress)
}

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

0 comments on commit 99260c3

Please sign in to comment.