/blog/images/avatar.webp

Hello World

AUTOSAR AP R2011 阅读指南

阅读 AUTOSAR Adaptive Platform (AP) 的官方文档,合适的方法和顺序至关重要。这份指南可以帮你理清头绪,高效入门。

📚 第一站:整体框架和设计哲学

  • AUTOSAR_EXP_PlatformDesign:阅读AP文档的极佳起点。它提供了AP设计的全局概览和所有关键概念,像一张“藏宝图”指引后续的深入方向。
  • AUTOSAR_EXP_SWArchitecture:详细拆解AP的软件架构。
  • AUTOSAR_TR_AdaptivePlatformReleaseOverview:对AP某个特定版本的“发行说明”,快速了解该版本包含的所有文档、功能和特性。
  • AUTOSAR_RS_Main:AUTOSAR的顶层“总纲”文档,读起来会比较枯燥,建议在建立框架后略读,了解顶层需求。

🧭 第二站:熟悉高频概念与核心流程

  • AUTOSAR_TR_FunctionalClusterShortnames:一份非常实用的“速查手册”,汇集了各个功能集群(FC)的缩写,便于快速查阅。
  • AUTOSAR_TR_Glossary(术语表):查阅本文档可帮你准确理解AUTOSAR体系中的专业术语。
  • AUTOSAR_TR_AdaptiveMethodology:介绍AP的标准开发方法论、应用程序开发流程和工具链。

⚙️ 第三站:深入关键模块

  • 执行管理(EM, Execution Management)
    • AUTOSAR_EXP_ExecutionManagement
  • AUTOSAR_SWS_ExecutionManagement、AUTOSAR_TPS_ManifestSpecification。EM相当于AP的“操作系统内核”,负责整个系统生命周期的管理,Manifest是EM等模块运行所必需的配置文件。
  • 通信管理(CM, Communication Management):推荐文档:AUTOSAR_EXP_ARAComAPI、AUTOSAR_SWS_CommunicationManagement。CM是AP实现SOA通信的核心,定义了用于服务发现和调用的API。
  • 状态管理(SM, State Management):推荐文档:AUTOSAR_RS_StateManagement、AUTOSAR_SWS_StateManagement。SM负责协调整个系统的运行模式切换。
  • 持久性(PER, Persistency):推荐文档:AUTOSAR_SWS_Persistency。PER为应用程序提供非易失性数据存储机制。
  • 日志和追踪(LT, Log and Trace):推荐文档:AUTOSAR_SWS_LogAndTrace。LT为AP应用程序提供了统一的日志记录接口。

📖 第四站:其他模块

  • 应用开发者:阅读 AUTOSAR_SWS 开头的软件规范文档和 AUTOSAR_EXP_AdaptivePlatformInterfacesGuideline(接口使用指南)。
  • 平台/服务开发者:重点关注 AUTOSAR_SWS、AUTOSAR_TPS(模板规范)及每个功能集群的详细设计说明(FC Design)。
  • 工具链开发者:深入研读 AUTOSAR_TPS、MOD 和 MMOD 等元模型文档。
  • 系统集成者:关注 AUTOSAR_TPS_ManifestSpecification及所有与配置、部署相关的文档。

📑 AUTOSAR 文档分类速查

AUTOSAR 文档通过文件名中的前缀来区分。理解这些前缀,能帮助你快速定位所需文档。

AUTOSAR_EXP_ARAComAPI

AUTOSAR_EXP_ARAComAPI


[SWS_CORE_90003]{草案} ⌈以 ARA 开头的 C/C++ 符号保留给 AUTOSAR 使用。⌋

自适应平台通常避免使用 C/C++ 预处理器宏。但如果未来某个时间点引入了宏,所有此类宏都将以 ARA 为前缀。因此,平台供应商不应定义任何以此为前缀的符号(包括宏和 C/C++ 符号),以免与标准未来新增内容发生冲突。

AUTOSAR_SWS_CommunicationManagement

AUTOSAR_SWS_CommunicationManagement


7 功能规范

7.1 总体描述

