通信模块的断线重连 固定IP改换为199.51

添加飞机选中数量的统计
优化写航点跳过错误,优化写航点的统计
通信模块的version
检测航点最小距离时显示ID号
This commit is contained in:
zxd 2018-08-26 22:11:06 +08:00
parent 72a9e28ed1
commit c867d89f19
6 changed files with 24 additions and 2 deletions

View File

@ -173,6 +173,14 @@ namespace Plane.Copters
/// </summary> /// </summary>
float Voltage { get; } float Voltage { get; }
/// <summary>
/// 预留字节用于通信模块条件下的返回值
/// </summary>
byte[] Retain { get; } byte[] Retain { get; }
/// <summary>
/// 飞机上通信模块版本
/// </summary>
byte CommModuleVersion { get; }
} }
} }

View File

@ -43,7 +43,7 @@ namespace Plane.Communication
{ {
try 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) catch (ObjectDisposedException)
{ {
@ -107,6 +107,8 @@ namespace Plane.Communication
{ {
while (Available < count) while (Available < count)
{ {
if (Available > 0)
Console.WriteLine("Available = " + Available);
//if (!IsOpen) //if (!IsOpen)
// return 0; // return 0;
if (!IsOnline) if (!IsOnline)

View File

@ -662,6 +662,13 @@ namespace Plane.Copters
protected set { Set(nameof(CommModuleMode), ref _CommModuleMode, value); } 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 #if PRIVATE
public public
#else #else

View File

@ -33,6 +33,7 @@ namespace Plane.Copters
Retain = BitConverter.GetBytes(_internalCopter.retain); Retain = BitConverter.GetBytes(_internalCopter.retain);
Voltage = _internalCopter.battery_voltage; Voltage = _internalCopter.battery_voltage;
CommModuleMode = (FlightMode)_internalCopter.commModuleMode; CommModuleMode = (FlightMode)_internalCopter.commModuleMode;
CommModuleVersion = _internalCopter.commModuleVersion;
IsUnlocked = _internalCopter.isUnlocked; IsUnlocked = _internalCopter.isUnlocked;
Yaw = _internalCopter.yaw; Yaw = _internalCopter.yaw;
HeartbeatCount++; HeartbeatCount++;

View File

@ -378,7 +378,7 @@ namespace Plane.Copters
/// 处理通信模块发过来的数据 /// 处理通信模块发过来的数据
/// </summary> /// </summary>
/// <param name="buffer"></param> /// <param name="buffer"></param>
public void AnalyzeCommMouldePositionIntPacket(byte[] buffer) public void AnalyzeCommMouldePositionIntPacket(byte[] buffer, byte version)
{ {
var info = buffer.ByteArrayToStructure<MavComm.comm_copter_info>(0); var info = buffer.ByteArrayToStructure<MavComm.comm_copter_info>(0);
lat = info.lat * 1.0e-7; lat = info.lat * 1.0e-7;
@ -392,6 +392,8 @@ namespace Plane.Copters
battery_voltage = ((float)info.battery_voltage) / 1000; battery_voltage = ((float)info.battery_voltage) / 1000;
yaw = ((float)info.yaw / 100) % 360; yaw = ((float)info.yaw / 100) % 360;
commModuleVersion = version;
retain = info.retain; retain = info.retain;
RaiseReceiveDataStreamEventOnUIThread(MAVLink.MAVLINK_MSG_ID_GPS_RAW_INT); RaiseReceiveDataStreamEventOnUIThread(MAVLink.MAVLINK_MSG_ID_GPS_RAW_INT);
} }

View File

@ -43,6 +43,8 @@ namespace Plane.Copters
public uint mode { get; set; } public uint mode { get; set; }
public uint commModuleMode { get; set; } public uint commModuleMode { get; set; }
public byte commModuleVersion { get; set; }
public bool isUnlocked { get; set; } public bool isUnlocked { get; set; }
public float battery_voltage { get; set; } public float battery_voltage { get; set; }