メインコンテンツ

このページは機械翻訳を使用して翻訳されました。最新版の英語を参照するには、ここをクリックします。

MDF ファイル内の LIN データのインポートと復号化

この例では、解析のために MATLAB ® の MDF ファイルから LIN データをインポートして復号化する方法を示します。もう 1 つの例では、MDF ファイルから CAN および CAN FD バス データを抽出して復号化する方法を示しました timetable データをMDFファイルに書き込む際にメタデータをカスタマイズする。ここでは、LIN フレームにアクセスし、LDF ファイルを使用して復号化する方法を学習します。この例で使用される MDF ファイルは Vector CANoe™ を使用して生成され、CAN-LIN ネットワーク セットアップに関連付けられた LIN 記述ファイル (LDF) の 1 つによってデコードが容易になります。

LINデータフレームを識別する

まず、MDF ファイルに関する情報を収集します。

mdfInfo("MDFFrameLogging.mf4")
ans = 
  MDFInfo with properties:

   File Details
                  Name: "MDFFrameLogging.mf4"
                  Path: "/tmp/Bdoc25a_2864802_1974203/tp6f7be44e/vnt-ex95179185/MDFFrameLogging.mf4"
                Author: ""
            Department: ""
               Project: ""
               Subject: ""
               Comment: ""
               Version: "4.20"
      InitialTimestamp: 2025-01-16 19:44:41.936000000

   Creator Details
     ProgramIdentifier: "MDF4Lib"
     CreatorVendorName: "Vector Informatik GmbH"
       CreatorToolName: "CANoe"
    CreatorToolVersion: "18.2.65"
       CreatorUserName: "hpatel"
        CreatorComment: "Created using MdfLog version 1.7.7.0 and Mdf4Lib version 1.9.0.0 X64 (2022-08-31)"

   File Contents
            Attachment: [10×7 table]
     ChannelGroupCount: 18
                 Event: [0×8 eventtable]

バス ロギングの ASAM MDF 規格によれば、LIN バス システムのイベント タイプには、「LIN_Frame」、「LIN_WakeUp」、「LIN_TransmissionError」、「LIN_SyncError」、「LIN_ReceiveError」、「LIN_Spike」、または「LIN_LongDom」が含まれます。この例では、「LIN_Frame」イベント タイプを使用して LIN データ フレームを抽出することに重点を置いています。標準の LIN データ フレームのペイロードは最大 8 バイトで、信号値の転送に使用されます。

標準では、イベント構造内のチャネル名の前に「LIN_Frame」などのイベント タイプ名を付ける必要があることが規定されています。通常、メンバー チャネルを指定するには、ドットを区切り文字として使用します (例: "LIN_Frame.ID""LIN_Frame.DataLength")。

mdfChannelInfo 関数を使用して、"LIN_Frame.*" に一致するチャネル名を見つけます。

