diff --git a/PlaneGcsSdk.Contract_Shared/Copters/FlightCommand.cs b/PlaneGcsSdk.Contract_Shared/Copters/FlightCommand.cs
index f6f5887..f7689bf 100644
--- a/PlaneGcsSdk.Contract_Shared/Copters/FlightCommand.cs
+++ b/PlaneGcsSdk.Contract_Shared/Copters/FlightCommand.cs
@@ -35,6 +35,11 @@
///
TakeOff = 22,
+ ///
+ /// 命令飞行器改变速度
+ ///
+ ChangeSpeed = 178,
+
///
/// 命令LED颜色改变
///
diff --git a/PlaneGcsSdk_Private_NET46/PlaneGcsSdk_Private_NET46.csproj b/PlaneGcsSdk_Private_NET46/PlaneGcsSdk_Private_NET46.csproj
index 4625ca5..0569a3e 100644
--- a/PlaneGcsSdk_Private_NET46/PlaneGcsSdk_Private_NET46.csproj
+++ b/PlaneGcsSdk_Private_NET46/PlaneGcsSdk_Private_NET46.csproj
@@ -57,6 +57,10 @@
+
+ {413C18E2-235F-4E15-B5C1-633657DE5D7A}
+ Plane.Windows.Messages
+
{47141894-ece3-48ca-8dcf-ca751bda231e}
PlaneGcsSdk.Contract_Private
diff --git a/PlaneGcsSdk_Shared/Communication/TcpConnection.cs b/PlaneGcsSdk_Shared/Communication/TcpConnection.cs
index 1879629..58c086f 100644
--- a/PlaneGcsSdk_Shared/Communication/TcpConnection.cs
+++ b/PlaneGcsSdk_Shared/Communication/TcpConnection.cs
@@ -44,6 +44,7 @@ namespace Plane.Communication
}
_isBroken = false;
}
+
_stream = _client.GetStream();
}
diff --git a/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs b/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs
index 208443a..c1e7231 100644
--- a/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs
+++ b/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs
@@ -24,7 +24,10 @@ namespace Plane.Communication
{
try
{
- return _client.Available;
+ if (_client.Connected)
+ return _client.Available;
+ else
+ return 0;
}
catch (ObjectDisposedException ex)
{
@@ -89,6 +92,7 @@ namespace Plane.Communication
{
while (Available < count)
{
+ if (!IsOpen) return 0;
await Task.Delay(5).ConfigureAwait(false);
}
return await _stream.ReadAsync(buffer, offset, count);
diff --git a/PlaneGcsSdk_Shared/Copters/Mission.cs b/PlaneGcsSdk_Shared/Copters/Mission.cs
index da36bb8..5d5a8f8 100644
--- a/PlaneGcsSdk_Shared/Copters/Mission.cs
+++ b/PlaneGcsSdk_Shared/Copters/Mission.cs
@@ -198,5 +198,13 @@ namespace Plane.Copters
G = green, //Green
B = blue //Blue
};
+
+ public static IMission CreateChangeSpeedMission(float levelSpeed, float upSpeed, float downSpeed) => new Mission
+ {
+ Command = FlightCommand.ChangeSpeed,
+ Param1 = levelSpeed, //水平速度
+ Param2 = upSpeed, //上升速度
+ Param3 = downSpeed, //下降速度
+ };
}
}
diff --git a/PlaneGcsSdk_Shared/PlaneGcsSdk_Shared.projitems b/PlaneGcsSdk_Shared/PlaneGcsSdk_Shared.projitems
index c18897f..eb29cd0 100644
--- a/PlaneGcsSdk_Shared/PlaneGcsSdk_Shared.projitems
+++ b/PlaneGcsSdk_Shared/PlaneGcsSdk_Shared.projitems
@@ -10,6 +10,7 @@
+