CN102622470A - General car code conversion method - Google Patents

General car code conversion method Download PDF

Info

Publication number
CN102622470A
CN102622470A CN2012100392776A CN201210039277A CN102622470A CN 102622470 A CN102622470 A CN 102622470A CN 2012100392776 A CN2012100392776 A CN 2012100392776A CN 201210039277 A CN201210039277 A CN 201210039277A CN 102622470 A CN102622470 A CN 102622470A
Authority
CN
China
Prior art keywords
configuration
code
module
function
api
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN2012100392776A
Other languages
Chinese (zh)
Inventor
蒋建春
刘先东
左文英
岑明
邱宝梅
李银国
冯辉宗
舒适
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing University of Post and Telecommunications
Original Assignee
Chongqing University of Post and Telecommunications
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing University of Post and Telecommunications filed Critical Chongqing University of Post and Telecommunications
Priority to CN2012100392776A priority Critical patent/CN102622470A/en
Publication of CN102622470A publication Critical patent/CN102622470A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention relates to a general car code conversion method. Based on a general simulation and code generation tool, MATLAB (matrix laboratory), a vehicular operating system model base meeting specifications of OSEK/VDX OS (open systems and their interfaces for the electronics in motor vehicles/vehicle distributed eXecutive operating system) and an underlying drive interface model base meeting standards of AutoSAR (AUTomotive Open System ARchitecture) are designed, and a vehicular electronic control unit control model is graphically established. According to a designed code generation template, an available control/simulation code framework is generated using RTW (real time workshop), a code generation mechanism, the operating system and underlying drive are added into a compiler to implement a function library or source code, and conversion of different ECU (electronic control unit) executable codes meeting the specifications above is compete. The trouble of manually compiling the codes is avoided, fast generation of the codes is realized, development cycle is accelerated, expertise requirements on developers are lowered, and code reliability is improved.

Description

