From 4a31fab35a05fc00cb0669311355a9d3bfb0c756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Josefsen?= Date: Thu, 6 Mar 2025 18:10:27 +0100 Subject: [PATCH 1/2] Add dm input tag to align with updated build_xml_clusters usage --- src/tools/PICS-generator/PICSGenerator.py | 9 +++++++-- src/tools/PICS-generator/README.md | 12 ++++++++++++ src/tools/PICS-generator/XMLPICSValidator.py | 11 ++++++++--- src/tools/PICS-generator/pics_generator_support.py | 1 + 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/tools/PICS-generator/PICSGenerator.py b/src/tools/PICS-generator/PICSGenerator.py index 6cfb95803af52b..3e2bbe52a18c31 100644 --- a/src/tools/PICS-generator/PICSGenerator.py +++ b/src/tools/PICS-generator/PICSGenerator.py @@ -20,6 +20,7 @@ import pathlib import sys import xml.etree.ElementTree as ET +from pathlib import Path import chip.clusters as Clusters from pics_generator_support import map_cluster_name_to_pics_xml, pics_xml_file_list_loader @@ -28,7 +29,7 @@ # Add the path to python_testing folder, in order to be able to import from chip.testing.matter_testing sys.path.append(os.path.abspath(sys.path[0] + "/../../python_testing")) from chip.testing.matter_testing import MatterBaseTest, async_test_body, default_matter_test_main # noqa: E402 -from chip.testing.spec_parsing import build_xml_clusters # noqa: E402 +from chip.testing.spec_parsing import PrebuiltDataModelDirectory, build_xml_clusters # noqa: E402 console = None xml_clusters = None @@ -360,6 +361,7 @@ def cleanDirectory(pathToClean): parser = argparse.ArgumentParser() parser.add_argument('--pics-template', required=True) parser.add_argument('--pics-output', required=True) +parser.add_argument('--dm-xml') args, unknown = parser.parse_known_args() xmlTemplatePathStr = args.pics_template @@ -414,7 +416,10 @@ async def test_device_mapping(self): console = Console() global xml_clusters - xml_clusters, problems = build_xml_clusters() + if args.dm_xml: + xml_clusters, problems = build_xml_clusters(Path(f"{args.dm_xml}/clusters")) + else: + xml_clusters, problems = build_xml_clusters(PrebuiltDataModelDirectory.kMaster) # Run device mapping function await DeviceMapping(self.default_controller, self.dut_node_id, outputPathStr) diff --git a/src/tools/PICS-generator/README.md b/src/tools/PICS-generator/README.md index 312d790ca3109b..c0769fcda136b4 100644 --- a/src/tools/PICS-generator/README.md +++ b/src/tools/PICS-generator/README.md @@ -86,6 +86,12 @@ If a device has already been commissioned, the tool can be executed like this: python3 PICSGenerator.py --pics-template --pics-output ``` +The tool can be used to validate against the available spec versions, this can be done by providing the following tag in the command, if no path is provided it will use the current scrape of Master. An example path is "connectedhomeip/data_model/master". + +``` +python3 PICSGenerator.py --pics-template --dm +``` + # Updates for future releases Given each new release adds PICS files, to ensure the tool is able to map the @@ -102,3 +108,9 @@ To run the XMLPICSValidator, the following command can be used: ``` python3 XMLPICSValidator.py --pics-template ``` + +The tool can be used to validate against the available spec versions, this can be done by providing the following tag in the command, if no path is provided it will use the current scrape of Master. An example path is "connectedhomeip/data_model/master". + +``` +python3 XMLPICSValidator.py --pics-template --dm +``` \ No newline at end of file diff --git a/src/tools/PICS-generator/XMLPICSValidator.py b/src/tools/PICS-generator/XMLPICSValidator.py index 5fd170463d3e7a..e22e15d62a10a0 100644 --- a/src/tools/PICS-generator/XMLPICSValidator.py +++ b/src/tools/PICS-generator/XMLPICSValidator.py @@ -18,15 +18,16 @@ import argparse import os import sys - +from pathlib import Path from pics_generator_support import map_cluster_name_to_pics_xml, pics_xml_file_list_loader # Add the path to python_testing folder, in order to be able to import from matter_testing_support sys.path.append(os.path.abspath(sys.path[0] + "/../../python_testing")) -from chip.testing.spec_parsing import build_xml_clusters # noqa: E402 +from chip.testing.spec_parsing import PrebuiltDataModelDirectory, build_xml_clusters # noqa: E402 parser = argparse.ArgumentParser() parser.add_argument('--pics-template', required=True) +parser.add_argument('--dm-xml') args, unknown = parser.parse_known_args() xml_template_path_str = args.pics_template @@ -35,7 +36,11 @@ pics_xml_file_list = pics_xml_file_list_loader(xml_template_path_str, True) print("Build list of spec XML") -xml_clusters, problems = build_xml_clusters() +if args.dm_xml: + xml_clusters, problems = build_xml_clusters(Path(f"{args.dm_xml}/clusters")) +else: + xml_clusters, problems = build_xml_clusters(PrebuiltDataModelDirectory.kMaster) + for cluster in xml_clusters: pics_xml_file_name = map_cluster_name_to_pics_xml(xml_clusters[cluster].name, pics_xml_file_list) diff --git a/src/tools/PICS-generator/pics_generator_support.py b/src/tools/PICS-generator/pics_generator_support.py index 53e0248842ff64..af585118eecedd 100644 --- a/src/tools/PICS-generator/pics_generator_support.py +++ b/src/tools/PICS-generator/pics_generator_support.py @@ -24,6 +24,7 @@ "OTA Software Update Requestor": "OTA Software Update", "On/Off": "On-Off", "GroupKeyManagement": "Group Communication", + "Wake On LAN": "Media Cluster", "Wake on LAN": "Media Cluster", "Low Power": "Media Cluster", "Keypad Input": "Media Cluster", From 13aa8137e2a09403ca97e8f577678992e5bf69bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Josefsen?= Date: Mon, 10 Mar 2025 23:24:10 +0100 Subject: [PATCH 2/2] Fix restyle issues --- src/tools/PICS-generator/README.md | 12 +++++++++--- src/tools/PICS-generator/XMLPICSValidator.py | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/tools/PICS-generator/README.md b/src/tools/PICS-generator/README.md index c0769fcda136b4..79579d5be2f4fb 100644 --- a/src/tools/PICS-generator/README.md +++ b/src/tools/PICS-generator/README.md @@ -86,7 +86,10 @@ If a device has already been commissioned, the tool can be executed like this: python3 PICSGenerator.py --pics-template --pics-output ``` -The tool can be used to validate against the available spec versions, this can be done by providing the following tag in the command, if no path is provided it will use the current scrape of Master. An example path is "connectedhomeip/data_model/master". +The tool can be used to validate against the available spec versions, this can +be done by providing the following tag in the command, if no path is provided it +will use the current scrape of Master. An example path is +"connectedhomeip/data_model/master". ``` python3 PICSGenerator.py --pics-template --dm @@ -109,8 +112,11 @@ To run the XMLPICSValidator, the following command can be used: python3 XMLPICSValidator.py --pics-template ``` -The tool can be used to validate against the available spec versions, this can be done by providing the following tag in the command, if no path is provided it will use the current scrape of Master. An example path is "connectedhomeip/data_model/master". +The tool can be used to validate against the available spec versions, this can +be done by providing the following tag in the command, if no path is provided it +will use the current scrape of Master. An example path is +"connectedhomeip/data_model/master". ``` python3 XMLPICSValidator.py --pics-template --dm -``` \ No newline at end of file +``` diff --git a/src/tools/PICS-generator/XMLPICSValidator.py b/src/tools/PICS-generator/XMLPICSValidator.py index e22e15d62a10a0..b3a98d67470a73 100644 --- a/src/tools/PICS-generator/XMLPICSValidator.py +++ b/src/tools/PICS-generator/XMLPICSValidator.py @@ -19,6 +19,7 @@ import os import sys from pathlib import Path + from pics_generator_support import map_cluster_name_to_pics_xml, pics_xml_file_list_loader # Add the path to python_testing folder, in order to be able to import from matter_testing_support