From 7f6f478dfc34ef6764a5a095446abc399441d27d Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 12 Oct 2019 12:40:01 +0100 Subject: [PATCH] Modified the LX200 Classic connections, so that if a :GVP is returned when :GVP# is sent, it assumes an error. A timeout will be assumed to be an LX200 Classic. --- Meade.net/SharedResources.cs | 29 ++++++++++++++++++++++++----- Meade.net/TelescopeList.cs | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 2cba633..6882b4b 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -231,11 +231,9 @@ namespace ASCOM.Meade.net { if (!ConnectedDevices.ContainsKey(deviceId)) ConnectedDevices.Add(deviceId, new DeviceHardware()); - ConnectedDevices[deviceId].Count++; // increment the value - + if (!ConnectedDeviceIds.ContainsKey(driverId)) ConnectedDeviceIds.Add(driverId, new DeviceHardware()); - ConnectedDeviceIds[driverId].Count++; // increment the value if (deviceId == "Serial") { @@ -252,10 +250,31 @@ namespace ASCOM.Meade.net SharedSerial.Handshake = SerialHandshake.None; SharedSerial.Connected = true; - ProductName = SendString(":GVP#"); - FirmwareVersion = SendString(":GVN#"); + try + { + ProductName = SendString(":GVP#"); + FirmwareVersion = SendString(":GVN#"); + } + catch (TimeoutException) + { + ProductName = TelescopeList.LX200CLASSIC; + FirmwareVersion = "Unknown"; + } + + if (ProductName == ":GVP") + { + //This means that the serial port is looping back what's been sent, something is very wrong. + SharedSerial.Connected = false; + + throw new Exception("Serial port is looping back data, something is wrong with the hardware."); + } } } + else + throw new ArgumentException($"deviceId {deviceId} not currently supported"); + + ConnectedDevices[deviceId].Count++; // increment the value + ConnectedDeviceIds[driverId].Count++; // increment the value return new ConnectionInfo { diff --git a/Meade.net/TelescopeList.cs b/Meade.net/TelescopeList.cs index 5995983..61e4293 100644 --- a/Meade.net/TelescopeList.cs +++ b/Meade.net/TelescopeList.cs @@ -27,7 +27,7 @@ #region LX200EMC // ReSharper disable once InconsistentNaming - public static readonly string LX200CLASSIC = ":GVP"; //GVP command is not supported! + public static readonly string LX200CLASSIC = "LX200 Classic"; //GVP command is not supported! #endregion } }