mdfChannelInfo("MDFFrameLogging.mf4", Channel="LIN_Frame.*")
ans=66×13 table
                  Name                  GroupNumber    GroupNumSamples    GroupAcquisitionName    GroupComment    GroupSourceName    GroupSourcePath         DisplayName             Unit                                 Comment                              ExtendedNamePrefix    SourceName     SourcePath
    ________________________________    ___________    _______________    ____________________    ____________    _______________    _______________    ______________________    ___________    __________________________________________________________    __________________    ___________    __________

    "LIN_Frame.Baudrate"                    11               285                  LIN6            <undefined>       <undefined>         LIN_Frame       "Baudrate"                bit/second     Baudrate in bits per second.                                         LIN6           <undefined>       LIN6   
    "LIN_Frame.Baudrate"                    12               939                  LIN4            <undefined>       <undefined>         LIN_Frame       "Baudrate"                bit/second     Baudrate in bits per second.                                         LIN4           <undefined>       LIN4   
    "LIN_Frame.Baudrate"                    13              1281                  LIN3            <undefined>       <undefined>         LIN_Frame       "Baudrate"                bit/second     Baudrate in bits per second.                                         LIN3           <undefined>       LIN3   
    "LIN_Frame.BreakDelimiterLength"        11               285                  LIN6            <undefined>       <undefined>         LIN_Frame       "BreakDelimiterLength"    ns             Length of the break delimiter in ns.                                 LIN6           <undefined>       LIN6   
    "LIN_Frame.BreakDelimiterLength"        12               939                  LIN4            <undefined>       <undefined>         LIN_Frame       "BreakDelimiterLength"    ns             Length of the break delimiter in ns.                                 LIN4           <undefined>       LIN4   
    "LIN_Frame.BreakDelimiterLength"        13              1281                  LIN3            <undefined>       <undefined>         LIN_Frame       "BreakDelimiterLength"    ns             Length of the break delimiter in ns.                                 LIN3           <undefined>       LIN3   
    "LIN_Frame.BreakLength"                 11               285                  LIN6            <undefined>       <undefined>         LIN_Frame       "BreakLength"             ns             Length of the break in ns.                                           LIN6           <undefined>       LIN6   
    "LIN_Frame.BreakLength"                 12               939                  LIN4            <undefined>       <undefined>         LIN_Frame       "BreakLength"             ns             Length of the break in ns.                                           LIN4           <undefined>       LIN4   
    "LIN_Frame.BreakLength"                 13              1281                  LIN3            <undefined>       <undefined>         LIN_Frame       "BreakLength"             ns             Length of the break in ns.                                           LIN3           <undefined>       LIN3   
    "LIN_Frame.BusChannel"                  11               285                  LIN6            <undefined>       <undefined>         LIN_Frame       "BusChannel"              <undefined>    Logical bus channel number the frame was sent or received.           LIN6           <undefined>       LIN6   
    "LIN_Frame.BusChannel"                  12               939                  LIN4            <undefined>       <undefined>         LIN_Frame       "BusChannel"              <undefined>    Logical bus channel number the frame was sent or received.           LIN4           <undefined>       LIN4   
    "LIN_Frame.BusChannel"                  13              1281                  LIN3            <undefined>       <undefined>         LIN_Frame       "BusChannel"              <undefined>    Logical bus channel number the frame was sent or received.           LIN3           <undefined>       LIN3   
    "LIN_Frame.Checksum"                    11               285                  LIN6            <undefined>       <undefined>         LIN_Frame       "Checksum"                <undefined>    Checksum.                                                            LIN6           <undefined>       LIN6   
    "LIN_Frame.Checksum"                    12               939                  LIN4            <undefined>       <undefined>         LIN_Frame       "Checksum"                <undefined>    Checksum.                                                            LIN4           <undefined>       LIN4   
    "LIN_Frame.Checksum"                    13              1281                  LIN3            <undefined>       <undefined>         LIN_Frame       "Checksum"                <undefined>    Checksum.                                                            LIN3           <undefined>       LIN3   
    "LIN_Frame.ChecksumModel"               11               285                  LIN6            <undefined>       <undefined>         LIN_Frame       "ChecksumModel"           <undefined>    ChecksumModel.                                                       LIN6           <undefined>       LIN6   
      ⋮

この場合、対象となる外部照明データは LIN 4 ネットワークから記録されました。上記の出力は、LIN 4 ネットワークからのデータが MDF ファイルのチャネル グループ 12 に保存されていることを示しています。

MDF ファイルから LIN データフレームを読み取る

mdfRead 関数を使用して、チャネル グループ 12 内のすべてのデータを timetable に読み取ります。timetable は ASAM MDF 規格のログ記録形式に準拠しており、各行はバスからの 1 つの生の LIN フレームを表し、各列は指定されたチャネル グループ内のチャネルを表します。

data = mdfRead("MDFFrameLogging.mf4", GroupNumber = 12)
data = 1×1 cell array
    {939×22 timetable}

