mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
Fixed startup crash when device has out-of-range com port
This commit is contained in:
@@ -26,12 +26,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
public ComPortController(string key, ComPort port, ComPort.ComPortSpec spec)
|
public ComPortController(string key, ComPort port, ComPort.ComPortSpec spec)
|
||||||
: base(key)
|
: base(key)
|
||||||
{
|
{
|
||||||
|
if (port == null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, "ERROR: Invalid com port, continuing but comms will not function");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Port = port;
|
Port = port;
|
||||||
Spec = spec;
|
Spec = spec;
|
||||||
//IsConnected = new BoolFeedback(CommonBoolCue.IsConnected, () => true);
|
//IsConnected = new BoolFeedback(CommonBoolCue.IsConnected, () => true);
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@@ -80,11 +88,15 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void SendText(string text)
|
public void SendText(string text)
|
||||||
{
|
{
|
||||||
|
if (Port == null)
|
||||||
|
return;
|
||||||
Port.Send(text);
|
Port.Send(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendBytes(byte[] bytes)
|
public void SendBytes(byte[] bytes)
|
||||||
{
|
{
|
||||||
|
if (Port == null)
|
||||||
|
return;
|
||||||
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
var text = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
||||||
Port.Send(text);
|
Port.Send(text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
[JsonProperty("info")]
|
[JsonProperty("info")]
|
||||||
public InfoConfig Info { get; set; }
|
public InfoConfig Info { get; set; }
|
||||||
|
|
||||||
//[JsonProperty("roomLists")]
|
|
||||||
//public Dictionary<string, List<string>> RoomLists { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty("devices")]
|
[JsonProperty("devices")]
|
||||||
public List<DeviceConfig> Devices { get; set; }
|
public List<DeviceConfig> Devices { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
//public CotijaConfig Cotija { get; private set; }
|
//public CotijaConfig Cotija { get; private set; }
|
||||||
|
|
||||||
public string SystemUuid
|
[JsonProperty("templateUuid")]
|
||||||
|
public string SystemUuid
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -37,7 +38,8 @@ namespace PepperDash.Essentials
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TemplateUuid
|
[JsonProperty("systemUuid")]
|
||||||
|
public string TemplateUuid
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,10 +32,6 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void InitializeSystem()
|
public override void InitializeSystem()
|
||||||
{
|
{
|
||||||
//CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Reloads configuration file",
|
|
||||||
// ConsoleAccessLevelEnum.AccessOperator);
|
|
||||||
//CrestronConsole.AddNewConsoleCommand(s => TearDown(), "ungo", "Unloads configuration file",
|
|
||||||
// ConsoleAccessLevelEnum.AccessOperator);
|
|
||||||
CrestronConsole.AddNewConsoleCommand(s =>
|
CrestronConsole.AddNewConsoleCommand(s =>
|
||||||
{
|
{
|
||||||
foreach (var tl in TieLineCollection.Default)
|
foreach (var tl in TieLineCollection.Default)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user