A kind of General Motors code conversion method
Technical field
The present invention relates to automotive electronics rapid prototyping and code Generation field, particularly a kind of automobile code conversion method.
Background technology
In the face of requirements such as the reliability of current automobile electronic control unit embedded software, consistance, interchangeability, high-level efficiency.The instrument that is used for the generation of automobile electronic control unit embedded software code at present is main with external specific purpose tool mainly; These instruments often rely on the special hardware and the running environment of exploitation enterprise; Generating code can't be unified and standard, limited consistance and interchangeability demand for development that industry proposes.Design a can compatible typical number modeling and simulating instrument, having extendability is the industry common recognition with open code generating method and system.
The automobile electronic control unit software development is a very complicated process, simultaneously, and problem such as, interchangeability lack of standardization, portable at automotive electronics software industry long-term existence code, reusability difference and program development efficient are low.And OSEK OS is embedded OS (RTOS) standard that is widely used in vehicle electric field; It has defined some basic system services; Such as task processing, interrupt service routine (ISR) processing, resource management, event handling and alert service etc., can unify calling and managing of application program.AutoSAR tissue has defined the interface specification of automobile electronic control unit hardware drive program, the routine interface that can unify different chip equal modules with call.At present; OSEK application development flow process is the manual earlier kernel configuration file of writing or using configuration tool generation OSEK OS; Manually add application code, re-use compilation tool this kernel configuration file, User Defined code and OSEK OS kernel file are compiled into final executable file.This traditional programming mode is not only loaded down with trivial details, and easy error, and very high to program development personnel's requirement, code development efficient is low, more and more is not suitable for the design and the realization of large scale system.Along with the development of modeling and simulating software, extensively promoted based on the Model Design method, improved the development efficiency of system greatly.And be exactly the automatic code generation technique based on the technology of a core in the development approach of model.
DSPACE combines many motor-dom users' requirement, has developed a kind of novel code Core Generator Targetlink specially, and it can accomplish the production from the MATLAB/Simulink/Stateflow controlling models to product code within several seconds.The code reliability that generates is high, and is readable good, adapts to multiple microprocessor and compiler.Utilizing Targetlink to carry out code generates; At first will carry out the conversion between Sinulink model and the Targetlink model, but Targetlink only supports Simulink module fairly simple and commonly used at present, like clock; The continue module, Targetlink is unsupported.
The RTW of Mathworks company is comparatively ripe aspect code Generation.RTW can be directly generates from the Simulink model and has product level C code quality, that be used for real-time system and can easily model conversion be become the C language codes.The user can set up system model very easily through Simulink, utilizes the RTW instrument that model conversion is become embedded code then, need not manual programming.Therefore; How will generate related tool based on the system API of the bottom layer driving standard of OSEK OS standard, AutoSAR and other codes combines with Matlab/Simulink; Design a system that apace the Vehicle Electronic Control algorithm is created on the code that can directly move in the ECU; With the exploitation that is very easy to the automotive electronics embedded control system, improve development efficiency.
At present, though Matlab provides several kinds of exemplary processor hardware driving interface models, the function model of each processor is all different, and this makes troubles for the generation of code and transplanting, can not satisfy the needs of different automobiles and ECU.Simultaneously the ununified system function model based on OSEK in Matlab can not be set up the task model based on OSEK operating system fast, also just can not generate general, with the automotive electronics embedded software model and the code of hardware independent.
Summary of the invention
The object of the invention just provides a kind of General Motors code conversion method, and it has avoided manually writing the loaded down with trivial details of code, has realized the quick generation of code, when accelerating the construction cycle, has reduced the requirement of developer's specialty, has also improved the reliability of code.
The objective of the invention is to realize that through such technical scheme the code conversion step is following:
1) set up task at the Simulink workbench, this task is the function that the software code of required conversion is accomplished;
2) according to selected ECU, confirm code content and form under OSEKOS operating system standard and the AutoSAR driving interface standard, and set up the tool box respectively;
3) the software code information of required conversion is imported the S function, this S function is by step 2) described in the tool box confirm;
4) the S function in the step 3) is encapsulated, be packaged into the operational module of Simulink workbench;
5) operational module after the encapsulation in the step 4) is imported the Simulink workbench;
6) under the Simulink workbench, the operational module that checking imports is not through then returning step 1), through then changing step 7) over to;
7) under the RTW platform, will carry out code conversion through the software code that the S function imports;
8) generating code configuration file and code content file;
9) configuration file of code described in the step 8) and code content file are added the compiler engineering, generate final required code.
Further, the method for designing in OSEK tool box is: based on the OSEK standard, carry out OSEK object configuration module and OSEK API Module Design, utilize the S function to carry out the establishment and the encapsulation of module then.
Further, the modeling method in OSEK tool box is:
At first in Simulink control algolithm model, add relevant OSEK object configuration module, and corresponding parameter is set;
Secondly add OSEK tool box API module and correlation parameter is set according to model tasks, realize the division of task framework;
Emulation and code through model generates the use that realizes the OSEK tool box automatically at last.
Further, the method for designing that the code in OSEK tool box generates template is: OSEK tool box code generates template and comprises two parts,
It is the OIL configuration file that OSEK object configuration module code generates stencil design, and interpolation OIL configuration file is converted into object code in the OSEK configuration tool;
OSEK tool box API block code generates template and obtains the code generation that API module parameter information realizes OSEK tool box API module through module TLC file.
Further; The method for designing of OSEK configuration tool is: be configured the design of instrument with the form of static module, encapsulate with the form of class, according to the function and the logic requirement of software; It is divided into presentation layer, functional layer and data Layer three-decker, carries out modular design and realization.
Further, the type of said AutoSAR driving interface standard is wherein a kind of among ADC, CAN, DIO, EEPROM, FLASH, GPT, LIN, PORT, PWM, WDG, ICU, MCU or the SPI.
Further, based on AutoSAR standard driven tool case method for designing be: the tool box is designed to configuration module and API module,
Driven tool case configuration module design comprises chip and selects that configuration, header file comprise, configuration file generates and drives the API switch, drive four parts of initialization relevant configuration, the various piece parameter configuration through conditional-variable with generate configuration file and realize the relevance that disposes with the chip selection;
Driven tool case API modular design is divided into driving api function parameter configuration and rreturn value transmission; Wherein the rreturn value transmission by definition in the configuration file that generates and statement global variable and in function body assignment realize the quick expansion of the interpolation implementation tool case of the API module that interpolation through the configuration of configuration module correlation parameter during the chip configuration expansion and extended chip are relevant.
Further, the modeling method based on AutoSAR standard driven tool case is:
At first in the Simulink controlling models, add the drive arrangements module;
Secondly in the drive arrangements module, select chip configuration and accomplish its relevant parameter realization driving function of initializing is set;
In the Simulink controlling models, add once more and drive the API module and dispose correlation parameter; Generate through model emulation and automatic code at last and accomplish the application that drives.
Further, driven tool case code generates template design method and is: driven tool case code generates the design of template based on module TLC, and it is divided into configuration module TLC template and API module TLC template,
The configuration module code generate template be divided into header file comprise code, chip select configuration down configuration file generate and API switch, chip select configuration to drive the initial configuration three parts down; The each several part code content provides conditional-variable and configuration file to realize the relevance of selecting with chip
Driven tool case API block code generates template and comprises and drive that api function calls and parameter configuration code, the api function rreturn value transmission two large divisions that realized by the definition global variable, when chip configuration expand through add the quick expanded function that related content realizes code generation template at each several part.
Owing to adopted technique scheme, the present invention to have following advantage:
The present invention adds OSEKOS api function and the bottom layer driving interface function that meets the AutoSAR standard in the Simulink model bank to the form of Simulink module, sets up model with graphical form, and parameter configuration and task creation are carried out simultaneously; Code according to design generates template; Utilize the RTW code generation mechanism, generate available control, simulation code framework, in compiler, add operating system and bottom layer driving realization function library or source code again; Generate different ECU run time versions; Avoided manually writing the loaded down with trivial details of code, realized the quick generation of code, when accelerating the construction cycle; Reduce the requirement of developer's specialty, also improved the reliability of code.
Other advantages of the present invention, target and characteristic will be set forth in instructions subsequently to a certain extent; And to a certain extent; Based on being conspicuous to those skilled in the art, perhaps can from practice of the present invention, obtain instruction to investigating of hereinafter.Target of the present invention and other advantages can realize and obtain through following instructions and claims.
Description of drawings
Description of drawings of the present invention is following.
Fig. 1 is general technical skeleton code flow path switch figure;
Fig. 2 is the structural drawing in OSEKOS tool box;
Fig. 3 is the design cycle in OSEK tool box;
Fig. 4 is driven tool case method for designing figure;
Fig. 5 is driven tool case ADC module realization flow figure;
Fig. 6 is that structural representation is formed in the bottom layer driving tool box;
Fig. 7 is that driven tool case code generates template design method figure.
Embodiment
Below in conjunction with accompanying drawing and embodiment the present invention is described further.
A kind of General Motors code conversion method, the code conversion step is following:
1) set up task at the Simulink workbench, this task is the function that the software code of required conversion is accomplished;
2) according to selected ECU, confirm code content and form under OSEKOS operating system standard and the AutoSAR driving interface standard, and set up the tool box respectively;
3) the software code information of required conversion is imported the S function, this S function is by step 2) described in the tool box confirm;
4) the S function in the step 3) is encapsulated, be packaged into the operational module of Simulink workbench;
5) operational module after the encapsulation in the step 4) is imported the Simulink workbench;
6) under the Simulink workbench, the operational module that checking imports is not through then returning step 1), through then changing step 7) over to;
7) under the RTW platform, will carry out code conversion through the software code that the S function imports;
8) generating code configuration file and code content file;
9) configuration file of code described in the step 8) and code content file are added the compiler engineering, generate final required code.
General technical skeleton code flow path switch of the present invention is as shown in Figure 1; The S function that at first will meet the S function of OSEKOS standard and meet AutoSAR bottom layer driving interface specification is designed to the Simulink module; These modules are added in the Simulink model bank with the form in tool box, realize graphical form task modeling, parameter configuration, design these model code then and generate template; Utilize the RTW code generation mechanism; Directly generate available control, simulation code framework, in compiler, add operating system and bottom layer driving realization function library or source code again, generate different ECU run time versions; Avoided manually writing the loaded down with trivial details of code, realized the quick generation of code.
The OSEKOS standard comprises OS, COM, OIL, four parts of NM, is the unified standard of automotive electronics embedded software, at home and abroad is widely used.The present invention utilizes its versatility exactly, and design is based on OS, COM, the NM tool box of Simulink, and wherein OS, COM tool box meet the OIL code requirement.Utilize these tool boxes can set up the os-task model; Simulink is set up control algolithm and model adds in the task model; Set up task to destination OS and application-specific; Module is carried out the operating system configuration,, utilize RTW to generate the configuration file of available control, simulation code and OIL/XML form then like configurations such as task, interruption, message, clocks.
The AutoSAR standard is the unified standard of automobile electronic control unit software development, and it has defined software architecture and the standard of various piece thereof in the automobile electronic control unit software development process, at home and abroad is widely used.This has driven the interface of the identical peripheral hardwares of various chips unified and standard, and the software of being convenient to different manufacturers, different software exploitation enterprise equal modules exchanges, and improves the interchangeability of software, is the development trend of following automobile electronic control unit software.Wherein, the bottom layer driving standard has more practical significance, has unified the hardware access interface, is convenient to automobile enterprise and changes different HardwareUpgring system performances.Therefore, the present invention utilizes the versatility of this standard, and design is based on the bottom layer driving tool box of Simulink.
Utilize this tool box when setting up the os-task model; Can be directly through adding the bottom layer driving model; Through the configuration driven program parameter, set up getting in touch of algorithm, application program, operating system and hardware, utilize RTW to generate the configuration file and the C language application program code skeleton of available control, simulation code and OIL/XML form then; Combine corresponding function library again, in compiler, generate executable code fast.
The design code generation module; According to OSEKOS standard and AutoSAR standard; According to the model configuration requirement; The code of design OSEK OS api function module, OIL configuration object module and various AutoSAR driver module functions generates template, generates corresponding configuration file, C source files of program, the generate pattern of controlled target language codes according to the model configuration requirement.
Though in Simulink, operating system, COM, NM and driving interface are disposed; Also can generate corresponding C language configuration file through template; But can not solve the validation problem that calls between task module, therefore need operating system of design and driver deployment and verification tool, realize the checking of application program function call; Simultaneously can also pass through this instrument manual configuration operation system and driver, be convenient to other user who does not need the Simulink instrument and use.This instrument can read by the XML of RTW instrument generation among the Simulink or the configuration file of OIL form; Be configured the conversion of information; Convert the configuration file of OIL/XML form in the engineering needed C language configuration file, directly add in the engineering that compiler sets up and compile.
Driven tool case based on Simulink mainly is made up of initial configuration module and api function module.The configuration module of driven tool case is selected the configuration of chip associated driving function through parameter configuration, has shielded the otherness of different chips, the controlled device that can replace different chip processors fast.Foundation good back in driver module storehouse just can directly be added in the actual control algolithm model, utilizes RTW to generate the available code of driven application efficiently then, combines corresponding driving resource function storehouse again, the quick executable code that generates in compiler.
The design driven application code generates template; According to the AutoSAR standard; Code according to driven application Demand Design various AutoSAR driver module function and the configuration of initialization function under the different processor configurations generates template; Generate corresponding configuration file, C source files of program etc., the generate pattern of controlled target language codes according to the model configuration requirement.Only need in code generation ATL, to realize the extensibility that code generates through the template file that increases the different processor chip.
Bottom layer driving interface function based on the AutoSAR standard adds in the Simulink model bank with the form of Simulink module, sets up model with graphical form, and the driven application under the different processor configuration is configured; Replace the central plant model of modeling and simulating fast, and generate template, utilize the RTW code generation mechanism according to the code of design; Realize the selection of different chips and the setting of relevant parameter through configuration module; Realize the quick generation of code, the otherness of shielding chip generates the available driving code to multiprocessor; In compiler, add bottom layer driving resources bank or source code again; Generate different ECU run time versions, avoided manually writing the loaded down with trivial details of code, realized the quick replacement of control system controlled device; Save the control system development time, also improved the reliability and the portability of code.
Specific embodiments of the present invention is divided into four aspects: the first, and design of OSEKOS tool box and encapsulation; The second, based on design of AutoSAR standard driven tool case and realization; The 3rd, OSEKOS tool box code generates the design of template; The 4th, driven tool case code generates the design and the realization of masterplate; The 5th, configuration and verification tool design.
The first, design of OSEKOS tool box and encapsulation
1. OSEKOS tool box design
The structural drawing in the OSEKOS tool box of the present invention's design is as shown in Figure 2; Comprise OSEKOS object configuration module and OSEKOS API module, OSEKOS API module comprises task module, alarm module, event module, resource module, message module and interruption processing module again.
(1) OSEK object configuration module design
OSEKOS OIL belongs to one of standard of OSEKOS, and target is to realize the OSEK portability of application programs, quick definition a series of OSEK object, the OSEK application program is described, CPU is defined as the container of all OSEK objects.Each OSEK object has all comprised some standard attributes, also can be expanded simultaneously.The present invention is configured the OIL object moduleization in the Simulink modeling to the OSEK object.Through the OSEK object is carried out the attribute setting, the configuring condition of descriptive system well.The OSEK object configuration module of the present invention's design and the attribute that will dispose thereof are as shown in table 1:
Table 1 OSEK object and attribute configuration table thereof
Figure 2012100392776100002DEST_PATH_IMAGE001
(2) OSEKOS API modular design
OSEKOS API module has comprised the api function relevant with task, warning, incident, resource, message and Interrupt Process.According to the OSEK standard, relevant parameters that each OSEK API module is all corresponding, table 2 has been listed the OSEK API module title of the present invention's design and the parameter that will dispose thereof.
Table 2 OSEK OS API modular design table
2. the OSEK tool box is created
The design cycle in OSEK tool box is as shown in Figure 3, in the process of creating the OSEK tool box, need be S function of each modular design, and the corresponding S function of each module will be according to the configuration parameter of listing in table 1, the table 2, statement relevant parameters variable.
The S function is write and is finished, and the S-Function module that carries through Simulink encapsulates the S function.
The second, based on design of AutoSAR standard driven tool case and realization
1. based on the method for designing of the driven tool case of AutoSAR standard
(1). the demand of driven tool case and function
Target Support Package tool box is the driver module storehouse to processor designs such as MPC55x series and DSP series in the Matlab/Simulink model bank.Driver module all is to support the processor chips design to specific target, and different chip configuration is to there being different driver modules, and this has just limited the versatility of driver module.Chip for driving configuration more complicated, during use to the requirement of hardware also than higher, brought very big inconvenience to the user.Great majority are drivings of genuine dsp chip in the tool box, and are specific several moneys, drive expansion and are difficult to realize.Can know that by last analysis there is the driver module specificity in Target Support Package tool box, objective chip support limited and expansion difficult, defective such as the target supporting chip of Vehicle Electronic Control class is few.In view of these deficiencies of Simulink Central Plains Driver Library, the present invention proposes the design based on the driven tool case of the highly versatile of AutoSAR standard.Require the driven tool case of design to have versatility, can satisfy Auto Electronic Controlled System and under different chip configuration, generate corresponding driven application code, realize the quick replacement of controlled device in the system model.
Satisfy the generation of driven application code under the different chip configuration based on the driven tool case of AutoSAR standard, the versatility and the extendability of shielding chip differences property realization driven tool case.The driven tool case is divided into drive arrangements module and api function module, and the drive arrangements module realizes the initialized relevant configuration of driving function under the different chip configuration, and the api function module realizes driving the api function parameter configuration and rreturn value is transmitted parameter configuration.The user selects chip and the corresponding driving initialization correlation parameter of configuration through the drive arrangements module, combines code to generate masterplate again and realizes the driven application setup code under the selected chip configuration.Driving function parameter and rreturn value parameter in user's configuration driven API module generate masterplate in conjunction with code and generate the driving function application code.
(2). the method for designing of driven tool case
Design based on the driven tool case of AutoSAR standard can be divided into three parts according to content: the format and content that driven tool case code generates confirm, write S function setup driver module configuration parameter variable, design S function driver module.Fig. 4 is a driven tool case method for designing synoptic diagram, introduces detailed design cycle below in conjunction with this figure.
1.. confirm content and form that driven tool case code generates
The realization of bottom layer driving code requires specific chip configuration that corresponding driving setup code and api function code are arranged in the Auto Electronic Controlled System.According to the requirement of driven application code, behind selected chip, to carry out initialization to driving function.For this reason; Driven tool case generating code content is the two large divisions: the one, and initialization section, it mainly comprises, and the chip condition is selected, the configuration that comprises, drives initialization function and structure parameter configuration, configuration file generation and driving API switch of driving head file; The 2nd, the api function code section mainly is the realization that api function parameter configuration and function call and api function rreturn value are transmitted code.
Generate content according to code, driven tool case code generates form and also is divided into the two large divisions, and promptly code generates initial configuration and api function configuration.The initial configuration part: code generation form is divided into chip and selects configuration, header file to comprise, drive the configuration of initialization function, the generation of drive arrangements file and four parts of driving API switch configuration.At first selected chip configuration, next comprises the relevant header file, once more according to the corresponding driving initialization function parameter of selected chip configuration and add in the relevant configuration file, in the relevant configuration file, adds the API switch according to selected chip and disposes at last.Drive the api function configuration section: code generates form and is divided into api function parameter configuration and function return value configuration.Provisioning API function interface variable at first, next adds configuration variables in the drive arrangements file, last provisioning API function parameter and function code.
2.. generate requirement according to code and confirm driven tool box function module
Driven tool case code generates and is divided into initial configuration and api function configuration two parts; Drive the initial configuration module and drive API module two large divisions so the tool box functional module also is divided into, wherein the api function module can be divided into the API module of band rreturn value transmission and not with the API module of rreturn value according to the interface setting again.Mainly comprised in each driver module storehouse in the tool box and driven initial configuration module, the API module of band rreturn value transmission and three types of functional modules of API module of not transmitting with rreturn value.For example drive and comprise mainly in the ADC module library that functional module has the API modules A dc_ReadGroup of ADC initial configuration modules A dc_Config, band rreturn value transmission and three types of the API modules A dc_Deinit that do not transmit with rreturn value.
3.. write the S function, the configuration driven module parameter
Set up driver module and will write the S function, in the S function all parametric variables in the module are defined.In the S function, call the each several part power function and realize that definition, interface initialization and the parameter of the configuration parameter of driver module are delivered among the RTW.Following table is drive arrangements module and driving API module are called each power function configuration module parameter in the S function a details.
Table 3 S function parameter allocation list
Figure 2012100392776100002DEST_PATH_IMAGE003
4.. the relation of analysis configuration module and other modules, design driven configuration module
The function of drive arrangements module is the configuration that realize to drive the corresponding initiation parameter of api function, is mainly reflected in two aspects with the relation of other modules, and the function parameter configuration is disposed with module interface.Function parameter configuration aspect: initialization structure parameter and other modularity function parameter configuration are consistent in the configuration module, and the configuration of api function switch is consistent with other modules A PI function call in the configuration module.Module interface configuration aspect: whether other module interface configuration tool functions have rreturn value is divided into dual mode, the band rreturn value pass through the defining variable configuration interface, do not pass through parameter configuration realization interface configuration with rreturn value.The defining variable configuration interface, variable-definition realizes in the configuration file that configuration module generates with statement in other modules; Parameter/configuration interface, the configuration of the function parameter of other modules and the configuration of configuration module initiation parameter are consistent.The tool configuration block code generate to require and can confirm the main contents of configuration module with the relation of other modules.
The main contents of drive arrangements modular design are that chip is selected, header file comprises and configuration file generation, User Defined utility function and driving initial configuration parameter and driving api function relevant configured parameter.To be divided into four parts be that chip is selected to comprise with header file and configuration file generates configuration, User-Defined Functions configuration, drives initialization structure parameter and the configuration of initialization function, driving api function switch to parameter configuration in configuration module.The parameter configuration of various piece is all in real time related with the chip selection, and following table is an each several part parameter configuration details.
Table 4 drive arrangements module parameter allocation list
Figure 2012100392776100002DEST_PATH_IMAGE005
5.. analyze API module interface method to set up, design driven API module
Module interface setting can be divided into two kinds, promptly with the api function interface of rreturn value with not with the api function interface of rreturn value.The band rreturn value pass through the defining variable configuration interface, definition statement global variable comes the setting of transport function rreturn value realization function interface in module; The parameter configuration of passing through with rreturn value does not realize interface configuration, and the initiation parameter configuration is consistent and realizes the function interface setting in the configuration of function parameter and the configuration module in module.The API Module Design mainly is the setting and the function calls of module interface, and design content is embodied in the transmission configuration of function parameter configuration and rreturn value.
Driving the API Module Design mainly is the configuration of parameter and the transmission of rreturn value, only need define according to standard during parameter configuration to get final product, and the transmission of rreturn value is realized that by global variable the global variable definition is to be associated with in the configuration file of configuration module.By defining in the configuration file and stating, the transmission of the global variable completion rreturn value of definition is arranged in driving the API module.Following table is to drive each parameter configuration situation of API module:
Table 5 API module parameter allocation list
2. based on the realization of the driven tool case of AutoSAR standard
Design based on each driver module of the driven tool case of AutoSAR standard has consistance, and the implementation method of driver module also is similarly, below to drive the implementation method that example is introduced the driven tool tank module in detail that is embodied as of ADC module.
(1) function introduction of .ADC module
The ADC driver module is divided into drive arrangements module and api function module, and configuration module realizes driving the initiation parameter configuration of ADC to selected chip, and the api function module realizes driving calling and the rreturn value transmission of each api function code of ADC.
ADC drive arrangements block configuration parameter comprises that chip is selected, header file comprises, configuration file generates, drive ADC initialization function, API switch.Through the selected a chip of ADC configuration module, and, combine code to generate the masterplate generation again and drive the relevant initialization function code of ADC under selected chip configuration should chip configuration accomplishing the configuration that each several part drives the initialization correlation parameter.
The API block configuration parameter that ADC drives mainly is that ADC function parameters and rreturn value are transmitted configuration parameter.The function parameter of provisioning API module and rreturn value configuration parameter generate masterplate in conjunction with code and generate the rreturn value that drives ADC function call code and transmit api function.
Selected different chips in driving the ADC configuration module, and corresponding configuration driven initialization correlation parameter can be realized general between different chip processors.The API modularity function interface that ADC drives is unified, and when in configuration module, selecting different chip, the configuration correlation parameter realizes driving under the different chip configuration calling of api function in the API module.Drive arrangements module shielding chip differences property has strengthened the extendability of driven tool case.
(2) the concrete realization of .ADC module
Drive the ADC module and be divided into configuration module and API module, configuration module realizes driving under the different chip configuration configuration of ADC initialization correlation parameter, and the API module realizes the configuration that ADC function parameter and rreturn value are transmitted configuration parameter.Specifically realize ADC configuration module and API module according to driven tool tank module method for designing, realization flow is as shown in Figure 5.
. drive the realization of ADC configuration module
Drive the ADC configuration module and design based on chip XC167 and STM8, realization flow is following:
The first step is confirmed the content that ADC configuration module parameter configuration and code generate according to demand analysis and AutoSAR standard.The configuration module content of parameter comprises the chip selection, header file comprises and configuration file generation, User Defined application initializes function and initial configuration structure, ADC drive the api function switch.The configuration information of each several part sees the following form 6.
Table 6 drives ADC configuration module parameter list
Figure 2012100392776100002DEST_PATH_IMAGE009
Second step, write the S function, ADC configuration module parametric variable is set.The S function that drives the ADC configuration module mainly is three parts, and promptly macro definition is provided with the module parameter variable, calls mdlInitializeSizes function detected parameters variable, calls mdlRTW () function passes parametric variable to RTW.Back two-part parametric variable and macrodefined being consistent are write according to S function grammer and to be got final product.Macro definition is provided with configuration module each several part parametric variable form: #define variable name (ssGetSFcnParam (S, 1)), and concrete variant content is following:
Chip choice variable definition ChipConfig;
Header file comprises variable-definition FileInclude;
Configuration file generates variable-definition Adc_CfgCon;
User-Defined Functions parametric variable definition APPFcnName etc. comprises function name, type;
Drive the structure parameter under two chip configuration such as initialization structure parametric variable and initialization function parameter variable-definition Adc_ResolutionType;
API switch under two chip configuration such as driving API switch definition Adc_DeInit_API.
In the 3rd step, design ADC configuration module is realized the each several part parameter configuration.According to configuration module S function parameters variable design configurations module parameter, parameter configuration is based on XC167 and STM8 two chip.ADC configuration module parameter configuration is designed to four parts, in module realizes, carries out the parameter setting by four parts, is that the each several part parameter is provided with situation in detail below.
First, chip is selected, header file comprises, configuration file generates three partial parameters settings.Chip is selected by condition choice variable configuration chip_config, and header file comprises to be provided with and comprises and involved file name variable configuration filename, and configuration file generates by the configuration filename configuration filename_cfg that will generate;
Second portion, the User-Defined Functions parameter configuration.SQL name configuration fun_name, SQL type configuration fun_type, SQL parameter title configuration fun_parm_name, SQL parameter type configuration fun_parm_type;
Third part, ADC drives initialization structure parameter configuration and the configuration of initialization function parameter.The entire infrastructure body parameter of corresponding two chip configuration such as initialization structure parameter configuration Adc_GroupType, initialization function parameter configuration config_ptr;
The 4th part, the API switch configuration that ADC drives.Whole API switches of corresponding two chip configuration such as API switching variable configuration Adc_Read_Group_API;
Each several part and chip are selected the realization of relevance.Header file comprises that to generate with configuration file all be to be undertaken relatedly by the parametric variable value, and the module parameter configuration is constant.User-Defined Functions oil code generates masterplate and realizes relevance.Drive related the realization with condition judgment command control module configuration parameter array of initialization structure and initialization function and chip selection by writing the M file.Driving the API switch parameter selects related realization the same with driving initialization structure implementation method with chip.
. drive the realization of ADC storehouse API module
According to API modular design method, drive each api function module of ADC to the effect that api function parameter configuration and api function rreturn value transmission configuration.Function parameter is according to the configuration of AutoASAR standard, and the rreturn value transmission of api function is realized by global variable.The realization of API module is the same with the configuration module implementation method, and promptly determination module parameter configuration content is write S function setup variable, the configuration module parameter.The same configuration module of API module realization flow is no longer introduced here, and following table is an API module parameter configuration particular content.
Table 7 drives the API module parameter allocation list of ADC
Figure 2012100392776100002DEST_PATH_IMAGE011
(3). the driven tool case is created and specificity analysis
. the establishment of driven tool case
The structure of driven tool case is as shown in Figure 6, to adding the design of just having accomplished the driven tool case in the Simulink storehouse to after the driver module encapsulation that designs.Be to add the step of driven tool case below to the Simulink storehouse.At first the Library that includes 13 driver module storehouses that design is named, be defined as AutoSAR Driver Blocks here.Driver Library AutoSAR Driver Blocks adds in the Simulink module library by writing the M file.It is AutoSAR Driver Blocks that Browser in the M file (1) .Library=imports the title of setting up good driver module storehouse Library at the back, and the title that in the Simulink storehouse, manifests after adding is by Browser (1) .Name=back input.Be placed on M file slblocks.m that writes and driver module storehouse AutoSAR Driver Blocks under the same catalogue.The path is set in Matlab has at last just accomplished the interpolation of driven tool case in the Simulink storehouse for the path that keeps the driver module storehouse.
. driven tool case specificity analysis
The design of driven tool case is the center with the chip configuration, and shielding chip differences property realizes driving under the different chip configuration application of API, and its characteristics mainly contain:
Versatility.The driven tool case is designed to configuration module and drives the API module, and selected chip configuration in the configuration module sheet drives API module invokes driving function, realizes calling of driving function under the different chip configuration.The driven tool case has shielded chip differences property, greatly strengthens its versatility.
Relevance.Different chips select related different driving initializes configuration information, configuration file to generate information and header file comprises information in the configuration module of driven tool case.Simultaneously configuration module also related driving API correlation parameter, realized the related of configuration module and driving API module.
Rapidity.The driven tool tank module adds in the task model, after algoritic module calls driving, can replace the controlled device of algorithm model fast.Promptly in processor, come to replace fast the emulation controlled device in the algorithm model by the driven application code.
Extendability.The driven tool case is the center with the chip configuration, and related other each drive arrangements parts, and each several part is again to realize with unit-modularized form, for the expansion of driven tool case chip provides great convenience.
3. the extended method of driven tool case and realization
(1). the extended method of driven tool case
Design based on the driven tool case of AutoSAR standard is the center with the chip configuration, drives other configuration information standard and modulars, makes driver module shield the otherness of chip, has simplified the expansion of its chip configuration.The expansion of driven tool case is mainly reflected in the configuration module, and the extended method flow process is following.
1.. confirm to want the drive arrangements content of parameter of extended chip.Analyze the corresponding driving initializes configuration information of chip that to expand in the AutoSAR standard, promptly drive initialization structure parameter, the header file that comprises, relevant configuration file and corresponding driving API switch etc.
2.. add the parametric variable of expansion in the former configuration module S function.Mainly be the interpolation of the parametric variable under the extended chip configuration in the S function, parametric variable is added on appropriate section interpolation in the macro definition.In the S function parameter detecting with transmit parameter and carry out corresponding modification to the content of RTW according to the parameter in a macrodefinition variable and get final product.Be the interpolation of macro definition each several part in the S function below:
Macro definition chips choice variable part need not added, and the value interpolation gets final product in the module;
Header file comprises and generates configuration variables with configuration file and partly expand in the macro definition: value is added and is realized in the module;
Driving initialization structure parametric variable in the macro definition partly expands: add the corresponding driving initialization structure parametric variable of extended chip at the back at it;
Driving the API switching variable in the macro definition partly expands: add the corresponding API switching variable of extended chip in the back.
3.. the expansion of drive arrangements module each several part parameter configuration.In the configuration module each several part, add the parametric variable under the extended chip configuration, and it is real-time related to realize that each several part and chip are selected.Configuration module each several part parameter is concrete to be expanded as follows:
First adds the extended chip model in the chip choice variable value, it is constant that header file and configuration file generate configuration variables, composes different value for these variablees and can realize the chip expansion;
Second portion, User-Defined Functions partly remains unchanged, and composes different value to parameter and realizes the chip expansion;
Third part drives initialization structure argument section, in the driving initialization structure variable parameter of adding thereafter under the extended chip configuration;
The 4th part drives the api function switch sections, at the driving api function switch that adds thereafter under the extended chip configuration;
The relevance of selecting with chip after the expansion.Header file and configuration file part is by conditional-variable and combine code to generate template to realize related; Drive initialization structure parameter and api function switch sections and realize, and combine code to generate masterplate realization associated codes by writing in the M file condition case statement; User-Defined Functions generates masterplate by code and realizes related.
4.. drive the expansion of API module, original driving API module is constant, and the driving API module that does not have in the driven tool case is added in corresponding extended chip configuration.The extended method that drives the API module is the same with configuration module, in the S function, adds expansion API parametric variable, and adds the each several part parameter of API block configuration API module.
(2). the realization of driven tool case expansion
ADC driver module storehouse based on the configuration module of XC167 chip in the realization flow of expansion STM8 chip following.
1.. in the AutoSAR standard, find the initializes configuration information and the API switch of the ADC driving of corresponding STM8;
2.. the back of definition XC167 configuration parameter adds the correlation parameter and the self-defining conditional-variable of STM8 configuration in ADC configuration module S function;
3.. add extended chip STM8 configuration ADC driving initialization relevant configured parameter down in the configuration module in the parameter configuration of each several part;
4. after the corresponding parameter configuration of .ADC configuration module extended chip was added, the method that realizes according to relevance in the extended method was accomplished the related of parameter configuration and chip selection after the expansion;
5.. in the ADC module library, add the API module of ADC under the STM8 chip configuration, the adding method of module is identical with the configuration module implementation method.
Three, OSEK tool box code generates the design of template
For generating code; Except will be for S function of each modular design; Also to design a target language TLC of the same name (Target Language Compiler) file; Target language compiler only detects C code S function and the TLC file with same name, just can be from the TLC file generating code.
TLC is the explanatory programming language that a kind of middle description document with the Simulink module map converts the specific objective code into.The TLC file can be divided into two kinds: the aims of systems file mainly is used for the parameter of whole code generation process is controlled.The aims of systems file that the present invention adopts is the osekworks.tlc that carries among the Matlab 7.1.For modules all in the Simulink model, all there is a module file destination in the module file destination, has comprised the code corresponding with the implementation algorithm of particular module.For self-defining S function, need write the file destination of custom block.
For OSEKOS API module and bottom layer driving function module; Because only need generate the code skeleton of api function; Needn't pay close attention to the concrete realization of its function; So (block system) adds the framework of wanting the corresponding api function of module to the %function Outputs that only needs at the corresponding TLC file of each module in the Output function.Code Template as among the corresponding TLC of ActivateTask () function module is:
%function?Outputs(block,?system)?Output
%if?EXISTS("ssBlock")
ActivateTask(%<SFcnParamSettings.TaskID>);
……
%endif
%endfunction
Wherein, TaskID is the parameter that in the corresponding S function of ActivateTask () function module module is provided with.
For OSEK object configuration module, because will generate the OIL/XML configuration file that meets the OSEK/VDX standard, so will follow OSEK OIL standard in the design of the corresponding Code Template of OSEK configuration object module.In standard, defined three configuration parameter: MAXALLOWEDVALUE with COUNTER, TICKSPERBASE and MINCYCLE, so being designed to of its Code Template:
%function?Outputs(block,?system)?Output
%if?EXISTS("ssBlock")
……
COUNTER?%<SFcnParamSettings.CounterName>{
MAXALLOWEDVALUE=%<CAST("Number",SFcnParamSettings.Max_allowedvalue)>;
TICKSPERBASE=%<CAST("Number",SFcnParamSettings.Ticksperbase)>;
MINCYCLE?=?%<CAST("Number",?SFcnParamSettings.Mincycle)>;
};
…….
%endif
%endfunction
Wherein, CounterName, Max_allowedvalue, Ticksperbase and Mincycle are the parameter of COUNTER module to being provided with in the deserved S function.
Four, driven tool case code generates the design and the realization of masterplate
1. driven tool case code generates the masterplate demand analysis
Analysis-driven function application demand and AutoSAR standard can know that driven tool case code generation masterplate obtains the driver module parameter and generates the driven application function code automatically.Mainly be divided in the generating code and drive the initialization correlative code and drive the api function invoke code.Driving the setup code that generates correspondence when initialization correlative code part will satisfy different chip configuration, the api function code satisfies unified and standard interface, and function parameter configuration and rreturn value transmission are selected related with chip.According to driven application code demand, driven tool case code generates template should possess the function that driving function initialization and api function under the different chip configuration call.
2. driven tool case code generates the design and the implementation method of template
(1). code generates the template major function
In order to satisfy driven application code demand, realize that code generates the versatility and the extendability of masterplate, code generates masterplate based on module TLC design, and its major function is that the driving function setup code is realized and the api function invoke code is realized.
The function of driving function setup code part mainly contains: chip selects that configuration, header file comprise, configuration file generates, the configuration of driving function initiation parameter and each several part and chip selection relevance.
The function that drives api function invoke code part mainly contains: api function parameter configuration and api function rreturn value are transmitted
Driving the problem that will note when code generates stencil design is: 1.. satisfy its versatility and extendability; 2.. realize above-mentioned repertoire; 3.. satisfy the relevance that drive arrangements code and chip are selected.
(2). driven tool case code generates the method for designing of template
Generate the function of template according to code, can realize realizing two big classes for driving the initial configuration code by design template with the api function invoke code.Drive code and generate the design of template, be divided into configuration module TLC and API module TLC, its method for designing such as Fig. 7 so driven tool case code generates masterplate based on module TLC.Be the method for designing of various piece among two big types of TLC below.
1.. the method for designing of drive arrangements module TLC
Drive arrangements module TLC combines the configuration module parameter to generate the driving initialization correlative code that related chip is selected, and its main contents can be divided into three parts, and particular content is following.
First, header file comprises code.Judge that by the condition judgment statement file comprises order in the TLC file, realize that by inserting code statement in the TLC file header file comprises code again.Header file comprises in the file destination that code is created on insertion.
Second portion, configuration file and API switch code.Condition judgment chip chosen content at first among the TLC realizes that by the configuration file generated statement configuration file that corresponding chip is selected generates again, in generating configuration file, adds the driving API switch code content of corresponding selection chip at last.Driving API switch configuration code is created in the configuration file of TLC file generation.
The 3rd partly, User-Defined Functions and driving initialization function code part.User-Defined Functions comprises driving initialization function, realizes that User Defined drives the initialization function performance.The User-Defined Functions code divides three parts to realize; Promptly in the main function, realize the definition of function in the source file of statement, generation of function in the header file of function call, generation, drive initialization structure parameter and initialization function and be embedded in SQL defines.
2.. drive the method for designing of API module TLC
Generate template function according to the API block code, drive API module TLC and will realize it being the invoke code and the function return value transmission of api function.The api function invoke code comprises function and parameter configuration, and according to the AutoSAR standard, the api function parameter configuration is unified, in TLC, is realized by the acquisition module parameter value.Function return value transmits by global variable and realizes, in configuration file, global variable is defined statement, again by in the function global variable assignment being accomplished the rreturn value transmission.
(3). driven tool case code generates the implementation method of template
1.. the realization of drive arrangements module TLC
The concrete specification of each several part such as following table 8 in the drive arrangements TLC file.
Table 8 drive arrangements module TLC designs table
Figure 965477DEST_PATH_IMAGE012
2.. drive the implementation method of API module TLC
Drive invoke code and function return value transmission that API module TLC will realize api function.The api function invoke code comprises function and parameter configuration, and according to the AutoSAR standard, the api function parameter configuration is unified, in TLC, is realized by the acquisition module parameter value.Function return value transmits by global variable and realizes, in configuration file, global variable is defined statement, again by in the function global variable assignment being accomplished the rreturn value transmission.Be two-part realization code in API module TLC below:
%assign hFile=LibCreateSourceFile (" Header ", " Custom ", " configuration file ")
%openfile?buffer
The global variable statement
%closefile?buffer
%<LibSetSourceFileSection(hFile,"Functions",buffer)>
%assign cFile=LibCreateSourceFile (" Source ", " Custom ", " configuration file ")
%openfile?buffer
The global variable definition
%closefile?buffer
%<LibSetSourceFileSection(cFile,"Definitions",buffer)>
Adc_SetupResultBuffer (% < SFcnParamSettings.Group >, % < SFcnParamSettings.Da taBufferName >); Api function and parameter code are realized, can transmit rreturn value by the assignment global variable here.
(4). drive the realization that the ADC code generates template
It is consistent that each driver module code generates the template implementation method, is that example analysis-driven configuration module TLC and API module TLC introduce the concrete realization that drives ADC block code generation template below with ADC.
1. the realization of .ADC drive arrangements module TLC
ADC driver module TLC content is divided three parts, and header file comprises, configuration file generates and API switch, configuration file generation and driving initial configuration, and three parts are selected through condition and configuration file is realized related with the chip selection.
First, it is following that header file comprises the realization of partial code:
%assign?hFile=LibCreateSourceFile("Header","Custom","%<SFcnParamSettings.ObjFName>")
%openfile?buffer
#include?"Adc_App.h"
%closefile?buffer
%<LibSetSourceFileSection(hFile,"Functions",buffer)>
Second portion, configuration file and API switch sections are selected to generate under the configuration configuration file and are added relevant API switch at chip, realize as follows:
%if?SFcnParamSettings.ChipConfig==?"XC167"
%assign?hFile=LibCreateSourceFile("Header","Custom","Adc_Cfg")
%openfile?buffer
%if?SFcnParamSettings.Adc_GetVersionInfo_API==?"on"
#define?ADC_GET_VERSION_INFO_API STD_ON
%else
#define?ADC_GET_VERSION_INFO_API STD_OFF
%endif
%closefile?buffer
%<LibSetSourceFileSection(hFile,"Functions",buffer)>
The 3rd partly, and configuration file and driving initial configuration generate corresponding configuration file and interpolation driving setup code under chip selection configuration, realize as follows:
%<SFcnParamSettings.APPFcnName>()
%if?SFcnParamSettings.ChipConfig==?"XC167"
%assign?hFile=LibCreateSourceFile("Header","Custom","Adc_App"
%openfile?buffer
void?%<SFcnParamSettings.APPFcnName>()
%closefile?buffer
%<LibSetSourceFileSection(hFile,"Functions",buffer)>
%assign?cFile=LibCreateSourceFile("Source","Custom","Adc_App"
%openfile?buffer
void?%<SFcnParamSettings.APPFcnName>()
{const?Adc_ConfigType?%<SFcnParamSettings.Adc_Config>={
AdC drives initialization structure parameter code };
%if?SFcnParamSettings.Adc_InitFunction==?"on"
Adc_Init(&%<SFcnParamSettings.Adc_Config>);
%endif }
%closefile?buffer %<LibSetSourceFileSection(cFile,"Definitions",buffer)>
2. .ADC drives the realization of API module TLC
Drive among the API module TLC mainly is function parameter configuration and rreturn value transmission.Rreturn value is by the global variable transmission, i.e. definition and statement global variable and assignment realization rreturn value transmission in function in configuration file is concrete realization below:
%assign?hFile=LibCreateSourceFile("Header","Custom","Adc_App")
%openfile?buffer
Extern?%<SFcnParamSettings.DataBufferType>?%<SFcnParamSettings.DataBufferName>[%<SFcnParamSettings.DataBufferNum>];
%closefile?buffer
%<LibSetSourceFileSection(hFile,"Functions",buffer)>
%assign?cFile=LibCreateSourceFile("Source","Custom","Adc_App")
%openfile?buffer
%<SFcnParamSettings.DataBufferType> %<SFcnParamSettings.DataBufferName>[%<SFcnParamSettings.DataBufferNum>]={0};
%closefile?buffer
%<LibSetSourceFileSection(cFile,"Definitions",buffer)>
Adc_SetupResultBuffer(%<SFcnParamSettings.Group>,%<SFcnParamSettings.DataBufferName>);
3. driven tool case code generates the expansion of template
(1). drive the expansion content that code generates masterplate
The design that generates template based on AutoSAR standard driven tool case code has versatility, and the standardization code of generation is convenient to transplant.The modular code that standardizes generates the masterplate expansion and also realizes easily, and only need to generate stencil structure during expansion and expand according to former code, be the method for expansion below.
. confirm that according to demand analysis and AutoSAR the extended chip configuration drives the content of code expansion down.. generate stencil structure according to code configuration module TLC each several part is expanded.
Header file comprises part, and the expansion that header file comprises realizes related with extended chip through the module parameter value;
Configuration file and API switch sections to the extended chip value, add configuration file at the back at extended chip and generate in chip is selected, and in generating configuration file, add the corresponding driving API switch of extended chip;
Configuration file with drive the initial configuration part, at first add chip and select value, add configuration file at the back carrying out the chip value, generate source file and also add the corresponding driving initialization structure parameter configuration of extended chip.User-Defined Functions realizes the chip expansion through the module value, drives the initialization function and also realizes expansion through the module value.
. add API module TLC file.Can add the API module in the driven tool case during extended chip, corresponding A PI module is added API module TLC file, and adding method is the same with former API module TLC file implementation method.
(2). drive the concrete realization that code generates the masterplate expansion
The expansion that drives ADC block code generation masterplate mainly is the expansion of configuration module TLC content, specifically introduces in the face of the realization of each several part expansion down.
. header file comprises part, and this part realizes the chip expansion through the module parameter value, in TLC, realizes constant.
. configuration file and API switch sections, add chip and select value and generate configuration file, in configuration file, add the corresponding API switch of extended chip, content realizes as follows among the TLC:
%if?SFcnParamSettings.ChipConfig==?"XC167"
%assign?hFile=LibCreateSourceFile("Header","Custom","Adc_Cfg")
%openfile?buffer
%if?SFcnParamSettings.Adc_GetVersionInfo_API==?"on"
#define?ADC_GET_VERSION_INFO_API STD_ON
%else//expansion
%assign?hFile=LibCreateSourceFile("Header","Custom","Adc_Cfg")
%openfile?buffer
%if?SFcnParamSettings.Adc_GetVersionInfo_API==?"on"
#define?ADC_GET_VERSION_INFO_API STD_ON
. configuration file and driving initial configuration part, the User-Defined Functions part realizes the chip expansion by the module parameter value, content is constant among the TLC.Drive initialization function and structure argument section and select the back to add value and generate configuration file to realize the chip expansion that content realizes as follows among the TLC at chip.
%if?SFcnParamSettings.ChipConfig==?"XC167"
%assign?cFile=LibCreateSourceFile("Source","Custom","Adc_App")
%openfile?buffer
void?%<SFcnParamSettings.APPFcnName>()
{ driving ADC initialization structure parameter under the XC167 chip configuration };
%if?SFcnParamSettings.Adc_InitFunction==?"on"
Adc_Init(&%<SFcnParamSettings.Adc_Config>);
%endif?}
%closefile?buffer
%<LibSetSourceFileSection(cFile,"Definitions",buffer)>
%else//expansion
%assign?cFile=LibCreateSourceFile("Source","Custom","Adc_App")
%openfile?buffer
void?%<SFcnParamSettings.APPFcnName>()
{ driving ADC initialization structure parameter under the STM8 chip configuration of expansion };
%if?SFcnParamSettings.Adc_InitFunction==?"on"
Adc_Init(&%<SFcnParamSettings.Adc_Config>);
%endif }
%closefile?buffer
%<LibSetSourceFileSection(cFile,"Definitions",buffer)>
%endif
The realization of the expansion of driving API module TLC is fairly simple, adds corresponding API module TLC file according to extended chip and gets final product.The extended method that ADC drives API module TLC is the same with the former API module of driving ADC TLC implementation method, i.e. driving function argument section and driving function rreturn value part.The function parameter part realizes that by TLC acquisition module parameter value statement the rreturn value transmission is realized by global variable.
Five, the design of configuration and verification tool
The main target of OSEK configuration tool is to generate the OSEK configuration file and carry out the inspection of consistent property, and it is with the form tissue of static module, and these modules mainly are the form encapsulation with class, and the foundation of division is the function and the logic of software.Be divided into presentation layer, functional layer and data Layer three-decker:
(1) presentation layer
This course user shows data and the operation of accepting the user, comprising: use tree list assembly management OIL object, file destination and entrance function; Use attribute form component editor OIL object properties; Check the file destination of function calling relationship, editor's generation etc.
Therefore, design OIL object configuration component should comprise following assembly:
An XML object of describing OIL object inventory, recording user increase, the operating result of deletion OIL object, and this should be a global object, can let other module also can visit.
This requires to be satisfied by the internal storage data representation module, and the internal storage data representation module has comprised several overall CMarkup objects, is used to describe OIL object inventory, simultaneously, and for other module provides data source.
A chart assembly shows the attribute of OIL object, and the events corresponding trigger mechanism is provided, and in real time the user is saved in the XML object of OIL inventory to the modification of attribute.
This requires to adopt the grid control of Property Grid class to satisfy, and such control provides form to revise trigger event, can in time respond, and the user is saved in the OIL object inventory the operating result of OIL object.Simultaneously; Because each XML tag of OIL object inventory all comprises unique uid; So the attribute of each OIL object all has been mapped in the list of entries of Property Grid control one by one, each operating result of user is all corresponding to a unique XML tag uid.
A tabulation class component is used to enumerate all OIL objects of XML inventory.
A tabulation class component is used to show all objects that can add at present.
(2) functional layer
The user's that this layer reception presentation layer passes into various operations, and carry out these operations.User's operation mainly comprises: management, editor OIL object; The file destination that management, editor generate; Inspection OIL object; Import the OIL file; Detect self-defined source code and whether violate the OSKE rule.So functional layer comprises: multi-format document creation module, OIL language parsing module, the consistent property of OSEK detection module, OIL object inspection module.All according to the design philosophy of static moduleization, each module is all independent mutually, realizes independently function separately for these functional modules.The function of each module designs as follows:
1. multi-format document creation module: with the synthetic file destination of the ATL of OIL object inventory and data Layer.
In this Module Design, executive module is carried out separating of height with data, and the action that generates document is fully by rule template control, and executive module is only carried out the synthetic action of document, and the course of work of module is as shown in Figure 8.The template file of ATL adopts XSLT to write.The XSLT transition components mainly is made up of CAutoXSLT class and MSXML assembly.The CAutoXSLT class has realized that based on the XSLT translation function of MSXML OIL object, ATL read, enumerate function; The XSLT transition components synthesizes destination document with destination document transformation rule ATL respectively with the OIL object set, and the rule of data-switching and the type of synthetic document depend on ATL.
2. OIL language parsing module: convert the OIL language file to the XML file, be convenient to operation.
OIL language parsing module most important part is the OIL language parser.The generation step of this executive routine is following:
Write the source file of lex, the OIL file is organized data according to the OIL standard format, and therefore, the lex source file is to write according to the OIL morphological rule;
Generate the C language file, use the lex instrument lex source program to be compiled into the C language file of standard;
Generate executive routine, because target program is on windows platform, to move, so use the VC compiler with the standard C source program.
3. the consistent property of OSEK detection module: user's self-defined code is carried out the detection of the consistent property of OSEK.
The consistent property of OSEK testing process figure is shown in 9; Before compiling, the User Defined code is analyzed, searched all entrance functions and call relation, the regular matrix of structure OSEK OS service call; Set up the forest of describing User Defined code function and call relation thereof; According to regular matrix, find out and violate the directed walk that standard is called in OSEK OS system service in this forest, assisting users improves the stability of OSEK OS application program.
4. the OIL object is checked module: whether the logical relation between the inspection OIL object and the setting of attribute be correct.
In order to realize favorable compatibility and extendability, when design OIL object inspection module, considered following principle:
Every OIL object inspection rule is independently, does not have dependence, and the sequencing of inspection does not influence check result.
OIL object inspection rule and executive module are mutually independently, and promptly program and data are disconnected from each other.
OIL object inspection rule can increase or reduce according to actual needs, but does not influence the structure of application program.
After every OIL object inspection rule executes, return results is arranged all, if the setting of the OIL object of inspection does not meet rule, return results can comprise error message so: OIL object, attributes entries and the reason of makeing mistakes.
(3) data Layer
This layer all stashes the details of all XML data, to functional layer the data access operation service is provided, and mainly comprises following components:
ATL: inspection rule and the OIL object template etc. of having preserved inspection rule, the OSEK consistent property of form, the OIL object of the file destination that needs to generate.
The XML object of internal storage data is described: described current all OIL objects and system's temporary variable.
Data operation modules: this module package the various operations of OIL object, comprise showing OIL list object, increase and deletion OIL object, editor OIL object properties.
Explanation is at last; Above embodiment is only unrestricted in order to technical scheme of the present invention to be described; Although with reference to preferred embodiment the present invention is specified, those of ordinary skill in the art should be appreciated that and can make amendment or be equal to replacement technical scheme of the present invention; And not breaking away from the aim and the scope of present technique scheme, it all should be encompassed in the middle of the claim scope of the present invention.

