13.02.2013 Views

Evaluation Environment for AUTOSAR-Autocode in Motor Control ...

Evaluation Environment for AUTOSAR-Autocode in Motor Control ...

Evaluation Environment for AUTOSAR-Autocode in Motor Control ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1 #def<strong>in</strong>e RTE E CS str<strong>in</strong>g to <strong>in</strong>t overflow (42)<br />

#def<strong>in</strong>e RTE E CS str<strong>in</strong>g to <strong>in</strong>t underflow (43)<br />

2.8 Example<br />

#def<strong>in</strong>e Rte Call rport1 parse(array, sum) (Rte Call swc1 rport1 parse(array, sum))<br />

FUNC(Std ReturnType, RTE CODE) Rte Call swc1 rport1 parse(CONSTP2VAR(Str<strong>in</strong>g8, �<br />

AUTOMATIC, RTE APPL DATA), CONSTP2VAR(Int16, AUTOMATIC, RTE APPL DATA));<br />

/∗ Inl<strong>in</strong>e Write optimization; Rte Write pport1 <strong>in</strong>tValue2 to direct access ∗/<br />

extern VAR(Int16, RTE DATA) Rte RxBuf 1;<br />

10 #def<strong>in</strong>e Rte Write pport1 <strong>in</strong>tValue2(data) ( �<br />

Rte WriteHook swc1 pport1 <strong>in</strong>tValue2 Start(data), (Rte RxBuf 1 = data), �<br />

Rte WriteHook swc1 pport1 <strong>in</strong>tValue2 Return(data), RTE E OK )<br />

/∗ Inl<strong>in</strong>e Write optimization; Rte Write pport1 <strong>in</strong>tValue1 to direct access ∗/<br />

extern VAR(Int16, RTE DATA) Rte RxBuf 0;<br />

#def<strong>in</strong>e Rte Write pport1 <strong>in</strong>tValue1(data) ( �<br />

Rte WriteHook swc1 pport1 <strong>in</strong>tValue1 Start(data), (Rte RxBuf 0 = data), �<br />

Rte WriteHook swc1 pport1 <strong>in</strong>tValue1 Return(data), RTE E OK )<br />

FUNC(void, RTE APPL CODE) run11(void);<br />

FUNC(void, RTE APPL CODE) run12(void);<br />

List<strong>in</strong>g 2.5: Example header file <strong>for</strong> SWC1 (Rte swc1.h)<br />

to implement a functional behavior <strong>for</strong> the Software Component, this functions have<br />

to be implemented. With<strong>in</strong> these functions, the values of the ports can be accessed, if<br />

it is configured <strong>for</strong> the SWC.<br />

For an access to a sender port with a DataSendPo<strong>in</strong>t, the API is specified with<strong>in</strong><br />

<strong>AUTOSAR</strong> to be of the <strong>for</strong>m Rte Write (data). Whereas is the name<br />

of the port and is the name of the data element which is accessed. The value,<br />

which is passed to the call with the parameter data, is written to the port.<br />

As mentioned be<strong>for</strong>e, the both components are mapped to the same ECU and so<br />

there is no need to use any <strong>in</strong>ter–ECU communication mechanism. Instead the communication<br />

can be done directly. It can be seen <strong>in</strong> the example that the API is<br />

implemented with #def<strong>in</strong>e directives, which directly accesses the global variables<br />

Rte RxBuf 1 and Rte RxBuf 2. The API <strong>for</strong> SWC2 is not shown here, but it has to<br />

access the same variables to establish the communication.<br />

To <strong>in</strong>voke an operation at the server, a function call is necessary. For the runnable<br />

run12 is a SynchronousServerCallPo<strong>in</strong>t specified. So the function does not return<br />

until the operation on the server is f<strong>in</strong>ished and the return values are available. In<br />

the special case mentioned above, the runnable, which implements the server, is not<br />

mapped to a task and can be <strong>in</strong>voked concurrently. This runnable is then executed <strong>in</strong><br />

the context of the current task and therewith no other task has to be started.<br />

For the SynchronousServerCallPo<strong>in</strong>t, the API Rte Call rport1 parse( str<strong>in</strong>g , value)<br />

is expected and created by the RTE generator. The operation parse takes one str<strong>in</strong>g<br />

as argument and returns one <strong>in</strong>teger value. This API is implemented us<strong>in</strong>g a #def<strong>in</strong>e<br />

directive to a function. This function is implemented <strong>in</strong> the also generated file Rte.c.<br />

21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!