|
1 | 1 | using System; |
2 | 2 | using System.Text; |
3 | 3 | using System.Text.RegularExpressions; |
| 4 | +using Crestron.SimplSharp; |
4 | 5 | using Crestron.SimplSharpPro; |
| 6 | +using Crestron.SimplSharpPro.GeneralIO; |
5 | 7 | using PepperDash.Core; |
6 | 8 | using PepperDash.Core.Logging; |
7 | 9 | using Serilog.Events; |
@@ -85,36 +87,32 @@ private void RegisterAndConfigureComPort() |
85 | 87 | { |
86 | 88 | if (Port == null) |
87 | 89 | { |
88 | | - Debug.LogMessage(LogEventLevel.Information, this, "Configured com Port for this device does not exist."); |
| 90 | + this.LogInformation($"Configured {Port.Parent.GetType().Name}-comport-{Port.ID} for {Key} does not exist."); |
89 | 91 | return; |
90 | 92 | } |
91 | | - // TODO [ ] - Remove commented out code once verified working |
92 | | - //if (Port.Parent is CrestronControlSystem || Port.Parent is CenIoCom102) |
93 | | - if (Port.Parent is GenericBase genericDevice && genericDevice.Registerable) |
| 93 | + |
| 94 | + var result = Port.Register(); |
| 95 | + if (result != eDeviceRegistrationUnRegistrationResponse.Success) |
94 | 96 | { |
95 | | - //this.LogInformation($"INFO: Attempting to register {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID}"); |
96 | | - var result = genericDevice.Register(); |
97 | | - if (result != eDeviceRegistrationUnRegistrationResponse.Success) |
98 | | - { |
99 | | - this.LogError($"ERROR: Cannot register {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {result})"); |
100 | | - return; // false |
101 | | - } |
| 97 | + this.LogError($"Cannot register {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {result})"); |
| 98 | + return; |
102 | 99 | } |
| 100 | + this.LogInformation($"Successfully registered {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {result})"); |
103 | 101 |
|
104 | 102 | var specResult = Port.SetComPortSpec(Spec); |
105 | 103 | if (specResult != 0) |
106 | 104 | { |
107 | | - this.LogError($"ERROR: Cannot set comspec for {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {specResult})"); |
| 105 | + this.LogError($"Cannot set comspec for {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {specResult})"); |
108 | 106 | return; |
109 | 107 | } |
110 | | - //this.LogInformation($"INFO: Successfully set comspec for {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {specResult})"); |
| 108 | + this.LogInformation($"Successfully set comspec for {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {specResult})"); |
111 | 109 |
|
112 | 110 |
|
113 | 111 | // TODO [ ] - Remove debug logging once verified working |
114 | 112 | // if (Port.Parent is CenIoCom102) |
115 | | - // { |
| 113 | + // { |
116 | 114 | // Port.PropertyChanged += (s, e) => |
117 | | - // { |
| 115 | + // { |
118 | 116 | // this.LogInformation($@"RegisterAndConfigureComPort: PropertyChanged Fired >> |
119 | 117 | // comPort-'{Port.ID}', |
120 | 118 | // Property Changed-'{e.Property}', |
|
0 commit comments