我读过几份AUTOSAR文件。现在,我关心的只是开发软件组件。我有两个软件组件设计,看看下面的图片。

解释:
RunnableEntity通信,当新数据出现时,该端口将运行。然后,RunnableEntity将数据设置为InterRunnableVariable。主RunnableEntity,即RunnableEntity 1,将处理InterRunnableVariable以生成输出。RunnableEntity在通用全局变量的帮助下对数据进行处理(全局变量的目的与InterRunnableVariable相同)。我的问题是,
谢谢你的帮助。
====================Adding编码后的Comment========================
设计1
/* Runnable Entity 1*/
/* Event : TimeEvent 25ms */
void re1(void){
data_output out;
irv irv1 = Rte_IrvIread_re1_irv1();
irv irv2 = Rte_IrvIread_re1_irv2();
irv irv3 = Rte_IrvIread_re1_irv3();
out = DataProcess(&irv1,&irv2,&irv3);
Rte_Write_re1_port3_out();
}
/* Runnable Entity 2*/
/* Event : DataReceiveErrorEvent on port1 */
void re2(void){
irv irv2 = Rte_IrvIread_re1_irv2();
modify(&irv2);
Rte_IrvIwrite_re1_irv2(irv2);
}
/* Runnable Entity 3*/
/* Event : DataReceiveEvent on port1 */
void re2(void){
data_input1 in;
Std_RetrunType status;
irv irv1 = Rte_IrvIread_re1_irv1();
status = Rte_Receive_re1_port1_input(&in);
if (status == RTE_E_OK) {
modify(&irv1,in);
Rte_IrvIwrite_re1_irv1(irv1);
}
}
/* Runnable Entity 4*/
/* Event : DataReceiveEvent on port2 */
void re2(void){
data_input2 in;
Std_RetrunType status;
irv irv3 = Rte_IrvIread_re1_irv3();
status = Rte_Receive_re1_port2_input2(&in);
if (status == RTE_E_OK) {
modify(&irv3,in2);
Rte_IrvIwrite_re1_irv3(irv3);
}
}设计2
/*Global Variable*/
global_variable1 gvar1; /* Equal with InterVariable 1 in Design 1*/
global_variable2 gvar2; /* Equal with InterVariable 2 in Design 1*/
global_variable3 gvar3; /* Equal with InterVariable 3 in Design 1*/
/* Runnable Entity 1*/
/* Event : TimeEvent 25ms */
void re1(void){
data_output out;
GetData1()
GetData2()
out = GetOutputWithGlobalVariable();
Rte_Write_re1_port3_out(out);
}
/* Get Data 1*/
void getData1(){
Std_ReturnType status; /* uint8 */
data_input1 in;
do {
status = Rte_Receive_re1_port1_input1(&in);
if (status == RTE_E_OK) {
modifyGlobalVariable(in);
}
} while (status != RTE_E_NO_DATA && status != RTE_E_LOST_DATA);
if(status != RTE_E_LOST_DATA){
modifyGlobalVariableWhenError();
}
return;
}
/* Get Data 2*/
void getData2(){
Std_ReturnType status; /* uint8 */
data_input2 in;
do {
status = Rte_Receive_re1_port2_input2(&in);
if (_status == RTE_E_OK) {
modifyGlobalVariable2(in);
}
} while (status != RTE_E_NO_DATA && status != RTE_E_LOST_DATA);
return;
}发布于 2016-03-12 11:50:08
我认为这两种解决方案都是可行的。主要区别在于,在第一个解决方案中,生成的Rte将管理全局缓冲区,而在第二个设计中,您必须自己处理缓冲区。特别是,如果您有多个运行在同一个缓冲区中的运行程序,“Rte”将生成中断锁以保护数据一致性,或者在运行RunnableEntities的任务上下文不能相互中断时优化锁。
即使只有一个“RunnableEntity”(如第二个设计中所示),TimingEvent也可能激活RunnableEntity和DataReceivedEvent (尽管我不明白为什么在第二个设计中忽略了DataReceivedEvent )。在本例中,“RunnableEntity”在访问相同数据的两个不同上下文中运行。
简而言之:我的建议是使用可互操作的变量,并让Rte处理数据的一致性、初始化等。创建软件组件描述可能需要付出更多的努力,但是您只需要使用生成的IrvRead/IrvW区函数就可以了。
发布于 2017-07-22 19:43:35
实际上我更喜欢这里的第一个。
第二个问题在一定程度上取决于您的SWC描述,因为有端口数据访问的规范。根据这个定义,它取决于RTE是创建阻塞Rte_Receive还是非阻塞Rte_Receive.
SWS_Rte_01288如果dataReceivePointByArgument角色中的VariableAccess使用“事件”语义引用所需的VariableDataPrototype,则将生成非阻塞的Rte_Receive API。(SRS_Rte_00051)
SWS_Rte_07638 RTE生成器将拒绝配置是由dataReceivePointByValue角色中的VariableAccess引用的具有“事件”语义的VariableDataPrototype。(SRS_Rte_00018)
SWS_Rte_01290如果dataReceivePointByArgument角色中的VariableAccess使用“事件”语义引用所需的VariableDataPrototype,即由DataReceivedEvent引用,而DataReceivedEvent则由WaitPoint引用,则将生成阻塞的Rte_Receive API。(SRS_Rte_00051)
另一方面,我不确定阻塞Rte_Receive与基于TimingEvent的RunnableEntity调用之间会发生什么。
还应考虑以下几点:
RTE_E_LOST_DATA实际上意味着由于传入数据溢出队列而丢失数据(Rte_Receive只适用于swImplPoliy =排队,否则,如果swImplPolicy !=排队,则得到Rte_Read)。这不是一个过量的Std_ReturnType值,而是添加到返回值-> OverlayedError中的一个标志)
RTE_E_TIMEOUT将用于阻塞Rte_Receive
RTE_E_NO_DATA将用于非阻塞Rte_Receive。
然后,您应该检查如下:
Std_ReturnType status;
status = Rte_Receive_..(<instance>, <parameters>);
if (Rte_HasOverlayedError(status)) {
// Handle e.g. RTE_E_LOST_DATA
}
// not with Rte_Receive - if(Rte_IsInfrastructureError(status)) { }
else { /* handle application error with error code status */
status = Rte_ApplicationError(status);
}https://stackoverflow.com/questions/35935206
复制相似问题