在使用Simulink Function 与Function Caller进行服务建模时,对于输入参数是bus类型的Simulink Function,在生成AutoSar代码的时候,经常会出错,提示“Provide Input argument specifications and Output argument specifications for the Function Caller block 'Function Caller' because the corresponding Simulink function could not be resolved to within this hierarchy, model, or any referenced model.”
下面通过一个实例,解决输入端口数据类型为Bus类型的Simulink Function生成AutoSar代码的问题。
1、新建一个数据字典,命名为“exsl_funcaller_struct_atsr_data”
2、添加一个bus对象,添加3个元素a,b,c
3、在Code Generation页的Header file填入“Rte_Type.h”
4、创建一个Simulink Parameter,命名为“myBus_Param”,Data Type为“myBus”
5、在‘Value’框输入“struct(‘a’,0,’b’,0,’c’,0)”
6、新建一个服务器模型,添加Simulink function模块
7、输入参数u的数据类型设为Bus:myBus
8、函数可见性设为global
9、新建一个客户端模型,顶层输入端口的数据类型设为Bus:myBus,勾选“output as nonvirtual bus”
10、添加function caller
11、function caller的Input argument输入已定义的bus对象参数myBus_Param
11、至此,2个模型可单独生成Autosar代码