Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GRPKEY cluster in PICSGenerator #33963

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 43 additions & 20 deletions src/tools/PICS-generator/PICSGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def GenerateDevicePicsXmlFiles(clusterName, clusterPicsCode, featurePicsList, at
elif "Group Key Management" == clusterName:
clusterName = "Group Communication"

tcarmelveilleux marked this conversation as resolved.
Show resolved Hide resolved
elif "GroupKeyManagement" == clusterName:
clusterName = "Group Communication"

elif "Wake On LAN" == clusterName or "Low Power" == clusterName:
clusterName = "Media Cluster"

Expand Down Expand Up @@ -86,7 +89,8 @@ def GenerateDevicePicsXmlFiles(clusterName, clusterPicsCode, featurePicsList, at
fileName = file
break
else:
console.print(f"[red]Could not find matching file for \"{clusterName}\" ❌")
console.print(
f"[red]Could not find matching file for \"{clusterName}\" ❌")
return

try:
Expand Down Expand Up @@ -134,7 +138,8 @@ def GenerateDevicePicsXmlFiles(clusterName, clusterPicsCode, featurePicsList, at
# Attributes PICS
# TODO: Only check if list is not empty
# console.print(attributePicsList)
serverAttributesNode = root.find("./clusterSide[@type='Server']/attributes")
serverAttributesNode = root.find(
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
"./clusterSide[@type='Server']/attributes")
if serverAttributesNode is not None:
for picsItem in serverAttributesNode:
itemNumberElement = picsItem.find('itemNumber')
Expand All @@ -149,30 +154,34 @@ def GenerateDevicePicsXmlFiles(clusterName, clusterPicsCode, featurePicsList, at
# AcceptedCommandList PICS
# TODO: Only check if list is not empty
# console.print(acceptedCommandPicsList)
serverCommandsReceivedNode = root.find("./clusterSide[@type='Server']/commandsReceived")
serverCommandsReceivedNode = root.find(
"./clusterSide[@type='Server']/commandsReceived")
if serverCommandsReceivedNode is not None:
for picsItem in serverCommandsReceivedNode:
itemNumberElement = picsItem.find('itemNumber')

console.print(f"Searching for {itemNumberElement.text}")

if f"{itemNumberElement.text}" in acceptedCommandPicsList:
console.print("Found acceptedCommand PICS value in XML template ✅")
console.print(
"Found acceptedCommand PICS value in XML template ✅")
supportElement = picsItem.find('support')
supportElement.text = "true"

# GeneratedCommandList PICS
# console.print(generatedCommandPicsList)
# TODO: Only check if list is not empty
serverCommandsGeneratedNode = root.find("./clusterSide[@type='Server']/commandsGenerated")
serverCommandsGeneratedNode = root.find(
"./clusterSide[@type='Server']/commandsGenerated")
if serverCommandsGeneratedNode is not None:
for picsItem in serverCommandsGeneratedNode:
itemNumberElement = picsItem.find('itemNumber')

console.print(f"Searching for {itemNumberElement.text}")

if f"{itemNumberElement.text}" in generatedCommandPicsList:
console.print("Found generatedCommand PICS value in XML template ✅")
console.print(
"Found generatedCommand PICS value in XML template ✅")
supportElement = picsItem.find('support')
supportElement.text = "true"

Expand All @@ -191,10 +200,12 @@ def GenerateDevicePicsXmlFiles(clusterName, clusterPicsCode, featurePicsList, at

try:
condition = statusElement.attrib['cond']
console.print(f"Checking {itemNumberElement.text} with conformance {statusElement.text} and condition {condition}")
console.print(
f"Checking {itemNumberElement.text} with conformance {statusElement.text} and condition {condition}")
except ET.ParseError:
condition = ""
console.print(f"Checking {itemNumberElement.text} with conformance {statusElement.text}")
console.print(
f"Checking {itemNumberElement.text} with conformance {statusElement.text}")

if statusElement.text == "M":

Expand Down Expand Up @@ -275,13 +286,16 @@ async def DeviceMapping(devCtrl, nodeID, outputPathStr):
clusterID = f"0x{server:04x}"

if server > 0x7FFF:
console.print(f"[red]Cluster outside standard range ({clusterID}) not handled! ❌")
console.print(
f"[red]Cluster outside standard range ({clusterID}) not handled! ❌")
continue

try:
clusterClass = getattr(Clusters, devCtrl.GetClusterHandler().GetClusterInfoById(server)['clusterName'])
clusterClass = getattr(Clusters, devCtrl.GetClusterHandler(
).GetClusterInfoById(server)['clusterName'])
except AttributeError:
console.print(f"[red]Cluster class not found for ({clusterID}) not found! ❌")
console.print(
f"[red]Cluster class not found for ({clusterID}) not found! ❌")
continue

# Does the the DM XML contain the found cluster ID?
Expand All @@ -290,7 +304,8 @@ async def DeviceMapping(devCtrl, nodeID, outputPathStr):
clusterPICS = f"{xml_clusters[server].pics}{serverTag}"

except KeyError:
console.print(f"[red]Cluster ({clusterID}) not found in DM XML! ❌")
console.print(
f"[red]Cluster ({clusterID}) not found in DM XML! ❌")
continue

console.print(f"{clusterName} - {clusterPICS}")
Expand All @@ -304,7 +319,8 @@ async def DeviceMapping(devCtrl, nodeID, outputPathStr):
for bitLocation in range(len(featureMapBitString)):
if featureMapValue >> bitLocation & 1 == 1:
# console.print(f"{clusterPICS}{featureTag}{bitLocation:02x}")
featurePicsList.append(f"{clusterPICS}{featureTag}{bitLocation:02x}")
featurePicsList.append(
f"{clusterPICS}{featureTag}{bitLocation:02x}")

console.print("Collected feature PICS:")
console.print(featurePicsList)
Expand All @@ -318,7 +334,8 @@ async def DeviceMapping(devCtrl, nodeID, outputPathStr):
for attribute in attributeList:
if (attribute != 0xfff8 and attribute != 0xfff9 and attribute != 0xfffa and attribute != 0xfffb and attribute != 0xfffc and attribute != 0xfffd):
# console.print(f"{clusterPICS}{attributeTag}{attribute:04x}")
attributePicsList.append(f"{clusterPICS}{attributeTag}{attribute:04x}")
attributePicsList.append(
f"{clusterPICS}{attributeTag}{attribute:04x}")
'''
else:
console.print(f"[yellow]Ignore global attribute 0x{attribute:04x}")
Expand All @@ -329,26 +346,30 @@ async def DeviceMapping(devCtrl, nodeID, outputPathStr):

# Read AcceptedCommandList
acceptedCommandListResponse = await devCtrl.ReadAttribute(nodeID, [(endpoint, clusterClass.Attributes.AcceptedCommandList)])
acceptedCommandList = acceptedCommandListResponse[endpoint][clusterClass][clusterClass.Attributes.AcceptedCommandList]
acceptedCommandList = acceptedCommandListResponse[endpoint][
clusterClass][clusterClass.Attributes.AcceptedCommandList]
# console.print(f"AcceptedCommandList: {acceptedCommandList}")

# Convert accepted command to PICS code
for acceptedCommand in acceptedCommandList:
# console.print(f"{clusterPICS}{commandTag}{acceptedCommand:02x}{acceptedCommandTag}")
acceptedCommandListPicsList.append(f"{clusterPICS}{commandTag}{acceptedCommand:02x}{acceptedCommandTag}")
acceptedCommandListPicsList.append(
f"{clusterPICS}{commandTag}{acceptedCommand:02x}{acceptedCommandTag}")

console.print("Collected accepted command PICS:")
console.print(acceptedCommandListPicsList)

# Read GeneratedCommandList
generatedCommandListResponse = await devCtrl.ReadAttribute(nodeID, [(endpoint, clusterClass.Attributes.GeneratedCommandList)])
generatedCommandList = generatedCommandListResponse[endpoint][clusterClass][clusterClass.Attributes.GeneratedCommandList]
generatedCommandList = generatedCommandListResponse[endpoint][
clusterClass][clusterClass.Attributes.GeneratedCommandList]
# console.print(f"GeneratedCommandList: {generatedCommandList}")

# Convert accepted command to PICS code
for generatedCommand in generatedCommandList:
# console.print(f"{clusterPICS}{commandTag}{generatedCommand:02x}{generatedCommandTag}")
generatedCommandListPicsList.append(f"{clusterPICS}{commandTag}{generatedCommand:02x}{generatedCommandTag}")
generatedCommandListPicsList.append(
f"{clusterPICS}{commandTag}{generatedCommand:02x}{generatedCommandTag}")

console.print("Collected generated command PICS:")
console.print(generatedCommandListPicsList)
Expand All @@ -369,12 +390,14 @@ async def DeviceMapping(devCtrl, nodeID, outputPathStr):
clusterPICS = f"{xml_clusters[client].pics}{clientTag}"

except KeyError:
console.print(f"[red]Cluster ({clusterID}) not found in DM XML! ❌")
console.print(
f"[red]Cluster ({clusterID}) not found in DM XML! ❌")
continue

console.print(f"{clusterName} - {clusterPICS}")

GenerateDevicePicsXmlFiles(clusterName, clusterPICS, [], [], [], [], endpointOutputPathStr)
GenerateDevicePicsXmlFiles(
clusterName, clusterPICS, [], [], [], [], endpointOutputPathStr)


def cleanDirectory(pathToClean):
Expand Down
Loading