Getting Started

Installation

Installing the cfile package

First install the cfile package.

PIP Install

pip3 install cfile

Manual Install

Download latest release from the cfile Github page.

Unzip the release then install using setuptools.

Linux (shell):
python3 setup.py install

Windows (PowerShell):
python setup.py install

Installing the autosar package

PIP Install

The autosar package is not yet available on PyPI.

Manual Install

Download latest release from the autosar Github page.

Unzip the release then install using setuptools.

Linux (shell):
python3 setup.py install

Windows (PowerShell):
python setup.py install

Running Unit Tests

In case you want to run unit tests you can use the convenience shell scripts to trigger Python to run test cases.

Linux (shell):
./run_tests.sh

Windows (PowerShell):
.\run_tests.cmd

Writing your first script

The primary purpose of the Python AUTOSAR package is to programmatically create AUTOSAR XML files or ARXML for short.

Below is a simple example you can use to see if your installation works as expected.

import autosar

ws = autosar.workspace(version="4.2.2")
package=ws.createPackage('DataTypes')
baseTypes = package.createSubPackage('BaseTypes')
BaseTypeUint8 = baseTypes.createSwBaseType('uint8', 8, nativeDeclaration='uint8')
implTypes = package.createSubPackage('ImplementationTypes', role='DataType')
implTypes.createSubPackage('CompuMethods', role='CompuMethod')
implTypes.createSubPackage('DataConstrs', role='DataConstraint')
implTypes.createImplementationDataType('uint8', BaseTypeUint8.ref, 0, 255)
ws.saveXML('DataTypes.arxml')

Here is what the script does:

If you are new to the AUTOSAR Python package you should continue by reading more about Basic Concepts.