AUTOSAR自适应架构将自适应平台基础软件组织为多个功能集群。这些集群向应用程序提供通用功能服务。AUTOSAR自适应平台的 通信管理(CM 正是这样一个功能集群,隶属于"AUTOSAR自适应应用运行时(ARA)"。它负责构建和监控应用程序之间的通信路径,支持本地和远程通信。

MISRA C 2023 规范英文版

MISRA C 2023 规范英文版

https://ww2.mathworks.cn/help/bugfinder/misra-c-2023-reference.html?lang=en

中文版本


Directives

Implementation

[Dir 1.1] Any implementation-defined behavior on which the output of the program depends shall be documented and understood.


Compilation and build

[Dir 2.1] All source files shall compile without any compilation errors.


Code design

[Dir 4.1] Run-time failures shall be minimized.

[Dir 4.3] Assembly language shall be encapsulated and isolated.

[Dir 4.4] Sections of code should not be “commented out”.

CERT C 规范英文版

CERT C 规范英文版

https://ww2.mathworks.cn/help/bugfinder/cert-c-rules-and-recommendations.html?lang=en


Rules

Preprocessor

[Rule PRE30-C] Do not create a universal character name through concatenation.

[Rule PRE31-C] Avoid side effects in arguments to unsafe macros.

[Rule PRE32-C] Do not use preprocessor directives in invocations of function-like macros.


Declarations and initialization

[Rule DCL30-C] Declare objects with appropriate storage durations.

[Rule DCL31-C] Declare identifiers before using them.

[Rule DCL36-C] Do not declare an identifier with conflicting linkage classifications.

AUTOSAR C++ 2014 规范英文版

AUTOSAR Cpp 2014 规范英文版

https://ww2.mathworks.cn/help/bugfinder/autosar-c-14.html?lang=en

中文版


Language independent issues

[Rule A0-1-1] A project shall not contain instances of non-volatile variables being given values that are not subsequently used.

[Rule A0-1-2] The value returned by a function having a non-void return type that is not an overloaded operator shall be used.

[Rule A0-1-3] Every function defined in an anonymous namespace, or static function with internal linkage, or private member function shall be used.

CERT C++ 规范英文版

CERT C++ 规范英文版

https://ww2.mathworks.cn/help/bugfinder/cert-c-rules.html?lang=en

中文版本


Declare and Initialization

[DCL30-C] Declare objects with appropriate storage durations.

[DCL39-C] Avoid information leakage in structure padding.

[DCL40-C] Do not create incompatible declarations of the same function or object.

[DCL50-CPP] Do not define a C-style variadic function.

[DCL51-CPP] Do not declare or define a reserved identifier.

[DCL52-CPP] Never qualify a reference type with const or volatile.

[DCL53-CPP] Do not write syntactically ambiguous declarations.

Misra C++ 2008 规范

Misra Cpp 2008


Language independent issues

Unnecessary constructs

Rule 0-1-1 (Required) A project shall not contain unreachable code.

Rule 0-1-2 (Required) A project shall not contain infeasible paths.

Rule 0-1-3 (Required) A project shall not contain unused variables.

Rule 0-1-4 (Required) A project shall not contain non-volatile POD variables having only one use.

Rule 0-1-5 (Required) A project shall not contain unused type declarations.

Rule 0-1-6 (Required) A project shall not contain instances of non- volatile variables being given values that are never subsequently used.

Misra C++ 2008 规范

Misra Cpp 2008 规范


语言无关问题

不必要的构造

规则 0-1-1 (必需)项目不应包含无法访问的代码。

规则 0-1-2 (必需)项目不应包含不可行的路径。

规则 0-1-3 (必需)项目不应包含未使用的变量。

规则 0-1-4 (必需)项目不应包含只有一种用途的非易失性 POD 变量。

Misra C++ 2023 规范英文版

MISRA C++ 2023 规范英文版

https://ww2.mathworks.cn/help/bugfinder/misra-cpp-2023-rules-and-directives.html?lang=en

中文版本


Language independent issues

[Rule 0.0.1 Required] A function shall not contain unreachable statements.

[Rule 0.0.2 Advisory] Controlling expressions should not be invariant.

[Rule 0.1.1 Advisory] A value should not be unnecessarily written to a local object.

[Rule 0.1.2 Required] The value returned by a function shall be used.

[Rule 0.2.1 Advisory] Variables with limited visibility should be used at least once.

C++ 编码规范

C++ 编码规范

本文基于 Google C++ Style Guide 编写,通过规范 C++ 的代码风格,提高代码的可读性,可维护性,可扩展性,同时保证 C++ 语言的新特性得以高效使用。


1. 项目结构

1.1 模块目录

模块目录结构如下:

colcon 使用详细总结

colcon 使用详细总结

colcon 是 ROS 2 默认的元构建工具,是 catkin_make、catkin_tools、ament_tools 的迭代升级版本,用于ROS 2工作空间的包构建、测试、打包与环境管理,支持ament_cmake、ament_python、纯CMake、Python setuptools等多种构建类型,采用拓扑序并行构建,原生支持工作空间叠加(overlay/underlay)机制,是ROS 2开发的核心工具。

ROS2 源码详细分析

ROS2 源码详细分析(基于Humble LTS 稳定版)

本文基于ROS2 Humble LTS官方源码,从分层架构、核心模块源码实现、全链路通信流程三个维度,对ROS2核心源码进行深度拆解,同时补充关键设计思想与源码阅读路径。

ROS2 使用详细总结

ROS2 使用详细总结

本文基于ROS2最新LTS版本(Humble Hawksbill / Jazzy Jalisco)编写,覆盖从环境搭建、核心概念、开发流程、进阶特性到生态应用、避坑指南的全链路内容,兼顾入门与实战,是一份可直接落地的ROS2全栈使用手册。