From e1a0d6449def2e224d414d6718d340973a4ff78a Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 18 Aug 2019 22:57:24 +0100 Subject: [PATCH] Added ability to read an unterminated buffer when changing slewing precision --- Meade.net.Telescope/Telescope.cs | 5 +++++ Meade.net/SharedResources.cs | 8 ++++++++ Meade.net/Wrapper/SharedResourcesWrapper.cs | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index a882d82..913033e 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -496,15 +496,20 @@ namespace ASCOM.Meade.net //“HIGH PRECISION” Current setting after this command. //“LOW PRECISION” Current setting after this command. + int throwAwayCharacters = "LOW PRECISION".Length - 1; + LogMessage("TogglePrecision", $"Result: {result}"); bool highPrecision = false; switch (result) { case "H": highPrecision = true; + throwAwayCharacters = "HIGH PRECISION".Length - 1; break; } + _sharedResourcesWrapper.ReadCharacters(throwAwayCharacters); + //Make sure that the buffers are cleared out. _sharedResourcesWrapper.SendBlind("#"); diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 71d9653..8d27adb 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -116,6 +116,14 @@ namespace ASCOM.Meade.net } } + public static string ReadCharacters(int throwAwayCharacters) + { + lock (LockObject) + { + return SharedSerial.ReceiveCounted(throwAwayCharacters); + } + } + /// /// Example of handling connecting to and disconnection from the /// shared serial port. diff --git a/Meade.net/Wrapper/SharedResourcesWrapper.cs b/Meade.net/Wrapper/SharedResourcesWrapper.cs index c2fda79..3417ce6 100644 --- a/Meade.net/Wrapper/SharedResourcesWrapper.cs +++ b/Meade.net/Wrapper/SharedResourcesWrapper.cs @@ -24,6 +24,7 @@ namespace ASCOM.Meade.net.Wrapper void SetupDialog(); void WriteProfile(ProfileProperties profileProperties); + string ReadCharacters(int throwAwayCharacters); } public class SharedResourcesWrapper : ISharedResourcesWrapper @@ -72,6 +73,11 @@ namespace ASCOM.Meade.net.Wrapper return SharedResources.ReadTerminated(); } + public string ReadCharacters(int throwAwayCharacters) + { + return SharedResources.ReadCharacters(throwAwayCharacters); + } + public ProfileProperties ReadProfile() { return SharedResources.ReadProfile();