mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
feat: enhance ComPortController with detailed logging on configuration changes
This commit is contained in:
@@ -8,6 +8,7 @@ using Crestron.SimplSharpPro;
|
|||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
|
using PepperDash.Core.Logging;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -71,23 +72,39 @@ namespace PepperDash.Essentials.Core
|
|||||||
Debug.LogMessage(LogEventLevel.Information, this, "Configured com Port for this device does not exist.");
|
Debug.LogMessage(LogEventLevel.Information, this, "Configured com Port for this device does not exist.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Port.Parent is CrestronControlSystem)
|
if (Port.Parent is CrestronControlSystem)
|
||||||
{
|
{
|
||||||
var result = Port.Register();
|
var result = Port.Register();
|
||||||
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
|
if (result != eDeviceRegistrationUnRegistrationResponse.Success)
|
||||||
{
|
{
|
||||||
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Com port: {0}", result);
|
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Cannot register Com port: {0}", result);
|
||||||
return; // false
|
return; // false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var specResult = Port.SetComPortSpec(Spec);
|
Port.PropertyChanged += (s, e) =>
|
||||||
if (specResult != 0)
|
{
|
||||||
{
|
this.LogInformation($"RegisterAndConfigureComPort: PropertyChanged Fired >> comPort-'{Port.ID}', Property Changed-'{e.Property}', Value Changed-'{e.Value}'");
|
||||||
Debug.LogMessage(LogEventLevel.Information, this, "WARNING: Cannot set comspec");
|
this.LogInformation($"RegisterAndConfigureComPort: deviceName-'{Port.DeviceName}', parentDevice-'{Port.ParentDevice}', parent-`{Port.Parent}`, online-`{Port.IsOnline}`, preset-`{Port.Present}`, supportedBaudRates-'{Port.SupportedBaudRates}'");
|
||||||
return;
|
};
|
||||||
}
|
Port.ExtendedInformationChanged += (s, e) =>
|
||||||
Port.SerialDataReceived += Port_SerialDataReceived;
|
{
|
||||||
|
this.LogInformation($"RegisterAndConfigureComPort: ExtendedInformationChanged Fired >> comPort-'{Port.ID}', {e.Protocol} using {e.BaudRate},{e.Parity},{e.DataBits},{e.StopBits}, HW Handshake-'{e.HardwareHandshakeSetting}', SW Handshake-'{e.SoftwareHandshakeSetting}'");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.LogInformation($"RegisterAndConfigureComPort: Configuring comPort-'{Port.ID}' using Spec {Spec.BaudRate},{Spec.DataBits},{Spec.Parity},{Spec.StopBits}, HW Handshake-'{Spec.HardwareHandShake}', SW Handshake-'{Spec.SoftwareHandshake}'");
|
||||||
|
|
||||||
|
var specResult = Port.SetComPortSpec(Spec);
|
||||||
|
if (specResult != 0)
|
||||||
|
{
|
||||||
|
Debug.LogMessage(LogEventLevel.Information, this, "WARNING: Cannot set comspec");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.LogInformation($"RegisterAndConfigureComPort: comPort-'{Port.ID}' configured successfully using {Port.BaudRate},{Port.DataBits},{Port.Parity},{Port.StopBits}, HW Handshake-'{Port.HwHandShake}', SW Handshake-'{Port.SwHandShake}'");
|
||||||
|
|
||||||
|
Port.SerialDataReceived += Port_SerialDataReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ComPortController()
|
~ComPortController()
|
||||||
|
|||||||
Reference in New Issue
Block a user