Skip to content

Commit

Permalink
Fix exception on writing Last COM Port setting to ASCOM profile (#19)
Browse files Browse the repository at this point in the history
Writing the "Last COM Port" value to the ASCOM profile of the focuser
throws an exception, because the device type of the profile has not been
set to "Focuser", so it is "Telescope" by default.

This means that if auto-detecting the COM port is off in the focuser
app, the connection always fails.

The device type was being set inside an "if" clause in the code, meaning
it was never being set in the non-auto-detecting case.
  • Loading branch information
naavis authored Sep 18, 2024
1 parent 5aaf1a2 commit 801e2d3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions ASCOM_Driver/FocuserDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,14 @@ public bool Connected

Debug.Assert(objSerial == null);

using (Profile driverProfile = new Profile())
using (Profile driverProfile = new Profile() { DeviceType = "Focuser" })
{
Serial serial = null;

var comPorts = new List<string>(System.IO.Ports.SerialPort.GetPortNames());

if (autoDetectComPort)
{
driverProfile.DeviceType = "Focuser";

// See if the last successfully connected COM port can be used first...
// This is a performance optimization that significantly reduces the time it takes to connect!
string lastComPort = driverProfile.GetValue(driverID, lastComPortProfileName, string.Empty, string.Empty);
Expand Down

0 comments on commit 801e2d3

Please sign in to comment.