AutoSAR系列讲解(入门篇)3.3-RTE对Ports的支撑(上)

目录

一、特征

1、扮演SWCs和BSW的交流途径

2、其他特征

二、S/R接口的不同方式

1、直接调用(Direct)

2、缓存调用(Buffered)

3、队列调用(Queued)

三、跨ECU的方式


一、特征

1、扮演SWCs和BSW的交流途径

还是老生常谈的那么几点:

  • 作为VFB的具体实现
  • 作为S/R接口的通信实现
  • 作为C/S接口的通信实现
  • ECU内部通信/跨ECU(通过COM)
  • 实现AR-COM的回调功能,具体实现是在SWC中完成的,RTE负责完成这个回调机制

2、其他特征

  • 提供了实现数据一致性的机制(所谓的数据一致性,就是说简单一点:当多个SWC同时操作同一个数据时,可能会发生一些不想看到的问题,数 据一致性要求不能发生这些问题)
  • 支持简单和复杂的数据类型
  • 对SWC类型(SWC type,和SWC不同,SWC type是指SWC的一个类型,用这个类型可以实例化一个SWC,就好像用int这个类型实例化一个count一样)的实例化

二、S/R接口的不同方式

以下调用,在配置好Davinci后,是会自动生成到runnable上方的,可以直接复制。比如我复制了一段DaVinci生成的SWC中的代码,可以看到,其中 的 Rte_ 的函数都是列出来在runnable上方的

/********************************************************************************************************************** 
 * 
 * Runnable Entity Name: RAB_Core0_100us 
 * 
 *--------------------------------------------------------------------------------------------------------------------- 
 * 
 * Executed if at least one of the following trigger conditions occurred: 
 * - triggered on TimingEvent every 100us 
 * 
 ********************************************************************************************************************** 
 * 
 * Input Interfaces: 
 * ================= 
 * Explicit S/R API: 
 * ----------------- 
 * Std_ReturnType Rte_Read_AppPI_Can_ReceiverCore0_DEP_Can_Receiver(Idt_Can_Receiver *data) 
 * 
 * Output Interfaces: 
 * ================== 
 * Explicit S/R API: 
 * ----------------- 
 * Std_ReturnType Rte_Write_AppPI_Can_SenderCore0_DEP_Can_Sender(Idt_Can_Sender data, Rte_TransformerError *transformerError) 
 * 
 * Service Calls: 
 * ============== 
 * Service Invocation: 
 * ------------------- 
 * Std_ReturnType Rte_Call_ComM_UserRequest_GetCurrentComMode(ComM_ModeType *ComMode) 
 * Synchronous Service Invocation. Timeout: None 
 * Returned Application Errors: RTE_E_ComM_UserRequest_E_NOT_OK 
 * Std_ReturnType Rte_Call_ComM_UserRequest_GetMaxComMode(ComM_ModeType *ComMode) 
 * Synchronous Service Invocation. Timeout: None 
 * Returned Application Errors: RTE_E_ComM_UserRequest_E_NOT_OK 
 * Std_ReturnType Rte_Call_ComM_UserRequest_GetRequestedComMode(ComM_ModeType *ComMode) 
 * Synchronous Service Invocation. Timeout: None 
 * Returned Application Errors: RTE_E_ComM_UserRequest_E_NOT_OK 
 * Std_ReturnType Rte_Call_ComM_UserRequest_RequestComMode(ComM_ModeType ComMode) 
 * Synchronous Service Invocation. Timeout: None 
 * Returned Application Errors: RTE_E_ComM_UserRequest_E_MODE_LIMITATION, RTE_E_ComM_UserRequest_E_NOT_OK 
 * 
 *********************************************************************************************************************/ 
 /********************************************************************************************************************** 
 * DO NOT CHANGE THIS COMMENT! << Start of documentation area >> DO NOT CHANGE THIS COMMENT! 
 * Symbol: RAB_Core0_100us_doc 
 *********************************************************************************************************************/ 
 
 
 /********************************************************************************************************************** 
 * DO NOT CHANGE THIS COMMENT! << End of documentation area >> DO NOT CHANGE THIS COMMENT! 
 *********************************************************************************************************************/ 
 
 FUNC(void, SWCCore0Basic_Type_CODE) RAB_Core0_100us(void) /* PRQA S 0850 */ /* MD_MSR_19.8 */ 
 { 
 /********************************************************************************************************************** 
 * DO NOT CHANGE THIS COMMENT! << Start of runnable implementation >> DO NOT CHANGE THIS COMMENT! 
 * Symbol: RAB_Core0_100us 
 *********************************************************************************************************************/ 
 
 
 /********************************************************************************************************************** 
 * DO NOT CHANGE THIS COMMENT! << End of runnable implementation >> DO NOT CHANGE THIS COMMENT! 
 *********************************************************************************************************************/ 
 }

1、直接调用(Direct)

相当于有一个全局变量,runnable可以直接读写这个变量用的是下面的语法:

(注意 和 data 的区别,带<>的是指全局data的名字,不带<>的data是局部变量的名字,这里使用指针,就是说操作的是 同一个地址,没有复制使用;同时,这些函数都是在runnable中使用的,不要看是Rte,就以为是RTE中的代码,因为调用的是RTE的机制,所以这 里是Rte)

Std_ReturnType Rte_Read_port>_data> (DataType> *data)

Std_ReturnType Rte_Write_port>_data> (DataType> data)

2、缓存调用(Buffered)

相当于将全局变量先复制到一个runnable的局部变量中,再操作这个局部变量,最后把这个局部变量再赋值到全局变量中。在runnable操作这个局部 变量期间,全局变量是不会改变的。

使用方法如下:(都是由RTE管理的,用户只需要正确调用函数就ok)

DataType> Rte_IRead_r>_port>_data> (void)

void Rte_IWrite_r>_port>_data> (DataType> data)

3、队列调用(Queued)

因为数据不止一个,是一组队列的数据,就像我们常用的串口FIFO。因此,可以设置循环接收或者等待接收,等待的话是有超时管理的。

调用代码如下:

Std_ReturnType Rte_Receive_port>_data> (DataType> *data)

Std_ReturnType Rte_Send_port>_data> (DataType> data)

三、跨ECU的方式

假如是跨ECU的数据传输。那么,我在runnable中使用 Rte_Write_<port>_<Data>()这样的函数后,会需要走runnable

(ECU1) ->RTE (ECU1) ->BSW (ECU1) ->外部总线->BSW (ECU2)

->RTE (ECU2) ->runnable (ECU2)

,这里也列出了用于COM传输的两个函数名:

Com_SendSignal()

Com_ReceiveSignal()

猜你喜欢

转载自blog.csdn.net/qq_42700289/article/details/131404548