Claims (9)

1. General Motors code conversion method, its step is following:
1) set up task at the Simulink workbench, this task is the function that the software code of required conversion is accomplished;
2) according to selected ECU, confirm code content and form under OSEKOS operating system standard and the AutoSAR driving interface standard, and set up the tool box respectively;
3) the software code information of required conversion is imported the S function, this S function is by step 2) described in the tool box confirm;
4) the S function in the step 3) is encapsulated, be packaged into the operational module of Simulink workbench;
5) operational module after the encapsulation in the step 4) is imported the Simulink workbench;
6) under the Simulink workbench, the operational module that checking imports is not through then returning step 1), through then changing step 7) over to;
7) under the RTW platform, will carry out code conversion through the software code that the S function imports;
8) generating code configuration file and code content file;
9) configuration file of code described in the step 8) and code content file are added the compiler engineering, generate final required code.
2. a kind of General Motors code conversion method as claimed in claim 1; It is characterized in that; The method for designing in OSEK tool box is: based on the OSEK standard, carry out OSEK object configuration module and OSEK API Module Design, utilize the S function to carry out the establishment and the encapsulation of module then.
3. a kind of General Motors code conversion method as claimed in claim 1 is characterized in that the modeling method in OSEK tool box is:
At first in Simulink control algolithm model, add relevant OSEK object configuration module, and corresponding parameter is set;
Secondly add OSEK tool box API module and correlation parameter is set according to model tasks, realize the division of task framework;
Emulation and code through model generates the use that realizes the OSEK tool box automatically at last.
4. a kind of General Motors code conversion method as claimed in claim 1 is characterized in that, the method for designing that the code in OSEK tool box generates template is: OSEK tool box code generates template and comprises two parts,
It is the OIL configuration file that OSEK object configuration module code generates stencil design, and interpolation OIL configuration file is converted into object code in the OSEK configuration tool;
OSEK tool box API block code generates template and obtains the code generation that API module parameter information realizes OSEK tool box API module through module TLC file.
5. a kind of General Motors code conversion method as claimed in claim 1; It is characterized in that; The method for designing of OSEK configuration tool is: be configured the design of instrument with the form of static module, encapsulate with the form of class, according to the function and the logic requirement of software; It is divided into presentation layer, functional layer and data Layer three-decker, carries out modular design and realization.
6. a kind of General Motors code conversion method as claimed in claim 1 is characterized in that: the type of said AutoSAR driving interface standard is wherein a kind of among ADC, CAN, DIO, EEPROM, FLASH, GPT, LIN, PORT, PWM, WDG, ICU, MCU or the SPI.
7. a kind of General Motors code conversion method as claimed in claim 1 is characterized in that, based on AutoSAR standard driven tool case method for designing be: the tool box is designed to configuration module and API module,
Driven tool case configuration module design comprises chip and selects that configuration, header file comprise, configuration file generates and drives the API switch, drive four parts of initialization relevant configuration, the various piece parameter configuration through conditional-variable with generate configuration file and realize the relevance that disposes with the chip selection;
Driven tool case API modular design is divided into driving api function parameter configuration and rreturn value transmission; Wherein the rreturn value transmission by definition in the configuration file that generates and statement global variable and in function body assignment realize the quick expansion of the interpolation implementation tool case of the API module that interpolation through the configuration of configuration module correlation parameter during the chip configuration expansion and extended chip are relevant.
8. a kind of General Motors code conversion method as claimed in claim 1 is characterized in that: the modeling method based on AutoSAR standard driven tool case is:
At first in the Simulink controlling models, add the drive arrangements module;
Secondly in the drive arrangements module, select chip configuration and accomplish its relevant parameter realization driving function of initializing is set;
In the Simulink controlling models, add once more and drive the API module and dispose correlation parameter; Generate through model emulation and automatic code at last and accomplish the application that drives.
9. the described a kind of General Motors code conversion method of claim 1; It is characterized in that; Driven tool case code generates template design method: driven tool case code generates the design of template based on module TLC, and it is divided into configuration module TLC template and API module TLC template
The configuration module code generate template be divided into header file comprise code, chip select configuration down configuration file generate and API switch, chip select configuration to drive the initial configuration three parts down; The each several part code content provides conditional-variable and configuration file to realize the relevance of selecting with chip
Driven tool case API block code generates template and comprises and drive that api function calls and parameter configuration code, the api function rreturn value transmission two large divisions that realized by the definition global variable, when chip configuration expand through add the quick expanded function that related content realizes code generation template at each several part.
CN2012100392776A 2012-02-21 2012-02-21 General car code conversion method Pending CN102622470A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2012100392776A CN102622470A (en) 2012-02-21 2012-02-21 General car code conversion method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2012100392776A CN102622470A (en) 2012-02-21 2012-02-21 General car code conversion method

