Skip to content

Commit 2b650ee

Browse files
OATControl V1.0.2.1 and ASCOM Driver 6.6.3.0 Updates (#27)
* OATControl V1.0.2.0 and ASCOM Driver 6.6.2.0 Updates - Allow OATControl to use ASCOM driver. * OATControl V1.0.2.1 and ASCOM Driver 6.6.3.0 Updates - Added support for communication handlers to open a settings dialog. - Added display of active connection to main window. - Made some cosmetic changes in Connection dialog to accomodate setup. - Made some cosmetic changes in Main window to line up display of stepper and mount values. - Fixed a bug that prevented Next button on Connect dialgo working when ASCOM was chosen. - Fixed a bug that made the DEC limits toggle no be persisted. - Fixed a bug to correctly handle the two message reply from :SC...# command * Readme updates. * Setup file updates
1 parent 42fbf65 commit 2b650ee

File tree

23 files changed

+659
-299
lines changed

23 files changed

+659
-299
lines changed

ASCOM.Driver/OpenAstroTracker/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// Build Number
2222
// Revision
2323
//
24-
[assembly: AssemblyVersion("6.6.1.0")]
25-
[assembly: AssemblyFileVersion("6.6.1.0")]
24+
[assembly: AssemblyVersion("6.6.3.0")]
25+
[assembly: AssemblyFileVersion("6.6.3.0")]
2626

2727
[assembly: ComVisibleAttribute(false)]

ASCOM.Driver/OpenAstroTracker/README.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
OpenAstroTracker ASCOM Driver
33
=============================
44

5-
Version 6.6.1.0, published 03 May 2021
5+
Version 6.6.3.0, published 14-Jun-2021
66
----------------------------------------
77

88
* History
9+
* 6.6.3.0 2021-06-13 : CHANGE : Changed passthrough command to support double-# terminated reply.
10+
* 6.6.2.0 2021-06-12 : CHANGE : Changed passthrough command to support OATControl.
911
* 6.6.1.0 2021-05-03 : CHANGE : Added support for OAT focuser.
1012
* 6.5.4.0 2021-04-15 : CHANGE : Changed available and default baud rate(s).
1113
* 6.5.3.0 2021-04-10 : CHANGE : Fixed Sync command. Added choosable baudrate. Lots of bug fixes.
@@ -21,8 +23,8 @@ Version 6.6.1.0, published 03 May 2021
2123

2224

2325
* Arduino information
24-
* Tested on Arduino Mega and ESP32. No other variants of Arduino have been tested, or are officially supported (MKS falls under Mega).
25-
* Tested with V1.9.03 firmware, which is the RECOMMENDED version.
26+
* Tested on MKS Gen L V2.1, Arduino Mega and ESP32. No other variants of Arduino have been tested, or are officially supported.
27+
* Tested with V1.9.15 firmware, which is the RECOMMENDED version.
2628
* Will probably work with earlier version (down to V1.6.32 and later).
2729

2830
* Last Conformance Test - 2021-04-09 - All tests passed, no errors, no issues.

ASCOM.Driver/OpenAstroTracker/SharedResources.cs

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ enum ExpectedAnswer
146146
{
147147
None,
148148
Digit,
149-
HashTerminated
149+
HashTerminated,
150+
DoubleHashTerminated,
150151
}
151152

152153
/// <summary>
@@ -171,6 +172,11 @@ public static string SendMessage(string message)
171172
message = message.Substring(0, message.Length - 2);
172173
expect = ExpectedAnswer.HashTerminated;
173174
}
175+
else if (message.EndsWith("#,##"))
176+
{
177+
message = message.Substring(0, message.Length - 3);
178+
expect = ExpectedAnswer.DoubleHashTerminated;
179+
}
174180
else if (message.EndsWith("#,n"))
175181
{
176182
message = message.Substring(0, message.Length - 2);
@@ -198,6 +204,15 @@ public static string SendMessage(string message)
198204
tl.LogMessage("OAT Server", "Raw reply :" + retVal);
199205
retVal = retVal.TrimEnd('#');
200206
break;
207+
case ExpectedAnswer.DoubleHashTerminated:
208+
tl.LogMessage("OAT Server", "Wait for two replies. Wait for 1st string reply");
209+
retVal = SharedSerial.ReceiveTerminated("#");
210+
tl.LogMessage("OAT Server", "First Raw reply :" + retVal);
211+
retVal = retVal.TrimEnd('#');
212+
tl.LogMessage("OAT Server", "Wait for 2nd string reply");
213+
retVal = SharedSerial.ReceiveTerminated("#");
214+
tl.LogMessage("OAT Server", "Second Raw reply :" + retVal);
215+
break;
201216
}
202217

203218
tl.LogMessage("OAT Server", "Reply: " + retVal);
@@ -212,37 +227,9 @@ public static string SendMessage(string message)
212227
return retVal;
213228
}
214229

