From c867d89f19666c62a4cafb1fb1849ecb6a0ba8cc Mon Sep 17 00:00:00 2001 From: zxd Date: Sun, 26 Aug 2018 22:11:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E4=BF=A1=E6=A8=A1=E5=9D=97=E7=9A=84?= =?UTF-8?q?=E6=96=AD=E7=BA=BF=E9=87=8D=E8=BF=9E=20=E5=9B=BA=E5=AE=9AIP?= =?UTF-8?q?=E6=94=B9=E6=8D=A2=E4=B8=BA199.51=20=E6=B7=BB=E5=8A=A0=E9=A3=9E?= =?UTF-8?q?=E6=9C=BA=E9=80=89=E4=B8=AD=E6=95=B0=E9=87=8F=E7=9A=84=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=20=E4=BC=98=E5=8C=96=E5=86=99=E8=88=AA=E7=82=B9?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E9=94=99=E8=AF=AF=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=86=99=E8=88=AA=E7=82=B9=E7=9A=84=E7=BB=9F=E8=AE=A1=20?= =?UTF-8?q?=E9=80=9A=E4=BF=A1=E6=A8=A1=E5=9D=97=E7=9A=84version=20?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E8=88=AA=E7=82=B9=E6=9C=80=E5=B0=8F=E8=B7=9D?= =?UTF-8?q?=E7=A6=BB=E6=97=B6=E6=98=BE=E7=A4=BAID=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PlaneGcsSdk.Contract_Shared/Copters/ICopterStatus.cs | 8 ++++++++ PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs | 4 +++- PlaneGcsSdk_Shared/Copters/CopterImplSharedPart.cs | 7 +++++++ .../Copters/EHCopter.InternalCopterEventHandlers.cs | 1 + PlaneGcsSdk_Shared/Copters/PlaneCopter.PacketAnalysis.cs | 4 +++- PlaneGcsSdk_Shared/Copters/PlaneCopter.cs | 2 ++ 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/PlaneGcsSdk.Contract_Shared/Copters/ICopterStatus.cs b/PlaneGcsSdk.Contract_Shared/Copters/ICopterStatus.cs index 47c6a19..2f4fc8b 100644 --- a/PlaneGcsSdk.Contract_Shared/Copters/ICopterStatus.cs +++ b/PlaneGcsSdk.Contract_Shared/Copters/ICopterStatus.cs @@ -173,6 +173,14 @@ namespace Plane.Copters /// float Voltage { get; } + /// + /// 预留字节用于通信模块条件下的返回值 + /// byte[] Retain { get; } + + /// + /// 飞机上通信模块版本 + /// + byte CommModuleVersion { get; } } } diff --git a/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs b/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs index b866599..aedcd37 100644 --- a/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs +++ b/PlaneGcsSdk_Shared/Communication/TcpConnectionBase.cs @@ -43,7 +43,7 @@ namespace Plane.Communication { try { - return !((_client.Client.Poll(1000, SelectMode.SelectRead) && (_client.Client.Available == 0)) || !_client.Client.Connected); + return _client.Client != null && !((_client.Client.Poll(1000, SelectMode.SelectRead) && (_client.Client.Available == 0)) || !_client.Client.Connected); } catch (ObjectDisposedException) { @@ -107,6 +107,8 @@ namespace Plane.Communication { while (Available < count) { + if (Available > 0) + Console.WriteLine("Available = " + Available); //if (!IsOpen) // return 0; if (!IsOnline) diff --git a/PlaneGcsSdk_Shared/Copters/CopterImplSharedPart.cs b/PlaneGcsSdk_Shared/Copters/CopterImplSharedPart.cs index a3cf514..9200070 100644 --- a/PlaneGcsSdk_Shared/Copters/CopterImplSharedPart.cs +++ b/PlaneGcsSdk_Shared/Copters/CopterImplSharedPart.cs @@ -662,6 +662,13 @@ namespace Plane.Copters protected set { Set(nameof(CommModuleMode), ref _CommModuleMode, value); } } + private byte _CommModuleVersion; + public byte CommModuleVersion + { + get { return _CommModuleVersion; } + protected set { Set(nameof(CommModuleVersion), ref _CommModuleVersion, value); } + } + #if PRIVATE public #else diff --git a/PlaneGcsSdk_Shared/Copters/EHCopter.InternalCopterEventHandlers.cs b/PlaneGcsSdk_Shared/Copters/EHCopter.InternalCopterEventHandlers.cs index 46c96d6..97f2073 100644 --- a/PlaneGcsSdk_Shared/Copters/EHCopter.InternalCopterEventHandlers.cs +++ b/PlaneGcsSdk_Shared/Copters/EHCopter.InternalCopterEventHandlers.cs @@ -33,6 +33,7 @@ namespace Plane.Copters Retain = BitConverter.GetBytes(_internalCopter.retain); Voltage = _internalCopter.battery_voltage; CommModuleMode = (FlightMode)_internalCopter.commModuleMode; + CommModuleVersion = _internalCopter.commModuleVersion; IsUnlocked = _internalCopter.isUnlocked; Yaw = _internalCopter.yaw; HeartbeatCount++; diff --git a/PlaneGcsSdk_Shared/Copters/PlaneCopter.PacketAnalysis.cs b/PlaneGcsSdk_Shared/Copters/PlaneCopter.PacketAnalysis.cs index 2d875a2..283d96e 100644 --- a/PlaneGcsSdk_Shared/Copters/PlaneCopter.PacketAnalysis.cs +++ b/PlaneGcsSdk_Shared/Copters/PlaneCopter.PacketAnalysis.cs @@ -378,7 +378,7 @@ namespace Plane.Copters /// 处理通信模块发过来的数据 /// /// - public void AnalyzeCommMouldePositionIntPacket(byte[] buffer) + public void AnalyzeCommMouldePositionIntPacket(byte[] buffer, byte version) { var info = buffer.ByteArrayToStructure(0); lat = info.lat * 1.0e-7; @@ -392,6 +392,8 @@ namespace Plane.Copters battery_voltage = ((float)info.battery_voltage) / 1000; yaw = ((float)info.yaw / 100) % 360; + commModuleVersion = version; + retain = info.retain; RaiseReceiveDataStreamEventOnUIThread(MAVLink.MAVLINK_MSG_ID_GPS_RAW_INT); } diff --git a/PlaneGcsSdk_Shared/Copters/PlaneCopter.cs b/PlaneGcsSdk_Shared/Copters/PlaneCopter.cs index c806ae7..1d275de 100644 --- a/PlaneGcsSdk_Shared/Copters/PlaneCopter.cs +++ b/PlaneGcsSdk_Shared/Copters/PlaneCopter.cs @@ -43,6 +43,8 @@ namespace Plane.Copters public uint mode { get; set; } public uint commModuleMode { get; set; } + public byte commModuleVersion { get; set; } + public bool isUnlocked { get; set; } public float battery_voltage { get; set; }