Mission 2 works awesome

This commit is contained in:
2019-09-09 00:10:33 -06:00
parent 1190c08729
commit 52a566eaf4
3 changed files with 10 additions and 11 deletions

View File

@@ -34,17 +34,14 @@ namespace Tello_Drone
private void SendCommand(string message)
private bool SendCommand(string message)
{
var returnValue = _udpClient.TrySend(message, 5_000, 3);
if (returnValue == false)
SendCommand("land");
return _udpClient.TrySend(message, 5_000, 3);
}
private bool TrySendCommand(string message)
{
return _udpClient.TrySend(message, 5_000, 3);
return _udpClient.TrySend(message, 20_000, 3);
}
}
}

View File

@@ -33,8 +33,9 @@ namespace Tello_Drone
MissionSetup();
_drone.BackFlip();
_drone.FrontFlip();
_drone.Forward(30);
_drone.Land();
_drone.Reverse(55);
_drone.Forward(66);
MissionTeardown();
}
private void MissionSetup()

View File

@@ -30,7 +30,7 @@ namespace Tello_Drone
{
_consoleLogger.Log($"Sending command to drone: {message}");
bool successfullFlag = false;
while(maxRetries >= 0 && successfullFlag == false)
while(maxRetries > 0 && successfullFlag == false)
{
_client.Client.ReceiveTimeout = timeout;
_client.Send(Encoding.ASCII.GetBytes(message), message.Length);
@@ -43,9 +43,10 @@ namespace Tello_Drone
if (returnMessage == "ok")
successfullFlag = true;
}
catch
catch(Exception x)
{
_consoleLogger.Log($"Did not get a response from the drone will attempt {maxRetries.ToString()} more times");
_consoleLogger.Log(x.Message);
_consoleLogger.Log($"Recieved {x.Message} from the drone, will attempt {maxRetries.ToString()} more times");
}
maxRetries--;