215-
public static string SendPassThroughCommand(string message, string terminator)
230+
public static string SendPassThroughCommand(string message)
216231
{
217-
lock (lockObject)
218-
{
219-
tl.LogMessage("OAT Server", "Locked Serial");
220-
221-
try
222-
{
223-
if (SharedSerial.Connected && !String.IsNullOrEmpty(message))
224-
{
225-
tl.LogMessage("Telescope", "Send message: " + message);
226-
SharedSerial.ClearBuffers();
227-
SharedSerial.Transmit(message);
228-
if (!string.IsNullOrEmpty(terminator))
229-
{
230-
return SharedSerial.ReceiveTerminated(terminator.ToString());
231-
}
232-
}
233-
else
234-
{
235-
tl.LogMessage("OAT Server", "Not connected or Empty Message: " + message);
236-
}
237-
}
238-
catch (Exception e)
239-
{
240-
tl.LogMessage($"Caught exception while SendPassThroughCommand - ${message}", e.Message);
241-
}
242-
}
243-
244-
tl.LogMessage("OAT Server", "Unlocked Serial");
245-
return string.Empty;
232+
return SendMessage(message);
246233
}
247234

248235

ASCOM.Driver/TelescopeDriver/Driver.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ public string Action(string ActionName, string ActionParameters)
137137

138138
case "Serial:PassThroughCommand":
139139
{
140-
var s = ActionParameters.Split(',');
141-
retVal = SharedResources.SendPassThroughCommand(s[0], s[1]);
140+
retVal = SharedResources.SendPassThroughCommand(ActionParameters);
142141
break;
143142
}
144143
}

