| 1 | {{{ |
| 2 | #!html |
| 3 | <div style="border:3px solid black;text-align:center;font-size:30pt;width:800px;"> |
| 4 | シグナルID、PDU-ID、CAN-IDの関係 |
| 5 | </div> |
| 6 | }}} |
| 7 | [[BR]] |
| 8 | |
| 9 | = はじめに = |
| 10 | * AUTOSARでは、アプリケーションが通信プロトコルやマイコンを意識せず、他のECUとデータ通信することができる |
| 11 | * RTEが、COMスタックを用いて他のECUとデータ送受信する際、データを識別するIDがどのように使用されるかを、CANプロトコルを題材に説明する |
| 12 | |
| 13 | ---- |
| 14 | = 用語説明 = |
| 15 | == COMスタック == |
| 16 | * AUTOSARアーキテクチャにおける、通信スタック(Communication Services、Communication Hardware Abstraction、Communication Drivers)の総称 |
| 17 | |
| 18 | == シグナル == |
| 19 | * アプリケーションSWC間で送受信するデータの単位 |
| 20 | * 異なるECUと、データを送受信する場合、RTEとComはシグナル単位でデータを送受信する |
| 21 | * シグナル毎に以下のデータ型を選択できる |
| 22 | * boolean |
| 23 | * uint8 |
| 24 | * uint16 |
| 25 | * uint32 |
| 26 | * sint8 |
| 27 | * sint16 |
| 28 | * sint32 |
| 29 | * float32 |
| 30 | * float64 |
| 31 | * uint8[n] (uint8の配列) |
| 32 | |
| 33 | == CAN-ID == |
| 34 | * [http://ja.wikipedia.org/wiki/Controller_Area_Network CANプロトコル]において、送受信するデータを識別するためのID |
| 35 | |
| 36 | == PDU == |
| 37 | * Protocol Data Unitの略 |
| 38 | * COMスタック内で管理するデータの単位 |
| 39 | * レイヤによってI-PDUのようにプレフィックスが付与されて呼ばれる |
| 40 | * ComレイヤではI-PDUと呼ぶ |
| 41 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/general/auxiliary/AUTOSAR_EXP_LayeredSoftwareArchitecture.pdf#page=73&view=fitv AUTOSAR_EXP_LayeredSoftwareArchitecture.pdf(73ページ)]参照 |
| 42 | |
| 43 | == グローバルPDU == |
| 44 | * ECU毎に定義するCOMスタック全体でユニークとなるPDU識別の概念 |
| 45 | * EcuCという仮想モジュールの{{{EcucPduCollection}}}にて定義する |
| 46 | * [http://www.autosar.org/fileadmin/files/releases/4-0/methodology-templates/templates/standard/AUTOSAR_TPS_ECUConfiguration.pdf#page=148&view=fitv AUTOSAR_TPS_ECUConfiguration.pdf(4.3)]参照 |
| 47 | * グローバルPDUにはIDという概念はない |
| 48 | * PDU-IDを示すデータ型(PduIdType)、PDUのバイト長を示すデータ型(PduLengthType)は、EcuCで定義し、COMスタックジェネレータで生成される{{{ComStack_Cfg.h}}}で定義する |
| 49 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/communication-stack/standard/AUTOSAR_SWS_CommunicationStackTypes.pdf#page=14&view=fitv AUTOSAR_SWS_CommunicationStackTypes.pdf(COMTYPE029)]参照 |
| 50 | * {{{ComStack_Cfg.h}}}は、{{{ComStack_Types.h}}}からincludeされるため、COMスタック全体で使用される |
| 51 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/communication-stack/standard/AUTOSAR_SWS_CommunicationStackTypes.pdf#page=9&view=fitv AUTOSAR_SWS_CommunicationStackTypes.pdf(Figure 1)]参照 |
| 52 | |
| 53 | ---- |
| 54 | |
| 55 | = 各モジュール(Com、PduR、CanIf)におけるPDU-ID = |
| 56 | * 各モジュールで定義するPDUには必ず、EcuCのPDUへの参照があり、どのPDUを示しているかを区別することができる |
| 57 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/communication-stack/standard/AUTOSAR_SWS_PDURouter.pdf#page=143&view=fitv AUTOSAR_SWS_PDURouter.pdf(Figure 32)]参照 |
| 58 | * 各モジュールで定義するPDU-IDはスタック内のの上下のモジュールからAPIコール時に引数に指定されるIDを示している |
| 59 | * [http://www.autosar.org/fileadmin/files/releases/4-0/methodology-templates/templates/standard/AUTOSAR_TPS_ECUConfiguration.pdf#page=161&view=fitv AUTOSAR_TPS_ECUConfiguration.pdf(4.4.2.1)]参照 |
| 60 | * [http://www.autosar.org/fileadmin/files/releases/4-0/methodology-templates/templates/standard/AUTOSAR_TPS_ECUConfiguration.pdf#page=162&view=fitv AUTOSAR_TPS_ECUConfiguration.pdf(Figure 4.9)]参照 |
| 61 | * つまり、ComがはPduRに対してPduR_ComTransmitを呼び出すときの引数(PDU-ID)は、PduR側でコンフィギュレーションした値である{{{PduRSourcePduHandleId}}}となる |
| 62 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/communication-stack/standard/AUTOSAR_SWS_PDURouter.pdf#page=35&view=fitv AUTOSAR_SWS_PDURouter.pdf(PDUR161)]参照 |
| 63 | * 従って、ComはPduRのarxmlを、PduRはCom/CanIfのarxmlを、CanIfはPduRのarxmlを読み込んで、送信先PDU-IDを知る必要がある |
| 64 | |
| 65 | = PduRの振る舞いについて = |
| 66 | * PduRのルーティングテーブルでは、ルーティングパスを{{{PduRSrcPdu}}}と{{{PduRDestPdu}}}のセット(1:N)で指定する |
| 67 | * {{{PduRSrcPdu}}}と{{{PduRDestPdu}}}にそれぞれグローバルPDUへの参照があるため、どのPDUを示しているか区別できる |
| 68 | * 送信(Com→PduR→CanIf) |
| 69 | * Com→PduRの場合、Comは対象のグローバルPDUに紐付いた{{{PduRSrcPdu}}}のPDU-ID({{{PduRSourcePduHandleId}}})に対して{{{PduR_ComTransmit}}}を呼び出す |
| 70 | * 続いて、PduR→CanIfでは、対象のグローバルPDUに紐付いた{{{CanIfTxPduId}}}に対して、{{{CanIf_Transmit}}}を呼び出す |
| 71 | * このとき、{{{PduRDestPdu}}}に設定したPDU-IDは送信完了通知おいて、CanIfから{{{PduR_CanIfTxConfirmation}}}が呼び出される際のPDU-IDとなる |
| 72 | * 従って、{{{PduRDestPdu}}}のPDU-ID({{{PduRDestPduHandleId}}})の多重度は0..1となっており、受信PDUでは使用しない |
| 73 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/communication-stack/standard/AUTOSAR_SWS_PDURouter.pdf#page=123&view=fitv AUTOSAR_SWS_PDURouter.pdf(PDUR322_Conf)]参照 |
| 74 | * 受信(CanIf→PduR→Com) |
| 75 | * CanIfからの受信の場合、受信したPDUのグローバルPDUに紐付いた{{{PduRSrcPdu}}}のPDU-IDに対して{{{PduR_CanIfRxIndication}}}を呼び出す |
| 76 | * [http://www.autosar.org/fileadmin/files/releases/4-0/methodology-templates/templates/standard/AUTOSAR_TPS_ECUConfiguration.pdf#page=163&view=fitv AUTOSAR_TPS_ECUConfiguration.pdf(Figure 4.10)]参照 |
| 77 | * このとき,CanIfでもIPDU-ID({{{CanIfRxPduId}}})が設定でき、多重度が1であるが、少なくともCANプロトコルでは必要ない(どこからも利用されない) |
| 78 | * 続いて、PduR→Comでは、対象のグローバルPDUに紐付いた{{{ComIPduHandleId}}}に対して、{{{Com_RxIndication}}}を呼び出す |
| 79 | * {{{ComIPduHandleId}}}は多重度0..1で、送信完了通知が不要なら必要ないと定義されている |
| 80 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/communication-stack/standard/AUTOSAR_SWS_COM.pdf#page=128&view=fitv AUTOSAR_SWS_COM.pdf(COM175_Conf)]参照 |
| 81 | * R4.1ではこの記述が消えている |
| 82 | * [http://www.autosar.org/fileadmin/files/releases/4-1/software-architecture/communication-stack/standard/AUTOSAR_SWS_COM.pdf#page=127&view=fitv AUTOSAR_SWS_COM.pdf(ECUC_Com_00175)]参照 |
| 83 | |
| 84 | == ゼロコストオペレーション == |
| 85 | * ゼロコストオペレーションを設定するパラメータはPduRにしか存在しない |
| 86 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/communication-stack/standard/AUTOSAR_SWS_PDURouter.pdf#page=116&view=fitv AUTOSAR_SWS_PDURouter.pdf(PDUR317_Conf)]参照 |
| 87 | * {{{configuration generator}}}は{{{configuration editor}}}の意味と思われるが、いずれにしても、ゼロコストオペレーションとするかどうかはコンフィギュレーション設定時に影響することを言っている |
| 88 | * PduRにて、ゼロコストオペレーション設定時に以下のようなAPI名を変換するマクロを用意する必要がある |
| 89 | {{{ |
| 90 | #define PduR_ComTransmit CanIf_Transmit |
| 91 | #define PduR_CanIfRxIndication PduR_ComRxIndication |
| 92 | }}} |
| 93 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/communication-stack/standard/AUTOSAR_SWS_PDURouter.pdf#page=57&view=fitv AUTOSAR_SWS_PDURouter.pdf(7.5)]参照 |
| 94 | * [http://www.autosar.org/fileadmin/files/releases/4-0/software-architecture/communication-stack/standard/AUTOSAR_SWS_PDURouter.pdf#page=143&view=fitv AUTOSAR_SWS_PDURouter.pdf(11.5.1)]参照 |
| 95 | * つまり、ComやCanIdは、PduRの{{{PduRZeroCostOperation}}}に関係なく、対象のグローバルPDUに紐付いた{{{PduRSourcePduHandleId}}}を使用すればよい |
| 96 | * この場合、PduRのジェネレータで、{{{PduRSourcePduHandleId}}}と対象のグローバルPDUに紐付いた{{{CanIfTxPduId}}}が一致しているか等のチェック処理が必要 |
| 97 | * ゼロコストオペレーションでもあっても、PduRのジェネレータは必要となる |
| 98 | |
| 99 | |
| 100 | = COMスタックのコンフィギュレーション例 = |
| 101 | 記法は[wiki:tips_abrex ABREX]参照 |
| 102 | {{{ |
| 103 | EcuC: |
| 104 | EcuC: |
| 105 | EcucPduCollection: |
| 106 | PduIdTypeEnum: UINT8 |
| 107 | PduLengthTypeEnum: UINT16 |
| 108 | Pdu_0: |
| 109 | DefinitionRef: Pdu |
| 110 | PduLength: 8 |
| 111 | Pdu_1: |
| 112 | DefinitionRef: Pdu |
| 113 | PduLength: 8 |
| 114 | |
| 115 | Com: |
| 116 | Com: |
| 117 | ComGeneral: |
| 118 | ComVersionInfoApi: true |
| 119 | ComSupportedIPduGroups: 2 |
| 120 | ComConfigurationUseDet: true |
| 121 | ComConfig: |
| 122 | ComConfigurationId: 1 |
| 123 | ComIPdu_0: |
| 124 | DefinitionRef: ComIPdu |
| 125 | ComIPduType: NORMAL |
| 126 | ComIPduSignalProcessing: IMMEDIATE |
| 127 | ComIPduDirection: RECEIVE |
| 128 | ComIPduHandleId: 10 |
| 129 | ComPduIdRef: /EcuC/EcuC/EcucPduCollection/Pdu_0 |
| 130 | ComIPduGroupRef: /EcuC/Com/ComConfig/ComIPduGroup_0 |
| 131 | ComIPduSignalRef: /EcuC/Com/ComConfig/ComSignal_0 |
| 132 | ComIPdu_1: |
| 133 | DefinitionRef: ComIPdu |
| 134 | ComIPduType: NORMAL |
| 135 | ComIPduSignalProcessing: IMMEDIATE |
| 136 | ComIPduDirection: SEND |
| 137 | ComIPduHandleId: 11 |
| 138 | ComPduIdRef: /EcuC/EcuC/EcucPduCollection/Pdu_1 |
| 139 | ComIPduGroupRef: /EcuC/Com/ComConfig/ComIPduGroup_1 |
| 140 | ComIPduSignalRef: /EcuC/Com/ComConfig/ComSignal_1 |
| 141 | |
| 142 | PduR: |
| 143 | PduR: |
| 144 | PduRGeneral: |
| 145 | PduRZeroCostOperation: false |
| 146 | PduRRoutingTables: |
| 147 | PduRRoutingTable: |
| 148 | PduRRoutingPath_0: |
| 149 | PduRSrcPdu: |
| 150 | PduRSourcePduHandleId: 20 |
| 151 | PduRSrcPduRef: /EcuC/EcuC/EcucPduCollection/Pdu_0 |
| 152 | PduRDestPdu: |
| 153 | PduRDestPduRef: /EcuC/EcuC/EcucPduCollection/Pdu_0 |
| 154 | PduRRoutingPath_1: |
| 155 | PduRSrcPdu: |
| 156 | PduRSourcePduHandleId: 21 |
| 157 | PduRSrcPduRef: /EcuC/EcuC/EcucPduCollection/Pdu_1 |
| 158 | PduRDestPdu: |
| 159 | PduRDestPduHandleId: 22 |
| 160 | PduRDestPduRef: /EcuC/EcuC/EcucPduCollection/Pdu_1 |
| 161 | |
| 162 | CanIf: |
| 163 | CanIf: |
| 164 | CanIfInitCfg: |
| 165 | CanIfRxPduCfg: |
| 166 | CanIfRxPduId: 30 # maybe unused ? |
| 167 | CanIfRxPduCanId: 0x71 |
| 168 | CanIfRxPduRef: /EcuC/EcuC/EcucPduCollection/Pdu_0 |
| 169 | CanIfTxPduCfg: |
| 170 | CanIfTxPduId: 31 |
| 171 | CanIfTxPduCanId: 0x72 |
| 172 | CanIfTxPduRef: /EcuC/EcuC/EcucPduCollection/Pdu_1 |
| 173 | }}} |
| 174 | 上記の場合、各モジュールの処理は以下となる |
| 175 | * ComIPdu_1の送信 |
| 176 | * Com |
| 177 | * ComIPdu_1(Pdu_1)の送信処理:PduR_ComTransmit(21) |
| 178 | * PduR |
| 179 | * PduRRoutingPath_1のルーティング処理:CanIf_Transmit(31) |
| 180 | * CanIf |
| 181 | * Canへの送信処理:Can_Write(0x72) |
| 182 | * 送信完了通知:PduR_CanIfTxConfirmation(22) |
| 183 | * PduR |
| 184 | * 送信完了通知:Com_TxConfirmation(11) |
| 185 | * ComIPdu_0の受信 |
| 186 | * CanIf |
| 187 | * Canからの受信処理:CanId:0x71を受信→PduR_CanIfRxIndication(20) |
| 188 | * PduR |
| 189 | * PduRRoutingPath_0のルーティング処理:Com_RxIndication(10) |
| 190 | |
| 191 | |