Publications (1)

Publication Number Publication Date
CN102622470A true CN102622470A (en) 2012-08-01

Family

ID=46562386

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2012100392776A Pending CN102622470A (en) 2012-02-21 2012-02-21 General car code conversion method

Country Status (1)

Country Link
CN (1) CN102622470A (en)

Cited By (26)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103116497A (en) * 2013-03-05 2013-05-22 北京经纬恒润科技有限公司 Multiple-electronic-control-unit building method based on software platform and system thereof
CN103150445A (en) * 2013-03-21 2013-06-12 北京经纬恒润科技有限公司 Parsing method and device of MATLAB model variable
CN103294532A (en) * 2012-08-27 2013-09-11 中国电子科技集团公司第四十一研究所 Method for rapid implementation of matrix switch graphical control system
CN103530447A (en) * 2013-09-26 2014-01-22 北京经纬恒润科技有限公司 Automatic model generation method based on Simulink
WO2014060470A1 (en) * 2012-10-16 2014-04-24 Continental Teves Ag & Co. Ohg Interface for interchanging data between redundant programs for controlling a motor vehicle
CN103942380A (en) * 2014-04-14 2014-07-23 河南理工大学 Graphical control system design and simulation tool
CN104111608A (en) * 2014-06-28 2014-10-22 中国北方发动机研究所(天津) Method and device for setting signals and parameters in Simulink model
CN104331292A (en) * 2014-11-03 2015-02-04 重庆邮电大学 Method for generating configuration for middleware protocol conversion of Internet of vehicles
CN104503767A (en) * 2014-12-31 2015-04-08 埃泰克汽车电子(芜湖)有限公司 System and method for automatically generating codes based on LIN protocol
CN105138457A (en) * 2015-09-01 2015-12-09 华东师范大学 Analyzing and verifying device and method for operation system of automobile open system structure
CN105512097A (en) * 2015-11-26 2016-04-20 普华基础软件股份有限公司 File analyzing method
CN105808216A (en) * 2014-12-29 2016-07-27 联创汽车电子有限公司 Vehicle-mounted control software system policy code and underlying code integration method
CN106371813A (en) * 2015-07-23 2017-02-01 广州汽车集团股份有限公司 Simulink-based motor controller software generation method for electric vehicle
CN103870262B (en) * 2012-12-14 2017-06-06 北汽福田汽车股份有限公司 A kind of variable automatic generation method and device based on SHELL scripts
CN106933582A (en) * 2017-03-03 2017-07-07 浙江仕善汽车科技股份有限公司 It is a kind of to improve the method that automobile controller develops software code execution efficiency
CN106970787A (en) * 2017-03-03 2017-07-21 浙江仕善汽车科技股份有限公司 A kind of automobile controller rapid prototyping implementation method
CN108693845A (en) * 2018-04-08 2018-10-23 中国科学院自动化研究所 Standardized packages method based on auto assembly business model and general assembly system
CN109063006A (en) * 2018-07-10 2018-12-21 奇瑞汽车股份有限公司 A kind of method that Excel realizes the calculating of vehicle software configuration coding and parsing
CN110727658A (en) * 2019-10-22 2020-01-24 中车青岛四方车辆研究所有限公司 QT-based display screen universal module library establishing method
CN112068895A (en) * 2020-08-10 2020-12-11 深圳市鼎盛光电有限公司 Code configuration method and device, video playing equipment and storage medium
CN112328256A (en) * 2020-11-19 2021-02-05 四川创智联恒科技有限公司 Method for automatically generating structure body parser source code
CN112328258A (en) * 2020-11-26 2021-02-05 中国科学院计算机网络信息中心 Method and system for converting programming language
CN112748904A (en) * 2019-10-29 2021-05-04 卓品智能科技无锡有限公司 Controller rapid prototyping development method based on MATLAB platform
CN113176903A (en) * 2021-04-15 2021-07-27 常州易控汽车电子股份有限公司 Software integration method and system for applying Simulink model to different automobile controller platforms
CN114898617A (en) * 2022-04-12 2022-08-12 哈尔滨工业大学 Automobile electronic demonstration system and operation method thereof
CN115826938A (en) * 2022-01-29 2023-03-21 宁德时代新能源科技股份有限公司 Method and device for generating and using real-time operating system, electronic equipment and medium

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
冯辉宗等: "《汽车ECU 标定系统CAN驱动模块的实现》", 《微计算机信息(嵌入式与SOC)》 *
张永博等: "《基于Simulink的OSEK嵌入式软件开发方法》", 《单片机与嵌入式系统应用》 *
李银国等: "《基于广义表结构的OIL配置器设计》", 《计算机工程》 *
王安军等: "《符合AUTOSAR规范的底层驱动软件开发》", 《计算机工程》 *
蒋建春等: "《基于OSEK/VDX规范的实时操作系统移植研究》", 《计算机测量与控制》 *

