Project 2-Highway Assistant-Lane Changing Assistant
Step 1: Create model as per the requirements( given in question).






Step 2: Create the simulink data dictionary for the input and output signal which are used in the model.

Step 3: Under Coder generation setting, select the system target file as autosar.tlc.

Step 4: Click the Autosar component which is presented in the left top corner. The pop up will be open like the image which is given below.




Step 5: Click the Code Interface, select the Autosar dictionary to create the autosar data dictionary.

Step 6: At autosar dictionary, under the xml options, make the file name as the format which is given.

Step 7: First create the S-R interfaces. Then create the Data Elements.


Step 8: After successfully creation of S-R interfaces, create the reveiver port with the prefix of "Rp_".

Step 9: Then create the Sender ports with the prefix of "Pp_".

Step 10: If they are successfully mapped, all validation will be successfully completed.



Step 11: Then click Quick start for code generate.







Step 11: The code will be generated successfully.


"AUTOSAR code:"
/*
* File: Highway_Lane_Assistant_Model.c
*
* Code generated for Simulink model 'Highway_Lane_Assistant_Model'.
*
* Model version : 1.23
* Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
* C/C++ source code generated on : Fri Jan 19 08:42:28 2024
*
* Target selection: autosar.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives:
* 1. Execution efficiency
* 2. RAM efficiency
* Validation result: Not run
*/
#include "Highway_Lane_Assistant_Model.h"
#include "rtwtypes.h"
/* Named constants for Chart: '/Chart' */
#define IN_Enable_Display_Off ((uint8)1U)
#define IN_Enable_Display_Off1 ((uint8)2U)
/* Named constants for Chart: '/Chart' */
#define IN_Enable_Display_On ((uint8)2U)
/* PublicStructure Variables for Internal Data */
ARID_DEF rtARID_DEF; /* '/Chart' */
/* Model step function */
void Highway_Lane_Assistant_Model_Step(void)
{
float64 tmp;
sint32 rtb_Highway_Display_Mode_1;
sint32 rtb_Highway_Display_Mode_3;
sint32 rtb_Lane_Display_Mode_1;
sint32 rtb_Lane_Display_Mode_2;
sint32 rtb_Lane_Display_Mode_3;
sint32 rtb_Lane_Display_Mode_4;
/* Chart: '/Chart' incorporates:
* Inport: '/Enable_Display '
* Inport: '/Highway_Input_Signal'
* Inport: '/Input_Switch'
*/
if (rtARID_DEF.is_active_c3_Highway_Lane_Assis == 0U) {
rtARID_DEF.is_active_c3_Highway_Lane_Assis = 1U;
rtARID_DEF.is_c3_Highway_Lane_Assistant_Mo = IN_Enable_Display_Off;
rtb_Highway_Display_Mode_1 = 232;
rtb_Highway_Display_Mode_3 = 41;
} else if (rtARID_DEF.is_c3_Highway_Lane_Assistant_Mo == IN_Enable_Display_Off)
{
rtb_Highway_Display_Mode_1 = 232;
rtb_Highway_Display_Mode_3 = 41;
if ((Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
() == 1.0) &&
(Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Enable_Display_DE_Enable_Display
() == 1.0) &&
(Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Input_Switch_DE_Input_Switch
() == 1.0)) {
rtARID_DEF.is_c3_Highway_Lane_Assistant_Mo = IN_Enable_Display_Off1;
rtb_Highway_Display_Mode_1 = 213;
rtb_Highway_Display_Mode_3 = 9;
}
} else {
/* case IN_Enable_Display_Off1: */
rtb_Highway_Display_Mode_1 = 213;
rtb_Highway_Display_Mode_3 = 9;
if ((Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
() == 1.0) &&
(Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Enable_Display_DE_Enable_Display
() == 0.0) &&
(Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Input_Switch_DE_Input_Switch
() == 1.0)) {
rtARID_DEF.is_c3_Highway_Lane_Assistant_Mo = IN_Enable_Display_Off;
rtb_Highway_Display_Mode_1 = 232;
rtb_Highway_Display_Mode_3 = 41;
}
}
/* End of Chart: '/Chart' */
/* Outport: '/Highway_Display_Mode_1' */
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Highway_Display_Mode_1_DE_Highway_Display_Mode_1
(rtb_Highway_Display_Mode_1);
/* Outport: '/Highway_Display_Mode_2' */
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Highway_Display_Mode_2_DE_Highway_Display_Mode_2
(183.0);
/* Outport: '/Highway_Display_Mode_3' */
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Highway_Display_Mode_3_DE_Highway_Display_Mode_3
(rtb_Highway_Display_Mode_3);
/* Outport: '/Highway_Display_Mode_4' */
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Highway_Display_Mode_4_DE_Highway_Display_Mode_4
(94.0);
/* Chart: '/Chart' incorporates:
* Inport: '/Enable_Display '
* Inport: '/Input_Switch'
* Inport: '/Lane_Input_Signal'
*/
if (rtARID_DEF.is_active_c1_Highway_Lane_Assis == 0U) {
rtARID_DEF.is_active_c1_Highway_Lane_Assis = 1U;
rtARID_DEF.is_c1_Highway_Lane_Assistant_Mo = IN_Enable_Display_Off;
rtb_Lane_Display_Mode_1 = 132;
rtb_Lane_Display_Mode_2 = 185;
rtb_Lane_Display_Mode_3 = 54;
rtb_Lane_Display_Mode_4 = 67;
} else if (rtARID_DEF.is_c1_Highway_Lane_Assistant_Mo == IN_Enable_Display_Off)
{
rtb_Lane_Display_Mode_1 = 132;
rtb_Lane_Display_Mode_2 = 185;
rtb_Lane_Display_Mode_3 = 54;
rtb_Lane_Display_Mode_4 = 67;
if ((Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
() == 1.0) &&
(Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Enable_Display_DE_Enable_Display
() == 1.0) &&
(Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Input_Switch_DE_Input_Switch
() == 1.0)) {
rtARID_DEF.is_c1_Highway_Lane_Assistant_Mo = IN_Enable_Display_On;
rtb_Lane_Display_Mode_1 = 127;
rtb_Lane_Display_Mode_2 = 248;
rtb_Lane_Display_Mode_3 = 186;
rtb_Lane_Display_Mode_4 = 84;
}
} else {
/* case IN_Enable_Display_On: */
rtb_Lane_Display_Mode_1 = 127;
rtb_Lane_Display_Mode_2 = 248;
rtb_Lane_Display_Mode_3 = 186;
rtb_Lane_Display_Mode_4 = 84;
if ((Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Lane_Input_Signal_DE_Lane_Input_Signal
() == 1.0) &&
(Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Enable_Display_DE_Enable_Display
() == 0.0) &&
(Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Input_Switch_DE_Input_Switch
() == 0.0)) {
rtARID_DEF.is_c1_Highway_Lane_Assistant_Mo = IN_Enable_Display_Off;
rtb_Lane_Display_Mode_1 = 132;
rtb_Lane_Display_Mode_2 = 185;
rtb_Lane_Display_Mode_3 = 54;
rtb_Lane_Display_Mode_4 = 67;
}
}
/* End of Chart: '/Chart' */
/* Switch: '/Switch' incorporates:
* Inport: '/Highway_Input_Signal'
* Switch: '/Switch1'
* Switch: '/Switch2'
* Switch: '/Switch3'
*/
tmp =
Rte_IRead_Highway_Lane_Assistant_Model_Step_Rp_Highway_Input_Signal_DE_Highway_Input_Signal
();
if (tmp == 0.0) {
rtb_Highway_Display_Mode_1 = rtb_Lane_Display_Mode_1;
}
/* Outport: '/Display_Mode_1' incorporates:
* Switch: '/Switch'
*/
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Display_Mode_1_DE_Display_Mode_1
(rtb_Highway_Display_Mode_1);
/* Outport: '/Lane_Display_Mode_1' */
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Lane_Display_Mode_1_DE_Lane_Display_Mode_1
(rtb_Lane_Display_Mode_1);
/* Outport: '/Lane_Display_Mode_2' */
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Lane_Display_Mode_2_DE_Lane_Display_Mode_2
(rtb_Lane_Display_Mode_2);
/* Outport: '/Lane_Display_Mode_3' */
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Lane_Display_Mode_3_DE_Lane_Display_Mode_3
(rtb_Lane_Display_Mode_3);
/* Outport: '/Lane_Display_Mode_4' */
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Lane_Display_Mode_4_DE_Lane_Display_Mode_4
(rtb_Lane_Display_Mode_4);
/* Switch: '/Switch1' */
if (tmp != 0.0) {
rtb_Lane_Display_Mode_2 = 183;
}
/* Outport: '/Display_Mode_2' incorporates:
* Switch: '/Switch1'
*/
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Display_Mode_2_DE_Display_Mode_2
(rtb_Lane_Display_Mode_2);
/* Switch: '/Switch2' */
if (tmp != 0.0) {
rtb_Lane_Display_Mode_3 = rtb_Highway_Display_Mode_3;
}
/* Outport: '/Display_Mode_3' incorporates:
* Switch: '/Switch2'
*/
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Display_Mode_3_DE_Display_Mode_3
(rtb_Lane_Display_Mode_3);
/* Switch: '/Switch3' */
if (tmp != 0.0) {
rtb_Lane_Display_Mode_4 = 94;
}
/* Outport: '/Display_Mode_4' incorporates:
* Switch: '/Switch3'
*/
Rte_IWrite_Highway_Lane_Assistant_Model_Step_Pp_Display_Mode_4_DE_Display_Mode_4
(rtb_Lane_Display_Mode_4);
}
/* Model initialize function */
void Highway_Lane_Assistant_Model_Init(void)
{
/* (no initialization code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
--------------------------------------------------------------------------------------------------------------
/*
* File: /*
* File: Highway_Lane_Assistant_Model.h
*
* Code generated for Simulink model 'Highway_Lane_Assistant_Model'.
*
* Model version : 1.23
* Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
* C/C++ source code generated on : Fri Jan 19 08:42:28 2024
*
* Target selection: autosar.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives:
* 1. Execution efficiency
* 2. RAM efficiency
* Validation result: Not run
*/
#ifndef RTW_HEADER_Highway_Lane_Assistant_Model_h_
#define RTW_HEADER_Highway_Lane_Assistant_Model_h_
#ifndef Highway_Lane_Assistant_Model_COMMON_INCLUDES_
#define Highway_Lane_Assistant_Model_COMMON_INCLUDES_
#include "rtwtypes.h"
#include "Rte_Highway_Lane_Assistant_Model.h"
#endif /* Highway_Lane_Assistant_Model_COMMON_INCLUDES_ */
/* PublicStructure Variables for Internal Data, for system '' */
typedef struct {
uint8 is_active_c1_Highway_Lane_Assis;/* '/Chart' */
uint8 is_c1_Highway_Lane_Assistant_Mo;/* '/Chart' */
uint8 is_active_c3_Highway_Lane_Assis;/* '/Chart' */
uint8 is_c3_Highway_Lane_Assistant_Mo;/* '/Chart' */
} ARID_DEF;
/* PublicStructure Variables for Internal Data */
extern ARID_DEF rtARID_DEF; /* '/Chart' */
/*-
* The generated code includes comments that allow you to trace directly
* back to the appropriate location in the model. The basic format
* is /block_name, where system is the system number (uniquely
* assigned by Simulink) and block_name is the name of the block.
*
* Use the MATLAB hilite_system command to trace the generated code back
* to the model. For example,
*
* hilite_system('') - opens system 3
* hilite_system('/Kp') - opens and selects block Kp which resides in S3
*
* Here is the system hierarchy for this model
*
* '' : 'Highway_Lane_Assistant_Model'
* '' : 'Highway_Lane_Assistant_Model/Highway_Display_Model'
* '' : 'Highway_Lane_Assistant_Model/Lane_Display_Model'
* '' : 'Highway_Lane_Assistant_Model/Highway_Display_Model/Chart'
* '' : 'Highway_Lane_Assistant_Model/Lane_Display_Model/Chart'
*/
#endif /* RTW_HEADER_Highway_Lane_Assistant_Model_h_ */
/*
* File trailer for generated code.
*
* [EOF]
*/
*
* Code generated for Simulink model 'Highway_Lane_Assistant_Model'.
*
* Model version : 1.23
* Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
* C/C++ source code generated on : Fri Jan 19 08:42:28 2024
*
* Target selection: autosar.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives:
* 1. Execution efficiency
* 2. RAM efficiency
* Validation result: Not run
*/
#ifndef RTW_HEADER_Highway_Lane_Assistant_Model_h_
#define RTW_HEADER_Highway_Lane_Assistant_Model_h_
#ifndef Highway_Lane_Assistant_Model_COMMON_INCLUDES_
#define Highway_Lane_Assistant_Model_COMMON_INCLUDES_
#include "rtwtypes.h"
#include "Rte_Highway_Lane_Assistant_Model.h"
#endif /* Highway_Lane_Assistant_Model_COMMON_INCLUDES_ */
/* PublicStructure Variables for Internal Data, for system '' */
typedef struct {
uint8 is_active_c1_Highway_Lane_Assis;/* '/Chart' */
uint8 is_c1_Highway_Lane_Assistant_Mo;/* '/Chart' */
uint8 is_active_c3_Highway_Lane_Assis;/* '/Chart' */
uint8 is_c3_Highway_Lane_Assistant_Mo;/* '/Chart' */
} ARID_DEF;
/* PublicStructure Variables for Internal Data */
extern ARID_DEF rtARID_DEF; /* '/Chart' */
/*-
* The generated code includes comments that allow you to trace directly
* back to the appropriate location in the model. The basic format
* is /block_name, where system is the system number (uniquely
* assigned by Simulink) and block_name is the name of the block.
*
* Use the MATLAB hilite_system command to trace the generated code back
* to the model. For example,
*
* hilite_system('') - opens system 3
* hilite_system('/Kp') - opens and selects block Kp which resides in S3
*
* Here is the system hierarchy for this model
*
* '' : 'Highway_Lane_Assistant_Model'
* '' : 'Highway_Lane_Assistant_Model/Highway_Display_Model'
* '' : 'Highway_Lane_Assistant_Model/Lane_Display_Model'
* '' : 'Highway_Lane_Assistant_Model/Highway_Display_Model/Chart'
* '' : 'Highway_Lane_Assistant_Model/Lane_Display_Model/Chart'
*/
#endif /* RTW_HEADER_Highway_Lane_Assistant_Model_h_ */
/*
* File trailer for generated code.
*
* [EOF]
*/
-------------------------------------------------------------------------------------------------------------------------------------
/*
* File: rtwtypes.h
*
* Code generated for Simulink model 'Highway_Lane_Assistant_Model'.
*
* Model version : 1.23
* Simulink Coder version : 9.9 (R2023a) 19-Nov-2022
* C/C++ source code generated on : Fri Jan 19 08:42:28 2024
*
* Target selection: autosar.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives:
* 1. Execution efficiency
* 2. RAM efficiency
* Validation result: Not run
*/
#ifndef RTWTYPES_H
#define RTWTYPES_H
/* Logical type definitions */
#if (!defined(__cplusplus))
#ifndef false
#define false (0U)
#endif
#ifndef true
#define true (1U)
#endif
#endif
/*=======================================================================*
* Target hardware information
* Device type: Intel->x86-64 (Windows64)
* Number of bits: char: 8 short: 16 int: 32
* long: 32 long long: 64
* native word size: 64
* Byte ordering: LittleEndian
* Signed integer division rounds to: Zero
* Shift right on a signed integer as arithmetic shift: on
*=======================================================================*/
/*=======================================================================*
* Fixed width word size data types: *
* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
* real32_T, real64_T - 32 and 64 bit floating point numbers *
*=======================================================================*/
typedef signed char int8_T;
typedef unsigned char uint8_T;
typedef short int16_T;
typedef unsigned short uint16_T;
typedef int int32_T;
typedef unsigned int uint32_T;
typedef long long int64_T;
typedef unsigned long long uint64_T;
typedef float real32_T;
typedef double real64_T;
/*===========================================================================*
* Generic type definitions: boolean_T, char_T, byte_T, int_T, uint_T, *
* real_T, time_T, ulong_T, ulonglong_T. *
*===========================================================================*/
typedef double real_T;
typedef double time_T;
typedef unsigned char boolean_T;
typedef int int_T;
typedef unsigned int uint_T;
typedef unsigned long ulong_T;
typedef unsigned long long ulonglong_T;
typedef char char_T;
typedef unsigned char uchar_T;
typedef char_T byte_T;
/*=======================================================================*
* Min and Max: *
* int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
* uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
*=======================================================================*/
#define MAX_int8_T ((int8_T)(127))
#define MIN_int8_T ((int8_T)(-128))
#define MAX_uint8_T ((uint8_T)(255U))
#define MAX_int16_T ((int16_T)(32767))
#define MIN_int16_T ((int16_T)(-32768))
#define MAX_uint16_T ((uint16_T)(65535U))
#define MAX_int32_T ((int32_T)(2147483647))
#define MIN_int32_T ((int32_T)(-2147483647-1))
#define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU))
#define MAX_int64_T ((int64_T)(9223372036854775807LL))
#define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL))
#define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL))
/* Block D-Work pointer type */
typedef void * pointer_T;
/* Include definitions for AUTOSAR Standard and Platform data types. */
#include "Std_Types.h"
#endif /* RTWTYPES_H */
/*
* File trailer for generated code.
*
* [EOF]
*/