cogu / autosar

A set of python modules for working with AUTOSAR XML files
MIT License
353 stars 160 forks source link

Load or create element ECUC-MODULE-CONFIGURATION-VALUES (DCM) #66

Closed wallem89 closed 4 years ago

wallem89 commented 4 years ago

I want to read an existing element: ECUC-MODULE-CONFIGURATION-VALUES with the SHORT-NAME Dcm but it gives the following error: [PackageParser] unhandled: ECUC-MODULE-CONFIGURATION-VALUES. Does this means this is not supported?

Code snip:

ws = autosar.workspace()
ws.openXML("Dcm.arxml")
ws.loadPackage('shortNameOfPackage')

I also want to be able to create the ECUC-MODULE-CONFIGURATION-VALUES myself but I also don't see this in the documentation.

Test arxml "Dcm.arxml":

<?xml version="1.0" encoding="utf-8"?>
<AUTOSAR xmlns="http://autosar.org/schema/r4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://autosar.org/schema/r4.0 AUTOSAR_4-0-3.xsd">
  <AR-PACKAGES>
    <AR-PACKAGE>
      <SHORT-NAME>shortNameOfPackage</SHORT-NAME>
      <ELEMENTS>
        <ECUC-MODULE-CONFIGURATION-VALUES UUID="8e3b6bec-9cd0-4347-b931-ef4a8b022f21">
          <SHORT-NAME>Dcm</SHORT-NAME>
          <ADMIN-DATA>
          </ADMIN-DATA>
          <DEFINITION-REF DEST="ECUC-MODULE-DEF">/EcucDefs/Generic/Dcm</DEFINITION-REF>
          <IMPLEMENTATION-CONFIG-VARIANT>VARIANT-PRE-COMPILE</IMPLEMENTATION-CONFIG-VARIANT>
          <MODULE-DESCRIPTION-REF DEST="BSW-IMPLEMENTATION">/EcucDefs/Generic/Implementations/Dcm</MODULE-DESCRIPTION-REF>
          <CONTAINERS>
          </CONTAINERS>
        </ECUC-MODULE-CONFIGURATION-VALUES>
      </ELEMENTS>
    </AR-PACKAGE>
  </AR-PACKAGES>
</AUTOSAR>
cogu commented 4 years ago

The Python package supports working with the creation of AUTOSAR SWCs and things related to it meaning the part of AUTOSAR which is generally above the RTE. Things below the RTE such as configuration of BSW components are not supported.

However, the Python package does allow anyone to write their own ARXML parsers and writers and plugging them into Python. Please see the methods _registerDefaultElementParsers and _registerDefaultElementWriters in the file workspace.py for examples of how the default parsers and writers registers themselves into the workspace. This registration mechanism is unfortunately not yet documented.

wallem89 commented 4 years ago

Thanks for the quick reply @cogu.

I didn't think about the difference between arxml files of AUTOSAR SWCs and BsW components.

I will have a look at your undocumented code and see if this can help!