[go: nahoru, domu]

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

Add support for ARXML version 3 #262

Merged
merged 2 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
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
Prev Previous commit
ARXML: Add support for the XML namespace used by Daimler for ARXML3
  • Loading branch information
andlaus committed Feb 1, 2021
commit 7f088f3b29a13de78f219d66fc2bf604e0fee2e1
10 changes: 8 additions & 2 deletions cantools/database/can/formats/arxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ def __init__(self, root, strict):
# AUTOSAR 3
autosar_version_string = m.group(1)
else:
raise ValueError(f"Unrecognized AUTOSAR XML namespace '{xml_namespace}'")
m = re.match('^http://autosar\.org/([0-9.]*)\.DAI\.[0-9]$', xml_namespace)
if m:
# Daimler (for some model ranges)
autosar_version_string = m.group(1)
else:
raise ValueError(f"Unrecognized AUTOSAR XML namespace '{xml_namespace}'")

m = re.match('^([0-9]*)(\.[0-9]*)?(\.[0-9]*)?$', autosar_version_string)
if not m:
Expand Down Expand Up @@ -1299,7 +1304,8 @@ def load_string(string, strict=True):
# Should be replaced with a validation using the XSD file.
recognized_namespace = False
if re.match("http://autosar.org/schema/r(4.*)", xml_namespace) \
or re.match("http://autosar.org/(3.*)", xml_namespace):
or re.match("http://autosar.org/(3.*)", xml_namespace) \
or re.match("http://autosar.org/(.*)\.DAI\.[0-9]", xml_namespace):
recognized_namespace = True

if not recognized_namespace:
Expand Down
5 changes: 5 additions & 0 deletions tests/files/arxml/system-DAI-3.1.2.arxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<AUTOSAR xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://autosar.org/3.1.2.DAI.2" xsi:schemaLocation="http://autosar.org/3.1.2.DAI.2 AUTOSAR_312_DAI2.xsd">
<TOP-LEVEL-PACKAGES>
</TOP-LEVEL-PACKAGES>
</AUTOSAR>
3 changes: 3 additions & 0 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -4304,6 +4304,9 @@ def test_arxml_version(self):
self.assertEqual(loader.autosar_version_newer(4,2,1), True)
self.assertEqual(loader.autosar_version_newer(4,2,2), False)

def test_DAI_namespace(self):
db = cantools.db.load_file('tests/files/arxml/system-DAI-3.1.2.arxml')

def test_system_3_arxml(self):
db = cantools.db.load_file('tests/files/arxml/system-3.2.3.arxml')

Expand Down