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')
print(ws.toXML())

Attributes

For inherited attributes see autosar.element.Element.

Name Type Description
category str Application data type mappings
size None or int type size in bits
typeEncoding None or str Optional type encoding
nativeDeclaration None or str Optional native declaration type name

Attribute Defaults

Name Default Value
category “FIXED_LENGTH”
size None
typeEncoding None
nativeDeclaration None