Cited By (38)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103294532A (en) * 2012-08-27 2013-09-11 中国电子科技集团公司第四十一研究所 Method for rapid implementation of matrix switch graphical control system
CN103294532B (en) * 2012-08-27 2016-09-07 中国电子科技集团公司第四十一研究所 The method of rapid implementation of matrix switch graphical control system
WO2014060470A1 (en) * 2012-10-16 2014-04-24 Continental Teves Ag & Co. Ohg Interface for interchanging data between redundant programs for controlling a motor vehicle
US10214189B2 (en) 2012-10-16 2019-02-26 Continental Teves Ag & Co. Ohg Interface for interchanging data between redundant programs for controlling a motor vehicle
CN103870262B (en) * 2012-12-14 2017-06-06 北汽福田汽车股份有限公司 A kind of variable automatic generation method and device based on SHELL scripts
CN103116497B (en) * 2013-03-05 2015-12-23 北京经纬恒润科技有限公司 A kind of polyelectron control module construction method based on software platform and system
CN103116497A (en) * 2013-03-05 2013-05-22 北京经纬恒润科技有限公司 Multiple-electronic-control-unit building method based on software platform and system thereof
CN103150445A (en) * 2013-03-21 2013-06-12 北京经纬恒润科技有限公司 Parsing method and device of MATLAB model variable
CN103530447A (en) * 2013-09-26 2014-01-22 北京经纬恒润科技有限公司 Automatic model generation method based on Simulink
CN103530447B (en) * 2013-09-26 2017-04-12 北京经纬恒润科技有限公司 Automatic model generation method based on Simulink
CN103942380A (en) * 2014-04-14 2014-07-23 河南理工大学 Graphical control system design and simulation tool
CN103942380B (en) * 2014-04-14 2017-01-11 河南理工大学 Graphical control system design and simulation tool
CN104111608A (en) * 2014-06-28 2014-10-22 中国北方发动机研究所(天津) Method and device for setting signals and parameters in Simulink model
CN104331292A (en) * 2014-11-03 2015-02-04 重庆邮电大学 Method for generating configuration for middleware protocol conversion of Internet of vehicles
CN104331292B (en) * 2014-11-03 2019-01-22 重庆邮电大学 A kind of configuration generating method of car networking middleware protocols conversion
CN105808216A (en) * 2014-12-29 2016-07-27 联创汽车电子有限公司 Vehicle-mounted control software system policy code and underlying code integration method
CN104503767A (en) * 2014-12-31 2015-04-08 埃泰克汽车电子(芜湖)有限公司 System and method for automatically generating codes based on LIN protocol
CN106371813A (en) * 2015-07-23 2017-02-01 广州汽车集团股份有限公司 Simulink-based motor controller software generation method for electric vehicle
CN106371813B (en) * 2015-07-23 2019-11-01 广州汽车集团股份有限公司 A kind of electric vehicle motor controller method for producing software based on Simulink
CN105138457A (en) * 2015-09-01 2015-12-09 华东师范大学 Analyzing and verifying device and method for operation system of automobile open system structure
CN105512097A (en) * 2015-11-26 2016-04-20 普华基础软件股份有限公司 File analyzing method
CN106933582A (en) * 2017-03-03 2017-07-07 浙江仕善汽车科技股份有限公司 It is a kind of to improve the method that automobile controller develops software code execution efficiency
CN106970787A (en) * 2017-03-03 2017-07-21 浙江仕善汽车科技股份有限公司 A kind of automobile controller rapid prototyping implementation method
CN108693845A (en) * 2018-04-08 2018-10-23 中国科学院自动化研究所 Standardized packages method based on auto assembly business model and general assembly system
CN109063006A (en) * 2018-07-10 2018-12-21 奇瑞汽车股份有限公司 A kind of method that Excel realizes the calculating of vehicle software configuration coding and parsing
CN110727658A (en) * 2019-10-22 2020-01-24 中车青岛四方车辆研究所有限公司 QT-based display screen universal module library establishing method
CN112748904A (en) * 2019-10-29 2021-05-04 卓品智能科技无锡有限公司 Controller rapid prototyping development method based on MATLAB platform
CN112068895A (en) * 2020-08-10 2020-12-11 深圳市鼎盛光电有限公司 Code configuration method and device, video playing equipment and storage medium
CN112068895B (en) * 2020-08-10 2023-12-19 深圳市鼎盛光电有限公司 Code configuration method, device, video playing equipment and storage medium
CN112328256B (en) * 2020-11-19 2023-04-25 四川创智联恒科技有限公司 Method for automatically generating source code of structural body analyzer
CN112328256A (en) * 2020-11-19 2021-02-05 四川创智联恒科技有限公司 Method for automatically generating structure body parser source code
CN112328258A (en) * 2020-11-26 2021-02-05 中国科学院计算机网络信息中心 Method and system for converting programming language
CN113176903A (en) * 2021-04-15 2021-07-27 常州易控汽车电子股份有限公司 Software integration method and system for applying Simulink model to different automobile controller platforms
CN113176903B (en) * 2021-04-15 2024-04-26 常州易控汽车电子股份有限公司 Software integration method and system for Simulink model applied to different automobile controller platforms
CN115826938A (en) * 2022-01-29 2023-03-21 宁德时代新能源科技股份有限公司 Method and device for generating and using real-time operating system, electronic equipment and medium
WO2023143020A1 (en) * 2022-01-29 2023-08-03 宁德时代新能源科技股份有限公司 Generation method and apparatus for real-time operating system, use method and apparatus for real-time operating system, electronic device, and medium
CN115826938B (en) * 2022-01-29 2023-11-17 宁德时代新能源科技股份有限公司 Method and device for generating and using real-time operating system, electronic equipment and medium
CN114898617A (en) * 2022-04-12 2022-08-12 哈尔滨工业大学 Automobile electronic demonstration system and operation method thereof

Similar Documents

Publication Publication Date Title
CN102622470A (en) General car code conversion method
CN102819492B (en) Keyword driven automatic testing frame on basis of Android
US7954084B2 (en) Software for generating a computer application code and software description language
CN109254905B (en) Distributed parallel automatic test system based on workflow
CN109558117B (en) Aerospace application-oriented AADL model refinement and C code automatic generation method supported by same
US20080244541A1 (en) Code translator and method of automatically translating modeling language code to hardware language code
CN110222318A (en) Data generating tool development approach based on XML
CN101739258A (en) Automatic code generation method of architecture analysis and design language (AADL) model
CN103744647A (en) Java workflow development system and method based on workflow GPD
CN108037913B (en) Method for converting xUML4MC model into MSVL (modeling, simulation and verification language) program and computer-readable storage medium
CN111367511A (en) Simulation model interface adaptation development system and working method thereof
CN110262794A (en) A kind of AADL behaviour expanding method and tool based on specification with description language
CN101458633B (en) Method for accessing host program by script program, and system and apparatus thereof
CN110209389A (en) A kind of data generating tool development system based on XML
Kirshin et al. A UML simulator based on a generic model execution engine
CN115061772A (en) Multi-field simulation model integration method and system
CN102867087A (en) Graphical radar signal processing high-level integrated design platform and method
CN104063231A (en) Test resource rapid access method based on HIT-TENA
Borde et al. Pride-an environment for component-based development of distributed real-time embedded systems
CN116048518B (en) Automatic generation method of comprehensive avionics system security codes for antenna operating system
Zhang et al. Automated unit testing intelligent agents in PDT
Heimdahl et al. Generating code from hierarchical state-based requirements
CN101517391B (en) System for supervising engine test beds which is independent of the type of engine test bed
CN114647451A (en) Test equipment driver and driving method
Mu et al. Design and implementation of gui automated testing framework based on xml

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20120801