Main Content

Generate Simulink Blocks for MCAL APIs

The AUTOSAR XML (ARXML) files of the automotive open system architecture (AUTOSAR) standard describe software, hardware, and configuration data within an AUTOSAR project. You can use parser function of the bswmdArxml class to parse the Basic Software module description (BSWMD) ARXML files and extract API information. Based on your application requirement, you can add API blocks or generate Simulink® blocks for peripheral modules used in your AUTOSAR project.

  • To generate a Simulink library with API blocks, execute these commands.

    arxmlObj = bswmdArxml.parser('path to ARXML files'); % Reads ARXML files and extracts the list of APIs available in the ARXML files.
    arxmlObj.createSimulinkLibrary; % Creates Simulink library. 
    

    For example, execute these commands to generate a Simulink library for analog‑to‑digital converter (ADC) modules.

    arxmlObj = bswmdArxml.parser('J:\MyCDDProject\Adc_Bswmd.arxml');
    arxmlObj.createSimulinkLibrary;
  • To add an API block to the model, execute these commands.

    arxmlObj = bswmdArxml.parser('path to ARXML files'); % Reads ARXML files and extracts the list of APIs available in the ARXML files.
    APINames = arxmlObj.apilist % Lists all APIs available in the arxml file.
    arxmlObj.addapiblock('API name', 'path to the model'); % Adds specified API block to the model.

    For example, execute these commands to add an ADC_ReadGroup API block to the specified model.

    arxmlObj = bswmdArxml.parser('J:\MyCDDProject\Adc_Bswmd.arxml');
    APINames = arxmlObj.apilist;
    arxmlObj.addapiblock('ADC_ReadGroup', 'J:\MyCDDProject\myModel.slx');
  • To generate a Simulink library based on defined block specifications, execute these commands.

    arxmlObj = bswmdArxml.parser('path to ARXML files'); % Reads ARXML files and extracts the list of APIs available in the ARXML files.
    APINames = arxmlObj.apilist % Lists all APIs available in the ARXML file.
    apiInfo = arxmlObj.apispec % Lists specifications corresponding to each APIs.
    blkObj = arxmlObj.blockspec % Lists block properties from the ARXML library. You can set the parameters as per the application requirement.
    arxmlObj.setblockspec('block name', 'parameters') % Sets block specifications.
    arxmlObj.createSimulinkLibrary % Creates Simulink library.

    For example, execute these commands to generate a Simulink library for ADC. Simulink applies the defined parameters to the ADC_ReadGroup API block within the library.

    arxmlObj = bswmdArxml.parser('J:\MyCDDProject\Adc_Bswmd.arxml');
    APINames = arxmlObj.apilist;
    apiInfo = arxmlObj.apispec;
    blkObj = arxmlObj.blockspec;
    arxmlObj.setblockspec('ADC_ReadGroup', 'Group’, Scope="Parameter", Legend="grp")
    arxmlObj.createSimulinkLibrary;

  • To generate a Simulink library with specific API blocks, execute these commands.

    arxmlObj = bswmdArxml.parser('path to ARXML files'); % Reads ARXML files and extracts the list of APIs available in the ARXML files.
    APINames = arxmlObj.apilist % Lists all the available APIs.
    apiInfo = arxmlObj.apispec % Lists properties of APIs.
    blkObj = arxmlObj.blockspec % Lists block properties from the ARXML library. You can set the parameters as per the 
    arxmlObj.createSimulinkLibrary(ApiList={'API name 1', 'API name 2', ..}) % Creates Simulink library with specified API blocks.

    For example, execute the following commands to generate an ADC Simulink library containing only the ADC_Init and ADC_ReadGroup API blocks. Simulink applies the defined parameters to these blocks within the library.

    arxmlObj = bswmdArxml.parser('J:\MyCDDProject\Adc_Bswmd.arxml');
    APINames = arxmlObj.apilist
    apiInfo = arxmlObj.apispec({'Adc_Init', 'ADC_ReadGroup'})
    blkObj = arxmlObj.blockspec({'ADC_Init', 'ADC_ReadGroup'})
    arxmlObj.setblockspec('ADC_Init', 'Group’, Scope='Parameter', Legend='grp');
    arxmlObj.setblockspec('ADC_ReadGroup', {'Status', 'DataBufferPtr'}, Scope={'Output', 'Output'}, Legend={'status', 'result'}, Size={'1', '[1 2]'}, Type={'uint8, 'uint16'});
    arxmlObj.createSimulinkLibrary(ApiList={'ADC_Init', 'ADC_ReadGroup'});

See Also

Topics