SwBaseType

XML tag

<SW-BASE-TYPE>

Module

autosar.datatype

Inherits

autosar.element.Element

The SwBaseType is the lowest level of the AUTOSAR 4 type system. It defines a type in terms of bits and bytes. All other data types eventually end up being defined by a base type.

Usage

import autosar

ws = autosar.workspace("4.2.2")
package = ws.createPackage('AUTOSAR_Platform')
baseTypes = package.createSubPackage('BaseTypes')
baseTypes.createSwBaseType('dtRef_const_VOID', 1, encoding = 'VOID', nativeDeclaration = 'void')
baseTypes.createSwBaseType('dtRef_VOID', 1, encoding = 'VOID', nativeDeclaration = 'void')
baseTypes.createSwBaseType('boolean', 8, encoding = 'BOOLEAN', nativeDeclaration='boolean')
baseTypes.createSwBaseType('float32', 32, encoding = 'IEEE754', nativeDeclaration = 'float32')
baseTypes.createSwBaseType('float64', 64, encoding = 'IEEE754', nativeDeclaration = 'float64')
baseTypes.createSwBaseType('sint8', 8, encoding = '2C', nativeDeclaration='sint8')
baseTypes.createSwBaseType('sint16', 16, encoding = '2C', nativeDeclaration='uint16')
baseTypes.createSwBaseType('sint32', 32, encoding = '2C', nativeDeclaration='sint32')
baseTypes.createSwBaseType('uint8', 8, nativeDeclaration='uint8')
baseTypes.createSwBaseType('uint16', 16, nativeDeclaration='uint16')
baseTypes.createSwBaseType('uint32', 32, nativeDeclaration='uint32')
ws.saveXML('AUTOSAR_Platform.arxml', filters=['/AUTOSAR_Platform'])

Factory Methods

Constructor

datatype.SwBaseType(name[, size = None][, typeEncoding = None][, nativeDeclaration = None][, category = 'FIXED_LENGTH'][, parent = None][, adminData = None])
参数
  • name (str) – Short name.

  • size (None, int) – Type size in bits.

  • typeEncoding (None, str) – Type encoding (e.g. “2C” for Two’s-complement encoding).

  • nativeDeclaration – Native declaration (name of type in C programming language).

  • category (None, str) – Category string.

  • parent (Package) – parent package.

  • adminData (None, AdminData.) – Optional AdminData.

Attributes

For inherited attributes see autosar.element.Element.

Name

Type

Description

nativeDeclaration

None, str

<NATIVE-DECLARATION>

size

None, int

<BASE-TYPE-SIZE>

typeEncoding

None, str

<BASE-TYPE-ENCODING>