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

Update PICS Generator tool #37901

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 7 additions & 2 deletions src/tools/PICS-generator/PICSGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions src/tools/PICS-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ If a device has already been commissioned, the tool can be executed like this:
python3 PICSGenerator.py --pics-template <pathToPicsTemplateFolder> --pics-output <outputPath>
```

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 <pathToPicsTemplateFolder> --dm <pathToDmScrapeFolder>
```

# Updates for future releases

Given each new release adds PICS files, to ensure the tool is able to map the
Expand All @@ -102,3 +111,12 @@ To run the XMLPICSValidator, the following command can be used:
```
python3 XMLPICSValidator.py --pics-template <pathToPicsTemplateFolder>
```

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 <pathToPicsTemplateFolder> --dm <pathToDmScrapeFolder>
```
10 changes: 8 additions & 2 deletions src/tools/PICS-generator/XMLPICSValidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
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
Expand All @@ -35,7 +37,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)
Expand Down
1 change: 1 addition & 0 deletions src/tools/PICS-generator/pics_generator_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading