From df473f74099aae7c3ccfde733f981a0f8e4358c8 Mon Sep 17 00:00:00 2001 From: Stephen Merrony Date: Wed, 5 Sep 2018 09:41:10 +0100 Subject: [PATCH] Remove unneccessary stopChan for control connection - addreses Issue #9 --- tello.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tello.go b/tello.go index 41ae184..976075a 100644 --- a/tello.go +++ b/tello.go @@ -44,7 +44,7 @@ const keepAlivePeriodMs = 50 type Tello struct { ctrlMu sync.RWMutex // this mutex protects the control fields ctrlConn, videoConn *net.UDPConn - ctrlStopChan, videoStopChan chan bool + videoStopChan chan bool ctrlConnecting, ctrlConnected bool ctrlSeq uint16 ctrlRx, ctrlRy, ctrlLx, ctrlLy int16 // we are using the SDL convention: vals range from -32768 to 32767 @@ -101,9 +101,6 @@ func (tello *Tello) ControlConnect(udpAddr string, droneUDPPort int, localUDPPor } // start the control listener Goroutine - tello.ctrlMu.Lock() - tello.ctrlStopChan = make(chan bool, 2) - tello.ctrlMu.Unlock() go tello.controlResponseListener() // say hello to the Tello @@ -145,7 +142,6 @@ func (tello *Tello) ControlConnectDefault() (err error) { // ControlDisconnect stops the control channel listener and closes the connection to a Tello. func (tello *Tello) ControlDisconnect() { // TODO should we tell the Tello we are disconnecting? - tello.ctrlStopChan <- true tello.ctrlConn.Close() tello.ctrlConnected = false } @@ -288,12 +284,6 @@ func (tello *Tello) controlResponseListener() { continue } - select { - case <-tello.ctrlStopChan: - log.Println("ControlResponseLister stopped") - return - default: - } if err != nil { if strings.HasSuffix(err.Error(), "use of closed network connection") { return