Skip to content

Commit b2f40eb

Browse files
OATControl V0.9.4.0 Updates
- Configured Serial port correctly (e.g. Baudrate, timeouts...) - Better handling of connection (connect failure, disconnect)
1 parent 636e290 commit b2f40eb

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

Software/OpenAstroTracker ASCOM/OATCommuncations.WPF/CommunicationHandlers/SerialCommunicationHandler.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public SerialCommunicationHandler(string comPort)
1616
{
1717
_portName = comPort;
1818
_port = new SerialPort(comPort);
19+
_port.BaudRate = 57600;
20+
_port.DtrEnable = false;
21+
_port.ReadTimeout = 250;
22+
_port.WriteTimeout = 250;
1923
}
2024

2125
public bool Connected => _port.IsOpen;
@@ -50,9 +54,9 @@ public async Task<CommandResponse> SendCommand(string command, bool needsRespons
5054
var response = _port.ReadTo("#");
5155
return new CommandResponse(response, true);
5256
}
53-
catch
57+
catch (Exception ex)
5458
{
55-
return new CommandResponse(string.Empty, false, $"Unable to read response to {command} from {_portName}");
59+
return new CommandResponse(string.Empty, false, $"Unable to read response to {command} from {_portName}. {ex.Message}");
5660
}
5761
}
5862
return new CommandResponse(string.Empty, true);
@@ -87,6 +91,7 @@ public void Disconnect()
8791
if (_port.IsOpen)
8892
{
8993
_port.Close();
94+
_port = null;
9095
}
9196
}
9297

Software/OpenAstroTracker ASCOM/OATControl/DlgChooseOat.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
Title="Connect to OpenAstroTracker" Height="312.39" Width="359.862" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow">
1010
<Controls:MetroWindow.Resources>
1111
<Style x:Key="ListItemsStyle" TargetType="ListBoxItem">
12-
<Setter Property="Margin" Value="5,3,5,1" />
13-
<Setter Property="Padding" Value="3" />
12+
<Setter Property="Margin" Value="10,3,5,1" />
13+
<Setter Property="Padding" Value="6,3" />
1414
<Setter Property="BorderThickness" Value="1" />
1515
<Setter Property="BorderBrush" Value="{StaticResource AccentBaseColorBrush}" />
1616
<Setter Property="Background" Value="{StaticResource AccentColorBrush2}" />

Software/OpenAstroTracker ASCOM/OATControl/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("0.9.3.0")]
54+
[assembly: AssemblyVersion("0.9.4.0")]
5555
[assembly: AssemblyFileVersion("1.0.0.0")]

Software/OpenAstroTracker ASCOM/OATControl/ViewModels/MountVM.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ private async void OnConnectToTelescope()
370370
//await +.WaitAsync();
371371

372372
var result = await _oatMount.SendCommand("GVP#,#");
373+
if (!result.Success)
374+
{
375+
throw new AccessViolationException("Cannot connect. " + result.StatusMessage);
376+
}
373377
var resultNr = await _oatMount.SendCommand("GVN#,#");
374378
ScopeName = $"{result.Data} {resultNr.Data}";
375379

0 commit comments

Comments
 (0)