linData = data{1}
linData=939×22 timetable
             t         LIN_Frame.BusChannel    LIN_Frame.ID    LIN_Frame.Dir    LIN_Frame.ReceivedDataByteCount    LIN_Frame.DataLength           LIN_Frame.DataBytes           LIN_Frame.Checksum    LIN_Frame.ChecksumModel    LIN_Frame.SOF    LIN_Frame.Baudrate    LIN_Frame.ResponseBaudrate    LIN_Frame.ConfiguredBaudrate    LIN_Frame.BreakLength    LIN_Frame.BreakDelimiterLength    LIN_Frame.IsSimulated    LIN_Frame.SupplierID    LIN_Frame.MessageID    LIN_Frame.NAD    LIN_Frame.EOH    LIN_Frame.IsETF    LIN_Frame.ETFAssocIndex    LIN_Frame.ETFAssocETFId
        ___________    ____________________    ____________    _____________    _______________________________    ____________________    _________________________________    __________________    _______________________    _____________    __________________    __________________________    ____________________________    _____________________    ______________________________    _____________________    ____________________    ___________________    _____________    _____________    _______________    _______________________    _______________________

        0.10573 sec             4                   21             "Tx"                        6                            6              {[        255 0 255 206 255 255]}           219                  "Enhanced"             100000000            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            102083320             0                      0                         255          
        0.1125 sec              4                   22             "Tx"                        8                            8              {[254 0 255 255 255 255 161 255]}           136                  "Enhanced"             105729130            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            107812450             0                      0                         255          
        0.11875 sec             4                   25             "Tx"                        7                            7              {[    224 0 255 247 255 255 203]}           193                  "Enhanced"             112499920            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            114583240             0                      0                         255          
        0.12187 sec             4                   26             "Tx"                        1                            1              {[                          244]}           240                  "Enhanced"             118749880            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            120833200             0                      0                         255          
        0.20625 sec             4                   23             "Tx"                        7                            7              {[     0 254 34 255 255 255 255]}            71                  "Enhanced"             200000000            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            202083320             0                      0                         255          
        0.21146 sec             4                   24             "Tx"                        5                            5              {[            16 254 55 255 255]}           224                  "Enhanced"             206249960            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            208333280             0                      0                         255          
        0.21562 sec             4                   27             "Tx"                        3                            3              {[                    253 4 170]}           247                  "Enhanced"             211458260            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            213541580             0                      0                         255          
        0.22135 sec             4                   21             "Tx"                        6                            6              {[        255 0 255 235 255 255]}           190                  "Enhanced"             215624900            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            217708220             0                      0                         255          
        0.22812 sec             4                   22             "Tx"                        8                            8              {[ 253 0 255 255 255 255 52 255]}           246                  "Enhanced"             221354030            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            223437350             0                      0                         255          
        0.23437 sec             4                   25             "Tx"                        7                            7              {[    224 0 255 247 255 255 122]}            19                  "Enhanced"             228124820            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            230208140             0                      0                         255          
        0.2375 sec              4                   26             "Tx"                        1                            1              {[                          236]}           248                  "Enhanced"             234374780            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            236458100             0                      0                         255          
        0.30573 sec             4                   21             "Tx"                        6                            6              {[         252 0 255 36 255 255]}           137                  "Enhanced"             300000000            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            302083320             0                      0                         255          
        0.3125 sec              4                   22             "Tx"                        8                            8              {[253 0 255 255 255 255 116 255]}           182                  "Enhanced"             305729130            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            307812450             0                      0                         255          
        0.31875 sec             4                   25             "Tx"                        7                            7              {[    224 0 255 247 255 255 108]}            33                  "Enhanced"             312499920            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            314583240             0                      0                         255          
        0.32187 sec             4                   26             "Tx"                        1                            1              {[                          236]}           248                  "Enhanced"             318749880            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            320833200             0                      0                         255          
        0.40625 sec             4                   23             "Tx"                        7                            7              {[    0 254 128 255 255 255 255]}           232                  "Enhanced"             400000000            19200                       0                              0                         937494                        104166                          1                       0                       0                   0            402083320             0                      0                         255          
      ⋮

LDF ファイルを使用して LIN メッセージを復号化する

linDatabase 関数を使用して LDF ファイルを開きます。

ldb = linDatabase("ExteriorLight_LIN_CH4.ldf")
ldb = 
  Database with properties:

   File Information
               Name: "ExteriorLight_LIN_CH4.ldf"
               Path: "/tmp/Bdoc25a_2864802_1974203/tp6f7be44e/vnt-ex95179185/ExteriorLight_LIN_CH4.ldf"
    ProtocolVersion: 2.2000
    LanguageVersion: 2.2000
           BusSpeed: 19.2000

   Network Information
              Nodes: [6×3 table]
             Frames: [7×5 table]
            Signals: [19×5 table]

linMessageTimetable 関数は、LDF データベースを使用してメッセージ名と信号を復号化します。ASAM 標準ログ形式のデータを Vehicle Network Toolbox ™ LIN message timetable に変換します。

