主要内容

ARXML 文件快速入门

此示例说明如何解析和查看 ARXML 文件中的信息。

访问权限是通过 ARXML 文件对象提供的。ARXML 文件对象可用于:

  • 原始报文解码方法的输入。

  • 观察可能导致解码失败的缺失元素。

  • 查找有关感兴趣的报文、PDU 或信号的信息。

  • 了解 ARXML 文件的形成。

此示例描述 CAN 的情况。

打开 ARXML 文件

使用 arxmlDatabase MATLAB 函数打开示例文件 SampleFile.arxml。ARXML 文件对象包括三个属性,即 NamePathCAN

arxmlObj = arxmlDatabase("SampleFile.arxml")
arxmlObj = 
  Database with properties:

    Name: "SampleFile.arxml"
    Path: "/tmp/Bdoc25b_2988451_1428583/tpf364ba40/vnt-ex86715502/SampleFile.arxml"
     CAN: [1×1 shared.vnt.arxml.protocol.CAN]

从 ARXML 文件查看实体值

CAN 属性是包含特定于 CAN 协议的 ARXML 信息的对象。当前,只有 CAN 协议才受支持,并且对象中的所有信息都为只读。

CAN 对象包括三个属性:FramePDUISignal,它们反映 ARXML 文件的基本结构。

arxmlObj.CAN
ans = 
  CAN with properties:

      Frame: [2×9 table]
        PDU: [1×1 shared.vnt.arxml.shared.PDU]
    ISignal: [6×9 table]

查看帧信息

调用 Frame 属性以查看帧表。

arxmlObj.CAN.Frame
ans=2×9 table
        Name                    Path                  ID     Extended    StartBit    Length           ByteOrder                         PDU                     FrameTriggering  
    ____________    _____________________________    ____    ________    ________    ______    _______________________    ________________________________    ___________________

    "ML_Frame_1"    "/MathWorks/FRAME/ML_Frame_1"    1000     false         0          8       mostSignificantByteLast    /MathWorks/PDUS/ML_ISignalIPDU_1    "FrameTriggering_1"
    "ML_Frame_2"    "/MathWorks/FRAME/ML_Frame_2"    1001     true          0          4       mostSignificantByteLast    /MathWorks/PDUS/ML_ISignalIPDU_2    "FrameTriggering_2"

帧表包括在 ARXML 文件中为 CAN 定义的信息。此表包括将 CAN 帧解码到 ISignalIPDU 所需的所有信息。

该表按照 AUTOSAR 标准定义以下各项。

  • Path 从上到下反映层次组织,说明元素如何相互包含。

  • PDU(协议数据单元)是用于软件组件和 ECU 之间通信的数据包。它使用与表中 Path 相同的表示。

  • FrameTriggering 定义在网络上发送或接收 Frame 的时序和条件。

  • ByteOrder 反映端序。它使用项 mostSignificantByteLast (Little Endian) 和 mostSignificantByteFirst (Big Endian)。

查看 PDU 信息

调用 PDU 属性以查看 CAN 的 PDU 信息。PDU 是以各种类型的 PDU 作为属性的对象。当前仅支持 ISignalIPDU

arxmlObj.CAN.PDU
ans = 
  PDU with properties:

    ISignalIPDU: [2×6 table]

调用 ISignalIPDU 以查看 ISignalIPDU 表。

arxmlObj.CAN.PDU.ISignalIPDU
ans=2×6 table
           Name                      Frame                 ISignal      StartBit    Length           ByteOrder       
    __________________    ___________________________    ___________    ________    ______    _______________________

    "ML_ISignalIPDU_1"    /MathWorks/FRAME/ML_Frame_1    {4×5 table}       0          8       mostSignificantByteLast
    "ML_ISignalIPDU_2"    /MathWorks/FRAME/ML_Frame_2    {2×5 table}       0          4       mostSignificantByteLast

ISignalIPDU 表包括在 ARXML 文件中为 CAN 定义的 ISignalIPDU 信息。ISignal 列中列出了特定 ISignalIPDU 中包含的 ISignal。

arxmlObj.CAN.PDU.ISignalIPDU.ISignal{1}
ans=4×5 table
         Name         StartBit    Length           ByteOrder              BaseType  
    ______________    ________    ______    ________________________    ____________

    "ML_ISignal_1"       0          1       mostSignificantByteLast     {1×1 struct}
    "ML_ISignal_2"       1          2       mostSignificantByteFirst    {1×1 struct}
    "ML_ISignal_3"       3          2       opaque                      {1×1 struct}
    "ML_ISignal_4"       5          1       mostSignificantByteLast     {1×1 struct}

