PepperDash / Essentials

The Essentials Application Framework Libraries
MIT License
133 stars 77 forks source link

Exception in DM bridge (post activate?) #37

Closed hvolmer closed 4 years ago

hvolmer commented 4 years ago

Troubleshooting with JD/JA: We're are getting a dictionary error in the LinkToApi in DmChassisControllerApiExtentions. When attaching a DMTX4k100C.

Line 143 (on my machine) dmChassis.InputCardHdcpCapabilityFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]);

I suspect that the InputCardHdcpCapabilityFeedbacks dictionary is not getting this TX slot added… Not sure really what to do with it.

Console (from JD)

[13:32:19.223]App 1:Setting up actions and feedbacks on input card 1
[13:32:19.230]App 1:Port is DMInputPortWithCec
System.Collections.Generic.KeyNotFoundException: KeyNotFoundExceptione:
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(UInt32 key)
   at PepperDash.Essentials.Bridges.DmChassisControllerApiExtentions.LinkToApi(DmChassisController dmChassis, BasicTriList trilist, UInt32 joinStart, String joinMapKey)
   at PepperDash.Essentials.Bridges.EiscApi.<.ctor>b__0()
   at PepperDash.Core.Device.<PostActivate>b__2(Action a)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at PepperDash.Core.Device.PostActivate()
   at PepperDash.Essentials.Core.DeviceManager.ActivateAll()
   at PepperDash.Essentials.ControlSystem.Load()
   at PepperDash.Essentials.ControlSystem.GoWithLoad()
   at PepperDash.Essentials.ControlSystem.InitializeSystem()
   at Crestron.SimplSharpPro.CrestronControlSystem.InitializeSimplSharpProApplication()
   at Crestron.SimplSharpProInternal.SimplSharpProManager.LoadSimplSharpProApplication(String moduleFileName)
   at Crestron.SimplSharpProInternal.SimplSharpProManager..ctor(UInt32 appNumber, String simplSharpProAppName, UInt32 flags, Boolean& badExit)
   at Crestron.SimplSharpProEntry.b(String[] A_0)
-------------------------------------------------------------
Program Initialized:01

By the way “Extentions" is misspelled on that class name, and the file it’s in is not consistent. Extensions.

Also, this method should probably be broken into many sub-methods.

This is breaking bridge post activation

jonnyarndt commented 4 years ago

Case & point: Project includes three DM-TX-4K-100-C-1G endpoints. One of the TX endpoints includes IR control of an Apple TV through the DM-TX.

bitm0de commented 4 years ago

Just looking quickly at this, I dug as far back as: public void AddInputCard(string type, uint number)

Are you sure the card is getting added to the correct input slot or the string 'type' exists in the branching within this function so that the dictionary contains the key? Am I looking in the wrong spot?

It appears the dictionary is populated by this method, so if the KeyNotFoundException is being thrown, it might not be adding a card to that slot in this section of logic.

ngenovese11 commented 4 years ago

You need the below object in the DM Chassis config to define whether the input slot supports HDCP2:

"inputSlotSupportsHdcp2": {
                        "1": false,
                        "2": false,
                        "3": true,
                        "4": true,
                        "5": true,
                        "6": true,
                        "7": false,
                        "8": false
                    }

The method was attempting to access the Dictionary PropertiesConfig.InputSlotSupportsHdcp2 and if you hadn't defined it in config it will throw an exception.

I have a fix that handles if this block is missing more elegantly and doesn't crash the process.

PR incoming

ngenovese11 commented 4 years ago

line 138 of DmChassisControllerBridge:

if (dmInPortWCec != null)
{
     SetHdcpStateAction(dmChassis.PropertiesConfig.InputSlotSupportsHdcp2[ioSlot], dmInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist);  
}

That dictionary is what was throwing the exception :)

ndorin commented 4 years ago

This is a duplicate of ECS-1255 (from JIRA) and will be resolved by a PR for bigfix/ecs-1255