msgTimetable = linMessageTimetable(linData, ldb)
msgTimetable=939×8 timetable
       Time        ID       Name                                Data                            Length      Signals       ErrorType    ChecksumType    Checksum
    ___________    __    ___________    ____________________________________________________    ______    ____________    _________    ____________    ________

    0.10573 sec    21    DLFLeft_01     255      0    255    206    255    255      0      0      6       {1×1 struct}      None         Enhanced        219   
    0.1125 sec     22    DLFRight_01    254      0    255    255    255    255    161    255      8       {1×1 struct}      None         Enhanced        136   
    0.11875 sec    25    GWE_01         224      0    255    247    255    255    203      0      7       {1×1 struct}      None         Enhanced        193   
    0.12187 sec    26    GWE_02         244      0      0      0      0      0      0      0      1       {1×1 struct}      None         Enhanced        240   
    0.20625 sec    23    DLRLeft_01       0    254     34    255    255    255    255      0      7       {1×1 struct}      None         Enhanced         71   
    0.21146 sec    24    DLRRight_01     16    254     55    255    255      0      0      0      5       {1×1 struct}      None         Enhanced        224   
    0.21562 sec    27    WWS_01         253      4    170      0      0      0      0      0      3       {1×1 struct}      None         Enhanced        247   
    0.22135 sec    21    DLFLeft_01     255      0    255    235    255    255      0      0      6       {1×1 struct}      None         Enhanced        190   
    0.22812 sec    22    DLFRight_01    253      0    255    255    255    255     52    255      8       {1×1 struct}      None         Enhanced        246   
    0.23437 sec    25    GWE_01         224      0    255    247    255    255    122      0      7       {1×1 struct}      None         Enhanced         19   
    0.2375 sec     26    GWE_02         236      0      0      0      0      0      0      0      1       {1×1 struct}      None         Enhanced        248   
    0.30573 sec    21    DLFLeft_01     252      0    255     36    255    255      0      0      6       {1×1 struct}      None         Enhanced        137   
    0.3125 sec     22    DLFRight_01    253      0    255    255    255    255    116    255      8       {1×1 struct}      None         Enhanced        182   
    0.31875 sec    25    GWE_01         224      0    255    247    255    255    108      0      7       {1×1 struct}      None         Enhanced         33   
    0.32187 sec    26    GWE_02         236      0      0      0      0      0      0      0      1       {1×1 struct}      None         Enhanced        248   
    0.40625 sec    23    DLRLeft_01       0    254    128    255    255    255    255      0      7       {1×1 struct}      None         Enhanced        232   
      ⋮

最初の「GWI_01」メッセージに保存されている信号を表示します。

msgTimetable.Signals{3}
ans = struct with fields:
     GWE_TurnIndicationLeft: 0
    GWE_TurnIndicationRight: 0
           GWE_WarningLight: 0
           GWE_DrivingLight: 1
               GWE_Reserved: 203

関心のある信号値を再パッケージ化して可視化する

バス上の各固有メッセージからの信号データを signal timetable に整理するには、この例に含まれている hLINSignalTimetable ヘルパー関数を使用します。この例では、LIN message timetable から、特定の関心メッセージ「GWI_01」の signal timetable を作成する方法を示します。「GWI_01」メッセージには、左折、右折、警告灯/ハザード灯、運転灯などの信号が含まれます。

signalTimetable = hLINSignalTimetable(msgTimetable,'GWE_01')
signalTimetable=171×5 timetable
       Time        GWE_TurnIndicationLeft    GWE_TurnIndicationRight    GWE_WarningLight    GWE_DrivingLight    GWE_Reserved
    ___________    ______________________    _______________________    ________________    ________________    ____________

    0.11875 sec              0                          0                      0                   1                203     
    0.23437 sec              0                          0                      0                   1                122     
    0.31875 sec              0                          0                      0                   1                108     
    0.43437 sec              0                          0                      0                   1                248     
    0.51875 sec              0                          0                      0                   1                199     
    0.63437 sec              0                          0                      0                   1                197     
    0.71875 sec              0                          0                      0                   1                245     
    0.83437 sec              0                          0                      0                   1                119     
    0.91875 sec              0                          0                      0                   1                 67     
    1.0344 sec               0                          0                      0                   1                198     
    1.1187 sec               0                          0                      0                   1                 86     
    1.2344 sec               0                          0                      0                   1                 14     
    1.3187 sec               0                          0                      0                   1                134     
    1.4344 sec               0                          0                      0                   1                233     
    1.5187 sec               0                          0                      0                   1                153     
    1.6344 sec               0                          0                      0                   1                 26     
      ⋮

関心のある信号を可視化するために、signal timetable の列を時間の経過に沿ってプロットし、さらに解析することができます。

stackedplot(signalTimetable,{"GWE_TurnIndicationLeft","GWE_TurnIndicationRight","GWE_WarningLight","GWE_DrivingLight"},marker=".")
title("Signals from 'GWE\_01' Message")

Figure contains an object of type stackedplot. The chart of type stackedplot has title Signals from 'GWE\_01' Message.