arxmlObj.CAN.PDU.ISignalIPDU.ISignal{2}
ans=2×5 table
         Name         StartBit    Length           ByteOrder             BaseType  
    ______________    ________    ______    _______________________    ____________

    "ML_ISignal_5"        0          2      mostSignificantByteLast    {1×1 struct}
    "ML_ISignal_6"      NaN        NaN      mostSignificantByteLast    {1×1 struct}

此 ISignal 表包括基本信息,例如 ISignal 在 ISignalIPDU 中位的位置。完整的 ISignal 信息可在 ISignal 表中获得。

查看 ISignal 信息

调用 ISignal 属性以查看 ISignal 表。

arxmlObj.CAN.ISignal
ans=6×9 table
         Name                             CompuMethod                        StartBit    Length           ByteOrder              BaseType         Unit                      PDU                                    SystemSignal                  
    ______________    ___________________________________________________    ________    ______    ________________________    ____________    ___________    ________________________________    _______________________________________________

    "ML_ISignal_1"    1×1 shared.vnt.arxml.shared.compumethod.CompuMethod        0          1      mostSignificantByteLast     {1×1 struct}    F              /MathWorks/PDUS/ML_ISignalIPDU_1    "/MathWorks/SYSTEM_SIGNALS/ML_ISignal_1_System"
    "ML_ISignal_2"    1×1 shared.vnt.arxml.shared.compumethod.CompuMethod        1          2      mostSignificantByteFirst    {1×1 struct}    min            /MathWorks/PDUS/ML_ISignalIPDU_1    "/MathWorks/SYSTEM_SIGNALS/ML_ISignal_2_System"
    "ML_ISignal_3"    1×1 shared.vnt.arxml.shared.compumethod.CompuMethod        3          2      opaque                      {1×1 struct}    rpm            /MathWorks/PDUS/ML_ISignalIPDU_1    "/MathWorks/SYSTEM_SIGNALS/ML_ISignal_3_System"
    "ML_ISignal_4"    1×1 shared.vnt.arxml.shared.compumethod.CompuMethod        5          1      mostSignificantByteLast     {1×1 struct}    F              /MathWorks/PDUS/ML_ISignalIPDU_1    "/MathWorks/SYSTEM_SIGNALS/ML_ISignal_4_System"
    "ML_ISignal_5"    1×1 shared.vnt.arxml.shared.compumethod.CompuMethod        0          2      mostSignificantByteLast     {1×1 struct}    F              /MathWorks/PDUS/ML_ISignalIPDU_2    "/MathWorks/SYSTEM_SIGNALS/ML_ISignal_5_System"
    "ML_ISignal_6"    1×1 shared.vnt.arxml.shared.compumethod.CompuMethod      NaN        NaN      mostSignificantByteLast     {1×1 struct}    <undefined>    /MathWorks/PDUS/ML_ISignalIPDU_2    ""                                             

CompuMethod 列显示 CompuMethod 对象,允许您查看支持的 CompuMethod 的属性。如果我们调用该表中的项,将提供更多详细信息。

例如,ISignal ML_ISignal_2 使用 TextTable 类型的 CompuMethod。

arxmlObj.CAN.ISignal.CompuMethod(2)
ans = 
  TextTable with properties:

            Name: "ML_ISignal_2_Encoding"
            Unit: "min"
              VT: ["Group1"    "Group2"    "Group3"]
      LowerLimit: [1 2 3]
      UpperLimit: [1 2 3]
    DefaultValue: ""
    InverseValue: [NaN NaN NaN]

BaseType 列显示物理数据类型的信息。它指定数据的编码方法和大小。

arxmlObj.CAN.ISignal.BaseType{1}
ans = struct with fields:
    BaseTypeEncoding: 'NONE'
        BaseTypeSize: 16

缺失元素

在 ARXML 中,某些元素是可选的。如果它们未在文件中定义,则可能不会出现在 ARXML 文件对象表中。

不同数据类型在表中有不同“缺失”表示。

arxmlObj.CAN.ISignal(6,:)
ans=1×9 table
         Name                          CompuMethod                     StartBit    Length           ByteOrder             BaseType         Unit                      PDU                   SystemSignal
    ______________    _____________________________________________    ________    ______    _______________________    ____________    ___________    ________________________________    ____________

    "ML_ISignal_6"    1×1 shared.vnt.arxml.shared.compumethod.Empty      NaN        NaN      mostSignificantByteLast    {1×1 struct}    <undefined>    /MathWorks/PDUS/ML_ISignalIPDU_2         ""