ASCOM.Driver/TelescopeDriver/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
// by using the '*' as shown below:
3636
//
3737
// TODO - Set your driver's version here
38-
[assembly: AssemblyVersion("6.6.1.0")]
39-
[assembly: AssemblyFileVersion("6.6.1.0")]
38+
[assembly: AssemblyVersion("6.6.3.0")]
39+
[assembly: AssemblyFileVersion("6.6.3.0")]
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO.Ports;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using ASCOM.DeviceInterface;
9+
10+
using OATCommunications.CommunicationHandlers;
11+
using OATCommunications.Utilities;
12+
13+
namespace OATCommunications.CommunicationHandlers
14+
{
15+
public class ASCOMCommunicationHandler : CommunicationHandler
16+
{
17+
ASCOM.DriverAccess.Telescope _oat;
18+
19+
public ASCOMCommunicationHandler()
20+
{
21+
}
22+
23+
public ASCOMCommunicationHandler(string device)
24+
{
25+
Log.WriteLine($"COMMFACTORY: Creating ASCOM handler for {device} ...");
26+
_oat = new ASCOM.DriverAccess.Telescope("ASCOM.OpenAstroTracker.Telescope");
27+
28+
foreach (var action in _oat.SupportedActions)
29+
{
30+
Log.WriteLine($"COMMFACTORY: ASCOM handler supported action: {action} ...");
31+
}
32+
_oat.Action("Serial:PassThroughCommand", "I#");
33+
}
34+
35+
public override string Name => "ASCOM";
36+
37+
public override bool Connected { get { return _oat.Connected; } }
38+
39+
long requestIndex = 1;
40+
41+
protected override void RunJob(Job job)
42+
{
43+
CommandResponse response = null;
44+
45+
if (_logJobs) Log.WriteLine("[{0:0000}] ASCOM: [{1}] Processing Job", requestIndex, job.Command);
46+
if (Connected)
47+
{
48+
if (_logJobs) Log.WriteLine("[{0:0000}] ASCOM: [{1}] Connected! Discarding any bytes in input buffer", requestIndex, job.Command);
49+
requestIndex++;
50+
string reply;
51+
try
52+
{
53+
if (_logJobs) Log.WriteLine("[{0:0000}] ASCOM: [{1}] Sending command", requestIndex, job.Command);
54+
string command = job.Command;
55+
switch (job.ResponseType)
56+
{
57+
case ResponseType.NoResponse:
58+
if (_logJobs) Log.WriteLine("[{0:0000}] ASCOM: [{1}] Expecting no response for command", requestIndex, job.Command);
59+
break;
60+
61+
case ResponseType.DigitResponse:
62+
if (_logJobs) Log.WriteLine("[{0:0000}] ASCOM: [{1}] Expecting single digit response for command", requestIndex, job.Command);
63+
command += ",n";
64+
break;
65+
66+
case ResponseType.FullResponse:
67+
if (_logJobs) Log.WriteLine("[{0:0000}] ASCOM: [{1}] Expecting #-delimited response for Command...", requestIndex, job.Command);
68+
command += ",#";
69+
break;
70+
case ResponseType.DoubleFullResponse:
71+
command += ",##";
72+
if (_logJobs) Log.WriteLine("[{0:0000}] ASCOM: [{1}] Expecting two #-delimited responses for Command...", requestIndex, job.Command);
73+
break;
74+
}
75+
76+
reply = _oat.Action("Serial:PassThroughCommand", command);
77+
response = new CommandResponse(reply, true);
78+
}
79+
catch (Exception ex)
80+
{
81+
Log.WriteLine("[{0:0000}] ASCOM: [{1}] Failed to send command. {2}", requestIndex, job.Command, ex.Message);
82+
job.OnFulFilled(new CommandResponse(string.Empty, false, $"Unable to execute command. " + ex.Message));
83+
return;
84+
}
85+
}
86+
else
87+
{
88+
Log.WriteLine("[{0:0000}] ASCOM: Telescope is not connected!", requestIndex);
89+
response = new CommandResponse(string.Empty, false, $"Unable to connect to telescope");
90+
}
91+
92+
if (_logJobs) Log.WriteLine("[{0:0000}] ASCOM: Calling OnFulFilled lambda", requestIndex);
93+
job.OnFulFilled(response);
94+
if (_logJobs) Log.WriteLine("[{0:0000}] ASCOM: Job completed", requestIndex);
95+
}
96+
97+
public override bool Connect()
98+
{
99+
_oat.Connected = true;
100+
StopJobsProcessor();
101+
StartJobsProcessor();
102+
return _oat.Connected;
103+
}
104+
105+
public override void Disconnect()
106+
{
107+
Log.WriteLine("ASCOM: Stopping Jobs processor.");
108+
StopJobsProcessor();
109+
_oat.Connected = false;
110+
}
111+
112+
public override void DiscoverDeviceInstances(Action<string> addDevice)
113+
{
114+
addDevice("ASCOM: OpenAstroTracker");
115+
}
116+
117+
public override bool IsDriverForDevice(string device)
118+
{
119+
return device.StartsWith("ASCOM: ");
120+
}
121+
122+
public override bool SupportsSetupDialog
123+
{
124+
get
125+
{
126+
return true;
127+
}
128+
}
129+
130+
public override bool RunSetupDialog()
131+
{
132+
_oat = new ASCOM.DriverAccess.Telescope("ASCOM.OpenAstroTracker.Telescope");
133+
_oat.SetupDialog();
134+
_oat.Dispose();
135+
_oat = null;
136+
return true;
137+
}
138+
139+
public override ICommunicationHandler CreateHandler(string device)
140+
{
141+
var regex = new System.Text.RegularExpressions.Regex(@"([A-z]+:\s*)([A-z]+)@?(\d+)?");
142+
var result = regex.Match(device);
143+
if (result.Success)
144+
{
145+
device = result.Groups[2].Value;
146+
}
147+
return new ASCOMCommunicationHandler(device);
148+
}
149+
}
150+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>OATCommunications.ASCOM</RootNamespace>
10+
<AssemblyName>OATCommunications.ASCOM</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<Deterministic>true</Deterministic>
14+
<ProjectGuid>{9DA34FCF-6464-491C-88B1-7726454A1183}</ProjectGuid>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="ASCOM.DeviceInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
35+
<Reference Include="ASCOM.DriverAccess, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
36+
<Reference Include="ASCOM.Exceptions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
37+
<Reference Include="ASCOM.Utilities, Version=6.0.0.0, Culture=neutral, PublicKeyToken=565de7938946fba7, processorArchitecture=MSIL" />
38+
<Reference Include="System" />
39+
<Reference Include="System.Core" />
40+
<Reference Include="System.Xml.Linq" />
41+
<Reference Include="System.Data.DataSetExtensions" />
42+
<Reference Include="Microsoft.CSharp" />
43+
<Reference Include="System.Data" />
44+
<Reference Include="System.Net.Http" />
45+
<Reference Include="System.Xml" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<Compile Include="CommunicationHandlers\ASCOMCommunicationHandler.cs" />
49+
<Compile Include="Properties\AssemblyInfo.cs" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<ProjectReference Include="..\OATCommunications\OATCommunications.csproj">
53+
<Project>{83ca4f93-43ce-4da1-839a-f65f51fc34ed}</Project>
54+
<Name>OATCommunications</Name>
55+
</ProjectReference>
56+
</ItemGroup>
57+
<ItemGroup />
58+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
59+
<PropertyGroup>
60+
<PostBuildEvent>copy $(TargetPath) $(SolutionDir)$(OutDir)</PostBuildEvent>
61+
</PropertyGroup>
62+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("OATCommunications.ASCOM")]
9+
[assembly: AssemblyDescription("COmmunications layer for OATControl using ASCOM")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("OATCommunications.ASCOM")]
13+
[assembly: AssemblyCopyright("Copyright © 2021 by OpenAstroTech")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("44274117-6ef7-42a7-88ca-0111d417f6d6")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)