RTA-OSEK for PC User Guide

Contact Details

ETAS Group www.etasgroup.com

Germany USA ETAS GmbH ETAS Inc. Borsigstraße 14 3021 Miller Road 70469 Stuttgart Ann Arbor, MI 48103 Tel.:+49 (711) 8 96 61-102 Tel.: +1 (888) ETAS INC Fax:+49 (711) 8 96 61-106 Fax: +1 (734) 997-94 49 www..de www.etasinc.com

Japan France ETAS K.K. ETAS S.A.S. Queen's Tower C-17F, 1, place des États-Unis 2-3-5, Minatomirai, Nishi-ku, SILIC 307 Yokohama, Kanagawa 94588 Rungis Cedex 220-6217 Japan Tel.: +33 (1) 56 70 00 50 Tel.: +81 (45) 222-0900 Fax: +33 (1) 56 70 00 51 Fax: +81 (45) 222-0956 www.etas.fr www.etas.co.jp

Korea Great Britain ETAS Korea Co., Ltd. ETAS UK Ltd. 4F, 705 Bldg. 70-5 Studio 3, Waterside Court Yangjae-dong, Seocho-gu Third Avenue, Centrum 100 Seoul 137-899, Korea Burton-upon-Trent Tel.: +82 (2) 57 47-016 Staffordshire DE14 2WQ Fax: +82 (2) 57 47-120 Tel.: +44 (0) 1283 - 54 65 12 www.etas.co.kr Fax: +44 (0) 1283 - 54 87 67 www.etas-uk.net

Copyright Notice

CprgtNtc RTA-OSEKfor PCUser Guide Copyright Notice 4 Copyright Notice UK - 0219936.2UK - USA and - 10/242,482. 0209800.2UK - USA and - 10/146,239, 0209479.5UK - USA - and 10/146,654, applications: patent following the Certain aspects of the technology described inthis guide theare subject of respective owners. names registered trademarks their or trademarks of product are All other is atradem OSEK/VDX of MS-DOStrademarks Microsoft areCorp. Windows and RTA-OSEKLiveDevices and trademarks are LiveDevicesof Ltd. Trademarks of natureany or kind. losses, costs, charges, claims, demands, claim for lost profits, feesor expenses document this be or direct, special, for indirect, liable consequential damage, LiveDevices, employees, contractors its shall its In noevent the or authors of or omissions. for any errors no responsibility containedinformation herein is assumed to be accurate, LiveDevices assumes does not represent commitment a on any part LiveDevices.of Whilethe inthis change document issubjectThe information to notice without and Disclaimer the terms of such a license. furnished under a license mayand onlybe usedor copied in accordance with consent of LiveDevices The Ltd. describedsoftware document inthis is documentof No part this may be reproduced thewithout written prior Version: RTA-OSEK for PC v5.0.0 (issue 1) 2001© - 2006 LiveDevices Ltd. Allrightsreserved. ark of AG.

Table of Contents

5

ide? ...... 19 Kernel...... 27 this Gu this Areas...... 31 ual Machine?...... 23ual File\New… ...... 36 Build / Custom Build ...... 38 Device ManagerDevice ...... 24 Unit Control Interrupt ...... 25 ManagerApplication ...... 26 GUIEmbedded ...... 26 RTA-OSEK TableLinkage ...... 27 RTA-OSEK ...... 32 Compiler ...... 32 RTA-TRACE ...... 35 need? ...... 22 tes...... 32

3.1.1 3.1.2 3.1.3 3.2.1 3.2.2 2.3.4 2.3.5 2.3.6 2.3.1 2.3.2 2.3.3 Guide ...... 19 Prerequisi ECU...... 36 Virtual first your Creating devices...... 40 Adding What is in a Virtual ECU?...... 28 a Virtual in is What ECUs...... 28 Virtual Managing ECU...... 29 a Virtual with Interacting Problem Possible Conventions...... 19 Terms ...... 20 I do What Virt the is What Who Should Read Who Should

3.1 3.2 3.3 2.4 2.5 2.6 2.7 1.2 2.1 2.2 2.3 Disclaimer ...... 4 Trademarks ...... 4 1.1 Tutorial ...... 32 Overview...... 20 About this this About

3 2 Contact Details...... 3 Contact NoticeCopyright ...... 4 Contents...... 5 of Table 1 Table of Contents of Contents Table RTA-OSEK for PC User Guide User PC RTA-OSEKfor Table Contents of

Table of Contents

Tbeo otns RTA-O Tableof Contents 6 6 5 4

vrtaMonitor...... 74 vrtaServe ...... 64 ECUs and Virtual Devices 4.6 4.5 4.4 4.3 4.2 4.1 3.4 6.2 6.1 5.3 5.2 5.1 4.7

r...... 70 Events...... 76 ...... 75 Actions Security i Server status Multiple instances of VECU...... 71 a Threads...... 69 Parent / Child re ...... 67 Raising interrupts ...... 66 Raising events Handling state queries...... 65 ...... 65 Handling actions ...... 64 Registering the device ...... 44 Tutorial2 3.4.13 3.4.12 3.4.11 3.4.10 3.4.9 3.4.8 3.4.7 3.4.6 3.4.5 3.4.4 3.4.3 3.4.2 3.4.1 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1

se ...... 73 ssues ak n Ss...... 51 TasksISRs and ...... 50 Summary so far ...... 48 Trial run 1 ...... 47 main() Device Initialization...... 47 Interfacing C code Logger Devices...... 44 ...... 43 Custom devices ...... 43 IO ...... 42 Actuators ...... 42 Sensors Clocks, counters and Addendum ...... 59 RTA-TRACE ...... 57 Non-volatile data ...... 57 Trial run 2 Threads...... 54 information...... 71 ainhp ...... 67 lationships ...... 46 ...... 63 with devices...... 46 compare de vices...... 40 SEK for PC UserGuide

Table of Contents

7

...... 85 -time ...... 89 Template...... 86 read priorities...... 84 read at at run econd tID...... 88 ype...... 88 vrtaISRID ...... 88 vrtaIntPriority...... 88 vrtaErrT vrtamillis The VECU...... 83The RTA-TRACE-Server...... 84 Files...... 86 Header API Linkage ...... 86 Call API The vrtaDevID ...... 88 vrtaActionID ...... 88 vrtaEven vrtaActEvID...... 88 Query...... 76 Monitor...... 77 vrtaMonitor...... 78 using Scripting Plug-Ins...... 79 variant and Target ...... 80 Interrupts ...... 80 tasks of Number ...... 81

6.2.1 9.2.1 9.2.2 9.2.3 9.2.4 9.2.5 9.2.6 9.2.7 9.2.8 9.1.1 9.1.2 9.1.3 8.1.1 8.1.2 6.2.3 6.2.4 7.1.1 7.1.2 7.1.3 6.2.2 Controlling the trace Controlling the own...... 85 your Rolling notesGeneral ...... 86 Types...... 88 Data Common Initialization ...... 82 Interrupts...... 82 application...... 82 the Building works it How ...... 83 th and process Tuning OIL fileOIL ...... 80 drivers...... 81Hardware

8.3 8.4 9.1 9.2 7.3 7.4 7.5 8.1 8.2 7.1 7.2 Virtual Machine API Reference API Machine Virtual ...... 86 RTA-TRACE Reference...... 83 RTA-TRACE Migration GuideMigration ...... 80

9 8 7 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Table Contents of

Table of Contents

Tbeo otns RTA-O Tableof Contents 8 9.4 9.3

P ucin ...... 96 API Functions Data formatStrings...... 93 9.4.12 9.4.11 9.4.10 9.4.9 9.4.8 9.4.7 9.4.6 9.4.5 9.4.4 9.4.3 9.4.2 9.4.1 9.3.2 9.3.1 9.2.18 9.2.17 9.2.16 9.2.15 9.2.14 9.2.13 9.2.12 9.2.11 9.2.10 9.4.21 9.4.20 9.4.19 9.4.18 9.4.17 9.4.16 9.4.15 9.4.14 9.4.13 9.2.9

eiiin...... 94 Definition Overview...... 93 ...... 92 vrtaOptStringlistPtr vrtaString vrtaTextP vrtaEven ...... 90 vrtaAction vrtaEmbed...... 89 vrtaDataLen...... 89 vrtaByte...... 89 vrtaBoolean...... 89 vrtaTimest raee( ...... 115 vrtaReset() vrtaRegisterVirtualDevice()...... 111 ...... 111 vrtaReadHPTime() vrtaRaiseEv vrtaOSSetIPL()...... 110 ...... 109 vrtaOSGetIPL() ...... 109 vrtaNoneUserThread() vrtaLoadVM()...... 108 vrtaLeaveUninterrupt vrtaIsIdle()...... 107 ...... 106 vrtaIsAppThread() vrtaIsAppFinished()...... 105 vrtaInitializ vrtaInitialize()...... 103 vrtaHookEv vrtaGetState()...... 100 vrtaEventUnreg vrtaEventReg vrtaEnterUninterrupt ...... 96 OS_MAIN() InitializeDev t...... 91 tr...... 92 listPtr...... 92 amp...... 89 eOS()...... 105 n( ...... 110 ent() ent()...... 102 cs)...... 96 ices() ister()...... 98 se( ...... 100 ister() ibleSection()...... 98 beeto( ...... 107 ibleSection() SEK for PC UserGuide

Table of Contents

9

egister...... 121 dVecs...... 126 eEvents ...... 123 te() ...... 119 ing ...... 126 ceList...... 122 es.h...... 120 Event: Enable Event: Start...... 127Action: Terminate...... 127Action: Event: Devi Event: DeviceActions...... 122 Event: Devic Event: DeviceInfo...... 123Event: RaiseAction: ...... 124 ClearAction: ...... 125 Mask...... 125Action: Unmask...... 125Action: GetPendingAction: ...... 125 GetIPLAction: ...... 125 SetIPLAction: ...... 125 Pend Event: Start...... 126 Event: Stop...... 126Event: IPLEvent: ...... 126 vrtaSendAction()...... 116 vrtaSpawnThread()...... 117 vrtaStart() ...... 118 vrtaTermina EventR Action: HookEventsAction: ...... 121 ListAllAction: ...... 122 GetDeviceActions...... 122 Action: GetDeviceEventsAction: ...... 122 GetDeviceInfo...... 122Action:

Reference...... 120 9.4.22 10.4.8 10.4.9 10.4.10 10.4.11 10.4.12 10.5.1 10.5.2 10.4.1 10.4.2 10.4.3 10.4.4 10.4.5 10.4.6 10.4.7 10.3.3 10.3.4 10.3.5 10.3.6 10.3.7 10.3.8 10.3.9 10.3.10 9.4.24 9.4.25 10.3.1 10.3.2 9.4.23 Application Manager...... 127Application Interrupt Control Unit...... 124 Control Interrupt vrtaStdDevic Descriptions...... 120 Event and Action ManagerDevice ...... 121

10.5 10.4 10.1 10.2 10.3 Standard Device Device Standard

10 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Table Contents of

Table of Contents

0 al fCnet RTA- Tableof Contents 10 11

Sample Device 11.4 11.3 11.2 11.1

ralc ...... 134 vrtaClock ...... 133 Device Descriptions Compiling the Sample Devices...... 132 ...... 131 Summary 11.4.2 11.4.1 11.3.2 11.3.1 10.5.19 10.5.18 10.5.17 10.5.16 10.5.15 10.5.14 10.5.13 10.5.12 10.5.11 10.5.10 10.5.9 10.5.8 10.5.7 10.5.6 10.5.5 10.5.4 11.4.10 11.4.9 11.4.8 11.4.7 11.4.6 11.4.5 11.4.4 11.4.3 10.5.3 eeec ...... 131 Reference

vn:Oto ...... 129 Event: Option Event: Info...... 129 Event: Term Event: Re Event: Rest Event: Pa Event: Star ...... 128 Action: ReadParam ...... 128 Action: ReadOption Action: TestOption...... 128 Action: GetInfo...... 128 Action: Reset...... 128 Action: Restart...... 127 ...... 127 Action: Pause Event: Interval...... 137 ...... 137 Action: Stop Action: Start...... 137 ...... 137 Action: Scale Action: Interval...... 136 ...... 136 Method: Stop() Method: Start()...... 135 Method: SetScale()...... 135 ...... 134 Method: SetInterval() Method: vrtaClock()...... 134 ...... 133 Actions andEvents ...... 133 Methods Event: State...... 130 Event: Para Event: OptionText...... 130 used...... 129 set...... 129 ted...... 128 re ...... 129 arted mText...... 130 inated...... 129 OSEK for PCUserGuide

Table of Contents

11

()...... 138 Counter ing...... 137 Set...... 144 ...... 145 Action: SetAction: ...... 150 Start...... 150Action: StopAction: ...... 150 Report...... 150Action: Action: SetAction: ...... 143 Start...... 143Action: StopAction: ...... 143 Report...... 143Action: Event: vrtaDownCounter()...... 145 Method: Min()...... 146Method: Max()Method: ...... 146 Value()Method: ...... 146 SetMin()Method: ...... 147 SetMax()...... 148 Method: SetVal()Method: ...... 148 Start()...... 149Method: Stop()Method: ...... 149 Minimum...... 150 Action: Maximum...... 150Action: Event: Scale...... 137Event: Runn Event: vrtaUp Method: Min()...... 139Method: Max()Method: ...... 139 Value()Method: ...... 140 SetMin()Method: ...... 140 SetMax()...... 141 Method: SetVal()Method: ...... 141 Start()...... 142Method: Stop() Method: ...... 142 Minimum...... 143 Action: Maximum...... 143Action: ounter

11.4.11 11.6.7 11.6.8 11.6.9 11.6.10 11.6.11 11.6.12 11.6.13 11.6.14 11.6.15 11.5.16 11.6.1 11.6.2 11.6.3 11.6.4 11.6.5 11.6.6 11.5.8 11.5.9 11.5.10 11.5.11 11.5.12 11.5.13 11.5.14 11.5.15 11.5.1 11.5.2 11.5.3 11.5.4 11.5.5 11.5.6 11.5.7 11.4.12 vrtaDownC vrtaUpCounter ...... 138

11.6 11.5 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Table Contents of

Table of Contents

2 al fCnet RTA- Tableof Contents 12 11.7 11.9 11.8 11.10

vrtaActuator...... 162 vrtaSensorMulti vrtaSensorToggl vrtaSenso 11.9.8 11.9.7 11.9.6 11.9.5 11.9.4 11.9.3 11.9.2 11.9.1 11.8.5 11.8.4 11.8.3 11.8.2 11.8.1 11.7.9 11.7.8 11.7.7 11.7.6 11.7.5 11.7.4 11.7.3 11.7.2 11.7.1 11.10.7 11.10.6 11.10.5 11.10.4 11.10.3 11.10.2 11.10.1 11.9.9 11.6.16

r...... 152

ehd au( ...... 156 Method: Value() Method: vrtaSenso ...... 155 Event: Maximum ...... 155 Event: Value Action: Maximum...... 154 Action: Value...... 154 ...... 154 Method: SetVal() Method: SetMax()...... 153 ...... 153 Method: Value() Method: GetMax()...... 152 Method: vrta Event: Action: Maximum...... 164 Action: Value...... 164 ...... 164 Method: SetVal() Method: SetMax()...... 163 ...... 163 Method: Value() Method: GetMax()...... 162 ...... 162 Method: vrtaActuator() ...... 161 Event: Maximum ...... 161 Event: Value Action: Maximum...... 160 Action: Value...... 160 ...... 160 Method: SetVal() Method: SetMax()...... 159 ...... 159 Method: Value() Method: GetMax()...... 158 Method: vrtaSensorMul Event: Po ...... 157 Action: Position ...... 157 Method: SetVal() waySwitc eSwitc Set...... 151 sition...... 157 h...... esr)...... 152 Sensor() h...... 158 rToggleSwit iaSic( ...... 158 tiwaySwitch() h)...... 156 ch() OSEK for PCUserGuide 156

Table of Contents

13

Method: SetMatch()...... 177 Method: IncrementMatch()Method: ...... 178 SetVector()Method: ...... 178 MatchAction: ...... 179 Action: Value...... 170 Action: Maximum...... 170Action: ValueEvent: ...... 171 MaximumEvent: ...... 171 vrtaActuatorMultiColorLight()...... 172 Method: GetMax()...... 172Method: Value()Method: ...... 173 SetMax()...... 173 Method: SetVal()Method: ...... 174 Value...... 174 Action: Maximum...... 174Action: ValueEvent: ...... 175 MaximumEvent: ...... 175 vrtaCompare()Method: ...... 176 GetMatch()...... 177Method: Event: ValueEvent: ...... 165 MaximumEvent: ...... 165 vrtaActuatorLight()...... 166 Method: Value()Method: ...... 166 SetVal()Method: ...... 167 Value...... 167 Action: ValueEvent: ...... 167 vrtaActuatorDimmableLight()Method: ...... 168 GetMax()...... 168Method: Value() Method: ...... 169 SetMax()...... 169 Method: SetVal()Method: ...... 170

11.10.8 11.13.8 11.13.9 11.14.1 11.14.2 11.14.3 11.14.4 11.14.5 11.14.6 11.13.1 11.13.2 11.13.3 11.13.4 11.13.5 11.13.6 11.13.7 11.12.2 11.12.3 11.12.4 11.12.5 11.12.6 11.12.7 11.12.8 11.12.9 11.11.1 11.11.2 11.11.3 11.11.4 11.11.5 11.12.1 11.10.9 vrtaCompare...... 176 vrtaActuatorMultiColorLight ...... 172 vrtaActuatorLight ...... 166 vrtaActuatorDimmableLight...... 168

11.14 11.13 11.11 11.12 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Table Contents of

Table of Contents

4 al fCnet RTA- Tableof Contents 14 12

Virtual ECU Server Li 12.11 12.10 12.9 12.8 12.7 12.6 12.5 12.4 12.3 12.2 12.1 11.15 12.19 12.18 12.17 12.16 12.15 12.14 12.13 12.12

VesLibSelectSer ...... 195 VesLibLoadECU() VesLibListLoad VesLibListAliases()...... 193 VesLibInitialize()...... 192 ...... 192 VesLibGetInfo() ...... 190 VesLibGetAliases() ...... 190 VesLibFreeMemory() VesLibFreeAlias()...... 189 VesLibFindECUs()...... 188 VesLibExit()...... 187 VesLibCreateAlias()...... 187 VesLibAttach The API Call VesLibEcuAlia VesLibEcuInfoType...... 185 Virtual ECU Aliases...... 184 Using the DLL...... 184 Using the Source Code...... 184 ...... 180 vrtaIO 11.15.11 11.15.10 11.15.9 11.15.8 11.15.7 11.15.6 11.15.5 11.15.4 11.15.3 11.15.2 11.15.1 11.14.8 11.14.7

brary Reference...... 184

Event: Va ...... 183 Event: Value Action: GetValues...... 183 ...... 183 Action: GetValue ...... 182 Action: Values Action: Value...... 182 Method: GetValues()...... 182 Method: GetValue()...... 181 ...... 181 Method: SetValues() Method: SetValue()...... 180 Method: vrtaIO()...... 180 Event: Match...... 179 ...... 179 Action: Vector epae...... 185 Template ToECU()...... 186 Tp ...... 185 sType dCs)...... 194 edECUs() ver()...... 196 lues...... 183 OSEK for PCUserGuide

Table of Contents

15

...... 204 n and CVcEvent and n ...... 202 Aliases()...... 217 DisplayMode ...... 210 taServer _StartMode...... 210 r_Status ...... 210 project ...... 203 _Status ...... 219 events ...... 207 Method: ServerStatus()Method: ...... 219 IVcECU Enum: Enum: IVcServer_ Enum: IVcServer Enum: IVcServe Enum: AttachECU()Method: ...... 211 Connect()Method: ...... 211 CreateAlias()...... 212Method: Disconnect()Method: ...... 213 FindECUs()...... 213Method: FreeAlias()...... 214 Method: GetAliases()Method: ...... 215 GetInfo()...... 216 Method: ListAliases()...... 216Method: ListLoaded Method: LoadECU()Method: ...... 218 CVcServer ...... 198 CVcECU ...... 200 CVcActio CVcDevice, the up Setting to Connecting vr the VECU...... 205 to Connecting devices the Initializing ...... 206 to Reacting actionsSending ...... 208 Summary...... 208 and Referenceand ...... 198

13.6.10 13.6.11 13.6.12 13.6.13 13.6.14 13.6.15 13.8.1 13.6.2 13.6.3 13.6.4 13.6.5 13.6.6 13.6.7 13.6.8 13.6.9 13.3.4 13.3.5 13.3.6 13.3.7 13.6.1 13.2.1 13.2.2 13.2.3 13.3.1 13.3.2 13.3.3 CVcECU...... 219 ICVcECU ...... 219 Method Description...... 209 Method CVcServer ...... 210 ICVcServer ...... 210 Sample of use of Sample ...... 198 tutorial...... 203 short A Overview...... 198

13.7 13.8 13.4 13.5 13.6 13.2 13.3 13.1 COM Bridge Tutorial Tutorial Bridge COM

13 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Table Contents of

Table of Contents

6 al fCnet RTA- Tableof Contents 16 13.11 13.10 13.9 13.14 13.13 13.12

ICVcAction...... 240 CVcAction...... 240 ICVcDeviceEv ICVcDevice...... 229 CVcDevice...... 229 ...... 228 ICVcECUEvents 13.11.10 13.11.9 13.11.8 13.11.7 13.11.6 13.11.5 13.11.4 13.11.3 13.11.2 13.11.1 13.9.1 13.8.13 13.8.12 13.8.11 13.8.10 13.8.9 13.8.8 13.8.7 13.8.6 13.8.5 13.8.4 13.8.3 13.12.1 13.11.15 13.11.14 13.11.13 13.11.12 13.11.11 13.8.2

ehd nvnCag( ...... 228 Method: OnEventChange() Method: SendFormat()...... 227 Method: SendAction()...... 226 ...... 226 Method: ReplyFormat() ...... 225 Method: QueryFormat() Method: QueryEvent()...... 224 Method: Hook()...... 223 Method: GetDevic Method: GetDevic Method: GetDev Method: DoAction()...... 221 ...... 220 Method: Disconnect() ...... 220 Method: Connect() ehd nvnCag( ...... 239 Method: OnEventChange() Method: SendFormat()...... 237 Method: SendAction()...... 237 ...... 236 Method: ReplyFormat() ...... 235 Method: QueryFormat() Method: QueryEvent()...... 235 ...... 234 Method: Name() Method: Hook()...... 233 Method: GetEventCount()...... 233 Method: GetEventByName()...... 232 Method: GetEventByID()...... 232 Method: GetAct Method: GetActi Method: GetAct Method: DoAction()...... 229 Method: DeviceID()...... 229 ns...... 239 ents ionCount() ionByID() iceByID()...... 222 onByName() Cut)...... 223 eCount() eByName( ...... 230 ...... 231 ...... 222 ) ...... 231 OSEK for PCUserGuide

Table of Contents

17

ice)...... 257 ile)...... 255 ile)...... 257 a license f a license f a license aServer service)aServer ...... 258 taServer serv taServer e TCP port) TCP e ...... 257 nts...... 248 -silent (silent install or uninstall)...... 257 or install (silent -silent mode) standalone in (run -standalone ...... 257 vr the (start -start vrt the (stop -stop Method: OnEventChange()Method: ...... 248 alias)...... 255 default the (override -alias=name (select -lic= priority)...... 255 Windows the (set -priority= mode) GUI or silent (select -silent ...... 255 mode)...... 256 autostart or slave (select -slave a as service)...... 257 (install -install (select -lic= th (specify -p Method: ActionID()...... 240Method: Do()...... 241 Method: Name()Method: ...... 241 Send()Method: ...... 242 SendFormat()...... 242Method: EventID()...... 244 Method: Hook()...... 244 Method: Name() Method: ...... 245 Query()...... 246 Method: QueryFormat()Method: ...... 246 ReplyFormat()Method: ...... 247

r...... 257

13.14.1 15.2.1 15.2.2 15.2.3 15.2.4 15.2.5 15.2.6 15.2.7 15.1.1 15.1.2 15.1.3 15.1.4 15.1.5 13.16.4 13.16.5 13.16.6 13.17.1 13.14.3 13.14.4 13.14.5 13.16.1 13.16.2 13.16.3 13.14.2 vrtaServe Floating-point Wrappers...... 254Floating-point Executables...... 255 ECU Virtual ICVcEventEve Toolinit.batModifying ...... 250 Variant...... 252 a new Creating CVcEvent ...... 244 ICVcEvent ...... 244

15.2 14.3 15.1 13.17 14.1 14.2 13.15 13.16 Command Line Option Reference...... 255 Option Line Command Compiler ConfigurationCompiler ...... 249

15 14 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Table Contents of

Table of Contents

8 al fCnet RTA- Tableof Contents 18 Index...... 267 ...... 265 Glossary 16

Windows Note 15.3 15.5 15.4 16.3 16.2 16.1

vrtaVMxxx.dll Location...... 263 Calling the C/C++ Runtime and Windows...... 263 Real-Time Behavior...... 263 ...... 260 vrtaMonitor Sequential Options ...... 259 vrtaMonitor Global Options vrtaMonitor...... 259 15.5.15 15.5.14 15.5.13 15.5.12 15.5.11 15.5.10 15.5.9 15.5.8 15.5.7 15.5.6 15.5.5 15.5.4 15.5.3 15.5.2 15.5.1 15.4.6 15.4.5 15.4.4 15.4.3 15.4.2 15.4.1 15.3.1 15.2.8 ...... 263 s

d(odbtntsataVrulEU ...... 260 -d (load but not start a Virtual ECU) -alias= (conne ...... 260 Virtual ECU Executable Name (auto-load) -t (close after seconds)...... 260 -scripter= (select a scripting engine)...... 260 ...... 260 -log= (write to a log file) -lic= (select -k (terminate with specific error level)...... 259 -f (close when appears).....259 Command Files...... 259 -uninstall (un-install as service)...... 258 a wi=n wi)...... 262 -wait= (wait) -start (start a VECU)...... 262 -send=.() ...... 262 (send action) -send=. ...... 262 (send action) -script=...... 261 –r (load andstart VECU)...... 261 a ...... 261 -quit (terminate) -p (select ...... 261 –n (load without a GUI) -mon=. (monitor event)...... 261 -host= (selec ...... 261 -g (load withGUI) a TCP port)...... 261 a license f ct toVECU)...... 260 t remote a PC)...... 261 ile)...... 260 OSEK for PCUserGuide

1.1

19

Courier RTA-OSEK RTA-OSEK and provides specific about notes RTA-OSEK User Guide hould have of C++.knowledge some ent in a Windows environment. ent in aenvironment. Windows and AUTOSAR applications. the This guide describes TM consists of tools and ofconsists tools of libraries enable the that creation includes a Windows port of the popular a the Windows kernel. of port includes RTA-OSEK for general information on how to use RTA-OSEK. use how to information on for general RTA-OSEK Binding Manual PC Binding RTA-OSEK Notes that appear like this contain important information that thatappearNotes like this that information contain important you follow any instructions that you are given.are you any that instructions you follow In this guide you’ll file program see that header names, C/C++ code, type names, C/C++ and functions API callall names appear in the typeface. It is assumed that you are a developer who wants to know how to create and areIt a is assumedand thatyou wants knowto who how create to developer be should monitorWindows AUTOSAR applications You OSEK or PCs. on familiarandwiths programming in C, Important: that and carefully them read you that sure Make of. aware be to need you RTA-OSEK for PC applicationsWindows-hosted that behaviorapplications the of emulate running on microcontroller hardwareability including the – run to OSEK automotive-style tools and libraries used to create and monitor such applications. applications. such monitor and create to used libraries and tools RTA-OSEK for PC You should consult documents the Reference Guide Reference The document using the RTA-OSEK kernel compon kernel RTA-OSEK using the Conventions Who Should Read thisWho Should Guide? Read About this Guide

1.2 1.1 1 RTA-OSEK for PC User Guide PC User RTA-OSEKfor About this Guide

2.1

4 3 2 1 Also available insilver See ISO standards 11898-1 and 11898-2 See See http://www.autosar.org http://www.osek-vdx.org/ 20 Overview RTA-OSEK for RTA-OSEK PCUser Guide Overview 20 2 2.1

Overview Terms VECUs. VECUs. DLL provided with RTA-OSEK for PC programs to interact with VECU. a AUTOSAR downloading of hexdownloading files to emulator. Noprogramming an Flash. development turnaround time is tiny –just recompile and run. No PC state the and progress ofmonitor your usingthe applications remotely Youcan units. simulation or test as CANnetwork onyour sit But youneedn’tBut stop Becausethere. embedded targets. for develop how to applications learning good is for it tool that a find also but you production hardware, the will onto it before migrating application a standard networking solution such as CAN solution standard networking suchas a OSEK, communication using of inter-application you implementation also add The VM provides a VECU Remember that andVECUextensively. VM terms the use will document we this Within links. diagnostic and control application Machine (VM) core a around built devices are These ECU. inyour bepresent will in software that simulates the real-life devices such as switches or sensors that PC under built application an on, you it run PCthat than the Other AUTOSAR applications. or OSEK not Many berunning theall body if will the boot. and doors, be will ECUs car, modern typical In a black box black TheECU beconsidered runs. a can onwhich as the application hardware ECU RTA-OSEK for PC RTA-OSEK for PC on selecting Congratulations monitor, monitor, doesnot need any real Instead, hardware. you create a (Electronic Control Unit) is commonly used to refer to the target is the whole ‘black-box’.

4 2 with inputs and outputs that perform a specific set of functions. applications. prototype beusing to Mostly it you’ll a new applications.

RTA-TRACE VM that provides services such as the interrupt controller, is typically used in automotive environments where the term that can and manage VECUs. monitor The is a complete environment for developing OSEK RTA-OSEK for PC represents the ‘core’ of the simulated hardware, and that diagnostic interface diagnostic or your PC-based debugger. And of course debugger. Andof the PC-based your or RTA-OSEK for PC vrtaMonitor that allows COM clients to interact with interact to clients COM that allows RTA-OSEK for PC found in the engine compartment, the enginecompartment, inthe found (via TCP/IP) that allows external 3 . You can write applications that that applications write Youcan . . is a program providedis a with is a complete and fast fast complete and a is Virtual ECU(VECU)Virtual COM Bridge RTA-OSEK for RTA-OSEK for RTA-OSEK for Virtual Virtual 1 and isa

2.1

21 ,

vrtaMonitor.exe . and many of the supplied source files. “vrta” is an abbreviation anabbreviation files. is “vrta” of supplied source the and many RTA-OSEK for PC for RTA-OSEK as such executables to prefix is used “vrta” The string vrtaVM.dll (Virtual) for RTA-OSEK for PC User Guide PC User RTA-OSEKfor Overview

2.2

22 Overview RTA-OSEK for RTA-OSEK PCUser Guide Overview 22 2.2

What do I need? VECU code. VECU code. comes usethe debugyour that to your debugger You can with compiler versions; refer to chapter 14 for details. It is straightforward a process to support different compilers or compiler OSEK for PC to use C++Compiler generateECUs. You can Virtual Windows ‘any’ times faster that a typical embedded target. many OSEK typical a application running of PCiscapable modern a that find but will you processor, ofthe power bedependent onthe clearly VECUwill a Pentium class processor. a requires It performance XP). Theactual Windows of RTA-OSEK for PC • • • • •

Borland C++5.8.1 /BorlandBorland Developer Studio 2006 C++5.5.1 /Borland C++Builder Borland 5 Microsoft Visual Studio 2003 Microsoft Visual C++ 5.0 MinGW / GCC. We test against version 3.4.2. has been tested with the following compiler variants: runs Microsoft under Windows 2000 later or (including RTA- 2.3

23

a Virtual ECU. It manages (virtual) The Virtual Machine is at the core of Machine is at the core The Virtual interrupts, startup and shutdown of the application, and routing of messages messages of routing and application, the of shutdown and startup interrupts, andalso outsidemay world. contain the devices between the RTA- The VM code. OSEK kernel in the asasplitexplained intoThe VM cancomponents be number of following sub-sections. What is the Virtual Machine? Machine? Virtual the is What

2.3 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Overview

2.3 5

Yes, the Device Manager is itself also a device. You query it as device zero to find out what other devices are present. present. are devices other what out find to zero as device it query You adevice. also itself is Manager Device the Yes, 24 Overview RTA-OSEK for RTA-OSEK PCUser Guide Overview 24 2.3.1

devices. vrtaMonitor as such applications, external that allows Interface Diagnostic a includes These services are notonly available dataused support andthe they Manager can bequeriedthen to whatfind devices exist, what actions/events initializ during Manager Device the with Eachdeviceregisters VECU. devicesinthe coordinates The DeviceManager all ICU and the ApplicationManager. of some change instate by raising an event or interrupt. inform device particular Adevicecan you You cantell to a a perform action. Virtual ECUs use Manager Device The VMitself contains the three standard devices: the DeviceManager events. Most operations VECU in performeda are bysending or actions responding to component CANcontroller. PCMCIA-based as such a complex represent a can it or LED, or an switch of a representation simple bea can device A

(seechapter 6) toinspect the state of the application’s devices to get done.things Devices have by the actions and events. events. and by the actions within the VECU: the Device Manager ation of the application. TheDevice ation ofthe application. actions and and events 5 , the

. 2.3

25

. A masked vector can still become

to 32). Each interrupt vector can be assigned a priority (1 to 32). 32). to (1 a priority assigned be can vector interrupt Each 32). to 6 Interrupt Control Unit Interrupt Control Unit The Interrupt Control (ICU)withinsimulates Unit thea device that is VM multi-level interrupts Virtualthe ECU. in The ICU supports different 32 interrupt (1 to and vectors 32) 33 interrupt (0 priorities The ICU maintains a current Interrupt Priority Level (IPL). An interrupt that has has that interrupt An (IPL). Level Priority Interrupt a current maintains ICU The the IPL remains IPL drops the pending until a below the current priority <= assigned priority. interrupt’s the match to raised is IPL the handled, is an interrupt When back taken is IPL the completes, handler interrupt the When priority. assigned taken. was interrupt the when effect in was that value the to Each interrupt vector can be masked pending, its but interrupthandlerwill vector the run not is unmasked. unless After reset, all interrupts are masked.

2.3.2 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Overview Interrupt priority zero ‘nopriority means Interrupt interrupt’.

6

2.3 7

Application code runs in its own thread, not the main Windows thread. 26 Overview RTA-OSEK for RTA-OSEK PCUser Guide Overview 26 2.3.3 2.3.4

parameters present on the command-line when the VECU was invoked. access with any provide application to Manager your can also Application The reset or terminate your application. Application Manager alive. is actually of confidence bit the that application giveyoua that will window empty console The black VM displaywindow. can optionally a simple GUI boring than other doesn’ta VECU showmuch your runs, probably When it Embedded GUI coderuns your application in thread thewhich Windows controlling for is responsible It VECU. overall the device with isa Manager Application The Application/Monitor option select menu complex just the For options, of more GUI. menu You can perform some simple operations such pause/resume/resetas from the

to launch 7 . Its Its beused. can actions start, to pause, resume, vrtaMonitor

in the VM that manages the state of .

2.3

27 RTA-OSEK RTA-OSEK framework without using OSEK OSEK using without framework RTA-OSEK for PC for RTA-OSEK . 8 build with simple RTA-TRACE RTA-TRACE simple with build actually ships with 9 different Virtual Virtual different 9 with ships actually build with advanced RTA-TRACE RTA-TRACE advanced build with RTA-OSEK for PC RTA-OSEK support. support. support. support. support.

will ensure correct that the DLL is loadedand that API stubs existforall vrtaVMatt.dll OSEK ‘t’ VM plus advanced build with RTA-TRACE vrtaVMate.dll ‘e’ VM plus OSEK Linkage Table andYou’veawill VM that realize the is seen in now packaged DLL thatthis The calls. API make to DLL the into call somehow to has code your that means provided with code startup answerworry” – the simple is “don’t PC for just API calls and other application RTA-OSEK makes Your and OSEK calls. VM application code. in normal would embedded as it vrtaVMt.dll vrtaVMt.dll vrtaVMe.dll build. ‘t’ OSEK plus VM vrtaVMts.dll ‘e’ build. OSEK VM plus VM plus OSEK ‘s’ vrtaVMtt.dll VM plus OSEK ‘t’ build with simple RTA-TRACE vrtaVMte.dll VM plus OSEK ‘e’ build with simple RTA-TRACE RTA-OSEK Kernel Kernel RTA-OSEK The VirtualMachine is provided in a DLL file. gets A VECU dynamically linked to the VirtualMachine initialization.during ‘build status’ the different support to mechanism this of is taken Advantage of OSEK. variants the RTA-OSEK of flavors the different contain these of Machine DLLs. 8 kernel RTA-OSEK no has and one kernel, vrtaVM.dll vrtaVMs.dll component OSEK no only, VM build. ‘s’ OSEK plus VM VM Name Content

2.3.6 2.3.5 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Overview It turns out that you can create some very effective ‘PC’ applications using the at all ;-) all at

8

2.4 9

All provided with 28 Overview RTA-OSEK for RTA-OSEK PCUser Guide Overview 28 2.4 2.5

What is in aVirtual ECU? Managing Virtual ECUs Virtual Managing RTA-OSEK for PC Virtual devices are very easy to use, as you’ll see in the next chapter. it. or simulate hardware real connect that to devices virtual contain also will It VM. the to application The server program is then asktheserver what VECUsexist, how and to connecttothem. PCVECUsthe thaton register with when they startup. Monitor programs The solutionchosen for how to connect to theirdiagnostic links. out find VECUs what because to and way theyrunning, programs, needa are same time. This causes something of problema for external monitor RTA-OSEK for PC have also will It processes. and code Your canapplication have an RTA-OSEK element, namely the tasks, ISRs create a program hasthat outputs inputs and simulate that a physical ECU. VMDLL of the code combination to ECUisthe and your A Virtual application reset, terminate and load VECUs. to ability the including machine, local ona when used available features the attachto servers VECUs and onthat remote are The monitor PCs. has all of One useful benefit of having such a server is that monitor programs can also start the server if required. will VECUor yourself monitor Youdo service. it to have –a Windows start not

RTA-OSEK for PC youto severalallows run VECUs onthe PC same theat vrtaServer.exe RTA-OSEK for PC startup and linkage code linkage and startup is to have isto programserver a running , and it normally runs unnoticed runs normally it a as and , 9 that glues your that 2.6

29

program is the quickest way to interact with a Virtual a Virtual with interact to way quickest the is program vrtaMonitor The so connect, can monitor the which to link a diagnostic have VECUs All ECU. when application.action building your monitor needed is no special The is It PCs. remote and local on events and view actions send to you allows discussed in detail in chapter 6. Interacting with a Virtual ECU ECU Virtual a with Interacting

2.6 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Overview

2.6 be stolen from the VECU. 10

If RTA-TRACE runs ona remote PC, then the processor cycles that are used to process its data and draw its graphs do not have 30 Overview RTA-OSEK for RTA-OSEK PCUser Guide Overview 30 minimize the impact of the RTA-TR TRACE monitor can VECUa from remotea PC, a factthat can be used to RTA-TRACE out RTA- onlysending isconnected. if data as normal, trace run VECUwill onthe but then from enabled, option tracing the with be built be can AVECUhas usingRTA-TRACE. also An RTA-OSEK traced toapplication options options are set correctly, thenand load the VECUinto debugger.the ensure link your Simply compile level. and that line-by-line VECU a at debug a You can also use the PC debugger that comes with your compiler toolchain to

ACE GUIon the execution of the VECU 10 .

to 2.7

31 and StackFaultHook() on 9.4.3). See section 16.2 for more for more 16.2 See section on 9.4.3). to display the content of some piece piece some of content the display to here.) here.) printf() printf() handlers and print an error to the screen if they they if screen the to an error print and handlers You must not make any non-VM or non-OSEK API calls your non-OSEK non-VM from or any makeYou must not application thread if virtual interruptsThis includes ‘quick could occur. as using hacks’ such of data.and All non-VM non-OSEK API calls must be protectedan by secti section (see uninterruptible details. Your lock up. application Provideto seems ShutdownHook() (You canoccur. use

• • The following is a short list of problems thatmight whenencounter you you code: VECU start developing Possible Problem Areas Problem Possible

2.7 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Overview

3.1

32 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 32 3.1 3

3.1.2 3.1.1 Tutorial Prerequisites

will assume that you have installed RTA-OSEK to to RTA-OSEK installed have you that assume will we tutorial Inthis license. your installed Youand have obtained CD. will target c:\rta\vrta\toolinit.bat You now need to tell RTA-OSEK about the compiler. We need to edit the file c:\MinGW at compiler the installed have you that assume we will tutorial In this Guide”. Started Seethe“Installation” sectGNU license. the under available freely is that the compiler MinGW use will tutorial This Compiler the RTAexecutables and DLLsis have installed thealready RTA-OSEK v5 CDtools the and inthe the instructions followed youhave If RTA-OSEK of copy a need we will tutorial this For with. comecan up we seewhat hours and ofcouple setlet’s a aside so running, The best way getto understanding of an VECU. It simply sets certain environmen certain sets simply It VECU. toolinit.bat normally need you will to edit computer. useon your of We will make select: to compiler which compilers. of Thevalue the environment variable toolinit.bat youlookin If values. sets upsome default elements, and compiler the find need a C++compiler. RTA-OSEK for PC RTA-OSEK for . is a batch file that gets run during the build stage for for a during buildstage the run gets that file batch isa you will see that it is already set up to recognize a range range of set recognize isalready up to a it seethat youwill are found at found at are c:\rta\vrta . . c:\rta\bin This is the only configuration file file istheonlyconfiguration thatThis RTA-OSEK for PC t variables that tellRTA-OSEKwhere to RTA-TRACE RTA-OSEK for PC ion of“RTA-OSEKforPCGetting Getting Started Guide Started Getting . . The filesthat are specific to VRTA c:\rta,s if you have that. We youhavethat. if also installed and licensed and installed is used to determine is to get something RTA-OSEK forPC o the route for then you

3.1

33 that it looks something like this: something that it looks

SET _OBJ=o goto check set AS=%CBASE%\bin\gcc.exe set AS=%CBASE%\bin\gcc.exe rem location of linker set LNK=%CBASE%\bin\g++.exe rem location of Archiver / librarian set AR=%CBASE%\bin\ar.exe rem Set location of C include files set CBASE_INC=%CBASE%\include rem Default settings SET _LIBS=-lwinmm -lws2_32 echo VS2003 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! goto exit :MINGW rem tools installation directory set CBASE=c:\mingw rem location of C compiler set CC=%CBASE%\bin\gcc.exe rem location of C++ compiler if not @%1==@ set VRTA=%1 if not @%1==@ goto MINGW if @%VRTA%@==@MinGW@ goto BCPP if @%VRTA%@==@BorlandC@ goto BDS_2006 if @%VRTA%@==@BDS2006@ goto VCPP5 if @%VRTA%@==@VisualC5@ goto VS2003 if @%VRTA%@==@VS2003@ echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! variable VRTA not specified in environment echo Compiler are: echo Valid settings echo MinGW echo BorlandC echo BDS2006 echo VisualC5 @echo off > < ...snip... e.g. e.g.

so MINGW section the You should edit RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.1 11

toolinit.bat 34 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 34 MinGW execute console open Now window and a will use the first command-line parameter toitif passed the environment variable C:\> PARTICULAR PURPOSE. warranty; notevenforMERCHANTABILITYorFITNESSFORA conditions. ThereisNO This isfreesoftware;seethesourceforcopying Copyright (C)2004FreeSoftwareFoundation,Inc. gcc.exe (GCC)3.4.2(mingw-special) C:\>%cc% --version C:\>c:\rta\vrta\toolinit MinGW 11 , followed by followed ,

%cc% --version . Your results. should belike this: c:\rta\vrta\toolinit VRTA isnot set. 3.1

35

from RTA- from rtcVRTAlink.dll RTA-TRACE. If RTA-TRACE. you have installed RTA- comes completewith a comes high-bandwidth special virtual availableis as a and separate a product provides very detailed TRACE in the same location as RTA-OSEK then thisasTRACE in the location same will link then be detected RTA-OSEK file the copy must you not If automatically. RTA-TRACE RTA-TRACE graphical display in real-time showing all of execution the Tasks,and ISRs application. in your processes RTA-OSEK for PC device that connect to can be used to ‘bin’. RTA-TRACE’s to ‘bin’ OSEK’s

3.1.3 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.2

36 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 36 3.2

3.2.1 Creating your first Virtual ECU Virtual your first Creating

File\New… values intheshown dialog values below. up bya bit brighten selecting menu option drab rather empty grey lookingat can now a we You are window which Start the RTA-OSEK GUI( twist. Let’s go for the traditional ‘Hello World’ starter application –with OSEKan

Select the on the left hand side to get to the same place). menu option Select You nowhave a new empty application. Hooks Button and select select and Button Application configuration OS / c:\rta\bin\RTA-OSEK.exe Startup and File /New… Shutdown (or use the navigation bar ). , then entering the hooks. hooks.

3.2

37

. standard and set the oflocation . See chapter information more . 14 for or Ctrl+M)thenwill you see that File / New … tab. That way your next project will pick up these these up pick will project next your way That tab. first tell RTA-OSEK where to look for, to look for, tell RTA-OSEK where first File / Options… File Global Setting Global . View /View Implementation button to change the OS status to to status OS the change to button 13 , 12

OS Status OS Select the Select the If you now look at that the hints RTA-OSEK about provides implementation details option (Menu we will need to supply the code for these two callback functions. and generate, files. Select menu option menu files.Select and generate, here shown as files We are now ready to write some code. like to keep things tidy, we Because we Hook functions The application must implement: OS_HOOK(void) StartupHook(void); OS_HOOK(void) ShutdownHook(StatusType s); RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial RTA-OSEK supports a number of macros such as “$(Variant)”. “$(Variant)” expands out to be the name of the current compiler compiler current the of name the be to out expands “$(Variant)” “$(Variant)”. as such macros of number a supports RTA-OSEK If you really like these settings you can also put them on the on the them put also can you settings these like really you If

12 13

on compiler variants. In this case, “$(Variant)” will expand out to “MinGW”. “MinGW”. to out expand will “$(Variant)” case, this In variants. on compiler variant. The compiler variant was selected when you created the application with values too. values 3.2 14

Notepad isn’t your favourite editor? Use the 38 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 38 3.2.2

The first entry says that with with the content shown below. Add inthetwo callbacks that we need to that contains your device declarations. contains device your that declarations. RTA-OSEK forPC device, one VECU OSEK-based so use youAny virtual at buildwill that least Press the offer. for ‘main’ and offer to save it as Press the 2 Builder. Select menu option Build /Custom the function the c:\Play\Tutorial1\Tutorial1.OIL save the project as something like Now give the project a name and save it. Select menu files. application and The remaining entries perform the same role for assembler, object, temporary directory $(Variant)\h, which is . The next entry says that file. OIL project favorite editor { OS_HOOK(void) ShutdownHook(StatusTypes) } vrtaLeaveUninterruptibleSection(); printf("HelloWorld\n"); vrtaEnterUninterruptibleSection(); { OS_HOOK(void) StartupHook(void) } ShutdownOS(E_OK); StartOS(OSDEFAULTAPPMODE); { OS_MAIN() #include "osekmain.h" /* Templatecodefor'main'inproject:Tutorial1*/ } vrtaTerminate(); vrtaLeaveUninterruptibleSection(); printf("GoodbyeWorld\n"); vrtaEnterUninterruptibleSection(); Create Templates Create

Quick Edit

InitializeDevices() 14 . expects theretobe a Global Settings Build / Custom Build Custom / Build button which will allow you to open you to allow will which button .c .h files will be located in belocated will files button. RTA-OSEK will display the template code the display template RTA-OSEK will button. files will be placed 2 levels down from in from that beplaced down 2 will levels files tab in the \MinGW\h c:\play\Tutorial1\main.c File\Options RTA-OSEK for PC in which you initialize them. At At the them. initialize you inwhich .cpp the existing code so that you end up in our case. or navigate to it via the GUI tab . file ( file dialog to change it. it. change to dialog devices.cpp the same directory as the as directory same the expects it to contain to it expects File SaveAs… / main.c by default) bydefault) . Accept its inyour and and 3.2

39 .cpp and and . , you will will , you 15 into another another into osgen . button on the the button on 16 andwhat files . This is file the . The . The #included Configure : devices.cpp 17 osekdefs.o will itself be be itself will tab already contains a call to to a call contains already tab with the following content following the with but we should create a placeholder a create placeholder should we but and and rnings or errors. Other compilers will usually output a bit more bit a output usually will compilers Other or errors. rnings button again and create create and again button C:\Play\Tutorial1\MinGW\o osgen.o Build Script Build devices.cpp , button and willRTA-OSEK thatcheck you want to create main.o Quick Edit Quick . If you run thiswithin might by clicking from Windows, you . Add the APP_AOPT and link steps to script as below. script to steps and link APP_AOPT the . Add . pane. The

files contain the code needed to support the OSEK side of your your of OSEK side the to support needed thecode files contain lines for now, because Build Now c:\Play\Tutorial1\MinGW\o\rtkbuild.bat C:\>\Play\Tutorial1\MinGW\app\Tutorial1.exe Hello World Goodbye World call $(DestDir_obj)rtkbuild.bat %_LIBS% -o"$(DestDir_app)$(name).exe" %LNK% -O2 $(Variant)\o\*.$(objext) void InitializeDevices(void) void InitializeDevices(void) { // Placeholder } -D$(name) set APP_AOPT=-DVRTA_INCLUDE_DEVICES moment, we don’t have any devices, any devices, moment, we don’t have devices.cpp Press the c:\play\Tutorial1\devices.cpp If you now look into the directory the look intoIf you now files: object see 3 RTA-OSEK. and close project your Now save the Press file the All thatremains to is tellRTA-OSEK to include the and press GUI the RTA-OSEK to to link. Go back Custom Build that controls the part of the build process that RTA-OSEK knows about or can can or about knows RTA-OSEK that build process the of part the controls that ‘Yes’. say so infer, RTA-OSEK creates now the low-levelfiles OSEK component your for of the as the code have enteredapplication, and theyou build script. runs If then above shown without theshould see you script errors complete osekdefs good. application. so far, So If you’vealreadyin the ‘app’ peeked directory,will you also see Tutorial1.exe acommand from run it to option is better runs. A as it flash a quick see window, where the results will be, as expected rtkbuild.bat #include RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial MinGW is alarmingly quiet when compiling source that has no wa no has that source compiling when quiet is alarmingly MinGW path. to the directory ‘bin’ your to add have may you then c:\rta\bin to install not did you If You don’t need any any need don’t You file as part of the build process. process. build the of part as file

17 15 16

progress information during the build so you can see the progress of the build on the RTA-OSEK display. display. RTA-OSEK the on build the of progress the see can you so build the during information progress 3.3

19 18 The clock device uses Windowsmultimedia timers,which have a minimum interval of 1ms. You wouldn’t expect a hardwarecounter to suddenly come intoexistence ona real ECU either! 40 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 40 3.3

3.3.1 Adding devices devices Adding

independently of the rest of the application at up to 1000 times per second per upto at 1000times rest the the of of application independently vrtaSampleDevices.h RTA-OSEK forPC devices.own vrtaDevice.h range zero to 2 By default, a counter increments or decrements its current value within the clock source: two such codedeclare Theselinesof the counters attacheddownwards. to two sorts of counter; one that counts upwards one thatand counts clocksource. this to connectWe needto counter a in Think ofit oscillator as ECU. a real the interrupts. any raise or value a maintain not itdoes but interval, its change clocksource ofthe own, use. isnot You much On its it it, stop andstart can The vrtaClock device represents a clock source Clocks, countersandcomparedevices attempt to create devices dynamically become known to the Device Manager before entering ‘main’. Do not in bedeclared statically devices must Virtual orrequests, event queries. actions and events to the VM’s Device Manager, and then respond to action Virtual devices are software components that can declare their name, type, to work with. need some devices ECU also will Virtual like, the a and switches comparators, In the sameway that reala ECU contains hardware such counters,as create a device in a C++ class called RTA-OSEK for PC SetMin() You can declare a clock named “Clock” that ticks every 5ms like this: see how to use them. let’s just for now but 11, inchapter devices documented indetail sample are devices are automatically included into your VECU if youuse them. The vrtaClock Clock("Clock",MSECS_PER_TICK); #define MSECS_PER_TICK(5) vrtaDownCounter CountDown("CountDown", Clock); vrtaUpCounter CountUp("CountUp",Clock); and and

. You can use this as base classa from which to create your SetMax() 32 wraps all of the repetitious ‘plumbing’ code needed to also supplies a number of sample devices in the files files inthe devices sample of number a supplies also -1. You can Youcan reduce the -1. range of countthe using the and and methods. The normal place to do this is in the vrtaSampleDevices.cpp 18 vrtaDevice . RTA-OSEK for PC that is defined in the file in a real ECU. It ticks RTA-OSEK forPC so thatthey can . These sample supplies 19 . 3.3

41 device to pause the the to pause device sources run independently independently run sources vrtaClock ApplicationManager . But what we’dreally like to do is to raisean function we saw earlier. It’s also a good place to a place also saw good we earlier. function It’s virtual device. device. virtual vrtaCompare vrtaCompare Compare5("Compare5",CountUp,5,1); vrtaCompare Compare5("Compare5",CountUp,5,1); vrtaCompare Compare15("Compare15",CountUp,15,2); { to 0 */ goes 0...999 then back /* CountUp CountUp.SetMax(999); CountUp.Start(); goes 1999...1000 then /* CountDown to 1999 */ back CountDown.SetValue(1999); CountDown.SetMin(1000); CountDown.SetMax(1999); CountDown.Start(); } void InitializeDevices(void) void InitializeDevices(void) InitializeDevices() enable the counter. counter. the enable of a chain construct easily can very you that this from clear it is Hopefully clock, of combinations simple by complexity arbitrary of elements timing devices. compare and counter worth is that One point emphasizing application.of use the the If you application thread, the clocks continue to run and any counter/compare devicesarethatattached can continue raise to interruptsthat will be serviced resumes. thread application the once using a counter of value current the read You can .GetValue() value. a certain reaches counter the when interrupt the Enter specify and to a it attach counter you can a device compare When you declare value. a specific reaches counter the value of the when fires an that interrupt the same to connected aretwoIn the examplethere comparators below 5.reaches value The counter interrupt raises 1 when the first one counter. The 15. reaches value counter the when 2 interrupt raises second RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.3

role of a sensor attached to it. Nevertheless, 20 By ourdefinition of an actuator, it isan output device soyou w 42 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 42 3.3.2 3.3.3

vrtaActuatorMultiColorLight 1), and zero Trivial specializations of of specializations Trivial you can raise an interrupt when a set value is reached youAs previously, can attach a can detect changes in the VECU’s output. changes,externalevent whenits value so programs suchas Sensors vrtaActuator PC RTA-OSEK for Actuators becomesposition 1. This compare device causes interrupt 3 to be raised when the theof sensor directly from your via theapplication vrtaMonitor be changed sensor of The values can a remotely such programs from as zero to 2 vanilla The counter. a as way same Sensors have minimuma value, a maximum value and currenta value in the thermocouples, pressure monitors and so on. Sensors in inputs to represent ECU. an world couldincludeswitches,the real PC RTA-OSEK for SetMax() e.g. declaration. inits have specified can switch limit 1. Themultiway upper or zero an value vrtaSensorMultiwaySwitch derivativesTwo of e.g. eventset.an when certainis value a Alternatively you can attach a vrtaCompare Eject("Eject",EjectSwitch,1,3); vrtaSensorMultiwaySwitch Gear("Gear",5);//0to5 vrtaSensorToggleSwitch EjectSwitch("EjectSwitch"); vrtaSensor Throttle("Throttle"); 32 method. method. -1, but you can change the upper limit for this usingthe changefor you but upper limit the can -1,

and the COM Bridge (see chapter 13). You can read the value vrtaActuatorDimmableLight you mayfind this capability useful incertain cases. device can be set to a value from zero to 2 provides sample ‘sensor’ devices that are intended to ‘actuators’ represent outputs from ECU.an The base vrtaSensor vrtaActuator vrtaCompare ouldn’t expect it to be able to raise an interrupt: that isr vrtaCompare . The toggle Thetoggle canswitch . position have a are vrtaSensor (‘colors’ zero to n). are vrtaSensorToggleSwitch vrtaActuatorLight device to the sensor and raise sensordevice the to and device to an actuator that so (‘levels’ zero to n) and GetValue() device range values from 20 . 32 vrtaMonitor EjectSwitch -1. It raises an raises It -1. method. (values and eally the

3.3

43 are a good starting point point a starting are good the individual elements. An event is An event elements. the individual RTA-OSEK for PC for RTA-OSEK virtual device is a more general purpose component. It simulates simulates It component. amore purpose is general virtual device vrtaIO vrtaActuatorDimmableLight vrtaActuatorDimmableLight InteriorLight("InteriorLight",20); vrtaActuatorMultiColorLight FuelIndicator("FuelIndicator",4); vrtaActuator Speedometer("Speedometer"); Speedometer("Speedometer"); vrtaActuator BrakeLight("BrakeLight"); vrtaActuatorLight a block of 32-bit values in an ECU’s IO or memory space. You (or an external external an (or You space. memory or IO an ECU’s in values 32-bit of a block in values inspect or set can monitor) raiseda when value is changed, butability there is no toan generate interrupt value. the based on e.g. Custom devices with devices provided The sample when creatinga VECU,will but you want to create your own devicesto reflect straightforward a is this inheritance C++ to Thanks environment. own your process that we will cover shortly – see section and3.4.11 chapter 4. IO The

3.3.5 3.3.4 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.4

44 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 44 3.4

3.4.1 Tutorial2

Edit Devices directory new as Tutorial1Reopen the project use then devices: We aregoing to create a very artificial VECU to demonstrate the use of virtual and #define POLL_ISR(3) #define BRAKE_ISR(2) #define ACCEL_ISR(1) #define MSECS_PER_POLL(100) #include //------// Devicedeclarations //------AccelDetect("AccelDetect",Accelerate,1,ACCEL_ISR); vrtaCompare // Comparators vrtaActuator Direction("Direction"); vrtaActuator Speed("Speed"); // Actuators vrtaSensorToggleSwitch Right("Right"); vrtaSensorToggleSwitch Left("Left"); vrtaSensorToggleSwitch Brake("Brake"); vrtaSensorToggleSwitch Accelerate("Accelerate"); // Switches • • • • • • • • devices.cpp devices.cpp

There will beon-screenThere will feedback of speed direction. the current and ANDprogram restart. reset over is The direction zerofrom 359 to degrees. Thedirection is preserved program resets, but not if the program restarts. the if Thespeed 100. ispreserved at zero The speedstarts at and limits sampled at ‘1’. cause one degree each and theya time indirection change are Right The Left switches polled OSEK and every from task an are 100ms control. decrease by one notch on each zero to one transition under interrupt BrakeThe Accelerate switches and thespeed cause toincrease/ be indicatingThere will a direction actuator. be There will a speed actuator. setting Right. Left and Brake, Accelerate, be4 will There inputswitches: c:\Play\Tutorial2\Tutorial2.OIL so that it contains the following code. from the Tutorial1 File SaveAs… / directory to directory Tutorial2 tomake copyin a a . Copy . . main.c

3.4

45 //------PollCounter.SetMin(0); PollCounter.SetMax(0); PollCounter.Start(); ClockSource.Start(); Speed.PersistThroughReset(true); PersistentData.PersistThroughReset(true); Direction.SetValue( PersistentData.GetValue(DIR_DATA) ); } //------//------format, ...) int status_printf(const char* { va_list argptr; va_start(argptr, format); argptr); int ret = Status.printf(format, va_end(argptr); return ret; } //------void InitializeDevices(void) { Speed.SetMax(100); Direction.SetMax(359); // Clock vrtaClock ClockSource("ClockSource",MSECS_PER_POLL); ClockSource); PollCounter("PollCounter", vrtaUpCounter PollCounter, 0, vrtaCompare PollCompare("PollCompare", POLL_ISR); // Data (1) #define DATA_SIZE (0) #define DIR_DATA vrtaIO PersistentData("PersistentData",DATA_SIZE); // Status #include Logger Status("Status"); vrtaCompare vrtaCompare BrakeDetect("BrakeDetect",Brake,1,BRAKE_ISR); and IO devices clock actuators, switches, the for Hopefully the declarations will be clear. RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.4

This isdiscussed later. 21 This won’t work if the string length is less than 16 bytes because the string has to be copied into the action’s embedded data embedded the action’s into to copied has be string the bytes because 16 than less is length string work if the won’t This 46 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 46 3.4.2 3.4.3

Logger 2) 1) Theretwo are answers tothis. Interfacing Ccodewith devices Youcan such make calls to. as a niceset of methods for outputting text sayingand where directto the text with C++ object logger Your device isa issue. interesting come to we an Now thread. your from application calls API non-OSEK making nonVMor needed when printf() deviceLogger outputUse a text to VECU’s the useto Donot directconsole. bar. lineinits status last its display will device name “Status”,Logger special with the embeddedthen VM’s the GUI youcreate If a file. text consolewindowa and/or output the can to it and make can You application. an from text diagnostic output to want you if useful very it find will but you devices, deviceThe Logger isnot part of included the standardas set of sample the Status object. How can it make use of it? it? of use make it can How object. Status the your OSEK But inCnotapplication C++, iswritten so does it not understand to theindicate outside whatworld ishappening.

the C and C++ source code that declares code C++source that Cand the provide prototype You must for this a function beseen that can byboth devices.h rather than C++ function. For this reason we need to add the file intended beintended to callable Cfrom code so your code becomes: The function a C/C++interface Write Thisis function. isdonewhat code inthe above. look likewould something this device’s the seehowto ‘Print’ but do codeaction. to You’ll the later, this use the Ccodecan VM APIcall Your vrtaSendAction(act.devID, &act); act.devActionData =pText_to_send; act.devActionLen =strlen(pText_to_send); act.devAction =1; act.devID =status_device_id; char *pText_to_send=“Boo”; vrtaAction act; status_printf(“Boo”) calls. The calls. Logger device has interruptthe protection that is

, with the followingcontents. status_printf Status.printf(“Boo”) 21 : is a simpleis a wrapper function thatis printf() vrtaMonitor vrtaSendAction style to calls a Logger device status_printf will do will the same. so that sothat you can to send string a to be a C area. area. 3.4

47 and and ticks the the ticks Speed function sets the both waits for the specified specified the for waits ClockSource returns false normally or or normally false returns tell the the tell to zero.will note You that vrtaIsIdle() so that the program does not simply start start not simply the does program so that into any C or C++ files that reference reference that files C++ or C any into PollCounter InitializeDevices() main.c vrtaIsAppFinished() #included . devices to preserve their data if the program resets. Note Note resets. program the if data their preserve to devices PersistThroughReset() . . is also to match set This has the on zero. effect an of raising (0) value maximum its past Incrementing ‘incremented’. is the to passed is value new the ‘incremented’ gets time. every zero on matches which – extern "C" { #endif ...); char* format, extern int status_printf(const #ifdef __cplusplus } #endif /* Interface between C and C++ */ C and C++ */ between /* Interface #ifdef __cplusplus /* Template code for 'main' in project: Tutorial2 */ /* Template code for 'main' in project: Tutorial2 */ #include "osekmain.h" #include OS_MAIN() { StartOS(OSDEFAULTAPPMODE); while(!vrtaIsAppFinished()) { vrtaIsIdle(5); true if the VECU should terminate. number milliseconds. During of this time processorassigned the a is to differentthread. Virtual interrupts can stilloccur a call duringto vrtaIsIdle() main() modify to need also We ofwill notice You use code the below. and the stop. Enter status_printf() Device Initialization Initialization Device The initialization code in our This file get must status_printf the for values max and min PollCompare the time each because tick, clock every interrupt PollCounter the time Each (0). value minimum the to reset to count the causes PollCounter PollCompare The calls to PersistentData thata reset isnot as same the killing the program and restarting it manually. is that a restart over thearequirement that is preserved direction We do have not satisfiedwewill by thislater. sorta bit – but that out

3.4.5 3.4.4 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.4

48 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 48 3.4.6

button on the onthe button If youdon’t If already have the custom buttons below, press the GUI. RTA-OSEK from the directly to run it easier it find probably you’ll but path, full inits the program run bytyping We can correctly. everything entered have go that check just back youand If not build besuccessful. the will Hopefully Button 1 dialogconfigure make theand following entries: embedded GUI. The GUI shows a few details about your VECU and gives VECU your TheGUIshows details youfew and a about GUI. embedded plus you screen new console run get your When an youempty will an VECU, in later. come handy will TRACE entries now use You can the Button 4 Button 3 Button 2 build ( Let’s check that was all entered correctly. Save your project performand a 1 Trial run Content: Content: Name: Name: Name: Name: Name: Name: Content: Content: Content: Content: Content: Content: } vrtaTerminate(); status_printf("Shutdownoccurred"); { OS_HOOK(void) ShutdownHook(StatusTypes) } status_printf("HelloWorld"); { OS_HOOK(void) StartupHook(void) } ShutdownOS(E_OK); } F9 ). "localhost.RTAOSEK-VRTA:$(destdir_app)$(name).rta" $(RTABase)\bin\rta-trace.exe RTA-&Trace $(DestDir_app)$(name) &Run $(EDITOR) $(OPENFILE) &Quick Edit $(RTABase)\bin\rta-trace-server.exe RTA-Trace &Server Custom Build

Run

button to launch to button

page. Select page. the

Custom Buttons Custom Tutorial2.exe tab in the the in tab . TheRTA- Configure

3.4

49

compare compare , which in turn turn in , which Brake and PollCounter Accelerate . It has therefore arranged these devices in a in devices these arranged therefore . It has that is connected to the VECU. the to connected is that device ‘belongs to’ the to’ ‘belongs device ClockSource vrtaMonitor PollCompare the abilitythe to pause,resume, reset terminate and it. should You see “Hello bar. status GUI’s the World” on willIfyou launch GUI, then you when in the pressan Ctrl+M embedded instance of bar. status the in World” “Hello has too it that Note the timeableTake devices in the some monitor. to explore You should be to out main the menu, checking clicking (and thework by features of most out and hand pane left navigation right-clicking)on elementsespecially in the looking atahead get to rightthe stuck, If on the tabs nip hand side. you monitor. the describes which 6 chapter that out worked has monitor the that is out pointing worth is that thing One the the ‘belongs to’ hierarchy. The same applies to the applies same The hierarchy. devices. devices. RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.4 22

Event times are recorded using the Windows API 50 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 50 3.4.7

checkbox you will also see the time that each event was raised in VECU the raised event each time see the was that you will also checkbox device the and display them inthe the right-hand side. This causes the monitor to hook all match events from To stop monitoring an event, drag the event onto the When you are ready, close the monitor VECU. and Summary sofar ‘Match’ Event of the In in place. fact, we can even see that We haven’t really written much code yet, but a large part of the framework is

GetTickCount() PollCompare Monitor devicefrom left hand the side over to the clock chain is working. Drag the working. is clockchain the . This typically has a resolution of around 15ms. If youtick tab. the Stop button. button. Show Times 22 .

3.4

51 button. button. zero in in zero Create Templates that activates task task activates that . with a tick rate of 100 real real a rate with 100 tick of with priority 1 and vector 1. 1. vector and 1 priority with 2. vector and 1 priority with . Poller with priority 2 and vector 3. 3. vector and 2 priority with 23 Autostart

to to . AlarmCounter looks like this: looks like isrBrake isrPoll isrAccel pane and press the the paneand press Poller , but do allow, but do create to RTA-OSEK remainingthe ements that implement the required functionality. functionality. the required that implement ements

isrPoll ke a long time a longbecause at toke time start the counter is already OS_MAIN() DirectionPoll main.c thus: Custom Build Custom so that so that

overwrite An OSEK Counter named An OSEK Counter named by driven ms time A Category 2 ISR named named ISR 2 Category A named ISR 2 Category A A task called named ISR 2 Category A In the Stimuli tab of the Planner section, set the alarm’s arrival pattern pattern arrival alarm’s set the section, Planner tab the of Stimuli the In 1 offset andstart tick counter to 1 In the Startup tab, set set tab, Startup In the An OSEK Alarm named DirectionPoll.

isrPoll.c main.c • • • • • • • • Tutorial2 */ #include "isrPoll.h" #include ISR(isrPoll) { Tick_AlarmCounter(); } OS_MAIN() { StartOS(OSDEFAULTAPPMODE); show_status(); while(!vrtaIsAppFinished()) { vrtaIsIdle(5); } ShutdownOS(E_OK); } /* Template code for 'isrPoll' in project:

Edit Tasks and ISRs and ISRs Tasks el OSEK the create We now Using the ‘Basic Data Entry’ screen in RTA-OSEK, add the following: following: the add RTA-OSEK, in screen Entry’ Data ‘Basic the Using Go back to the the to back Go files. We will now add some code into the templates. Edit DO NOT

, so the first offset you can get is 1. is get can you offset first the , so 3.4.8 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial If the as zero, leave ta start offset If you will alarm the

23 StartOS()

3.4

52 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 52 Edit Update Edit Edit extern intchange_direction(intamount); extern intright_pressed(void); extern intleft_pressed(void); extern intshow_status(void); } TerminateTask(); } change_direction(+1); if(right_pressed()){ } change_direction(-1); if(left_pressed()){ { TASK(DirectionPoll) #include #include "DirectionPoll.h" Tutorial2 */ /* Templatecodefor'DirectionPoll'inproject: } change_speed(+1); { ISR(isrAccel) #include #include "isrAccel.h" /* Templatecodefor'isrAccel'inproject:Tutorial2*/ } change_speed(-1); { ISR(isrBrake) #include #include "isrBrake.h" /* Templatecodefor'isrBrake'inproject:Tutorial2*/ extern intchange_speed(intamount); isrBrake.c DirectionPoll.c isrAccel.c devices.h thus: thus: thus: thus: to add the C / C++ interface function prototypes: thus: 3.4

53 . They are clearly quite . are clearly quite They devices.cpp Direction.SetValue(newvalue); Direction.SetValue(newvalue); show_status(); } //------int change_speed(int amount) { int newvalue = Speed.Value() + amount; if ((newvalue >=0) && (newvalue <=100)) { Speed.SetValue(newvalue); show_status(); } } Speed.Value(), Speed.Value(), Direction.Value()); } //------int change_direction(int amount) { + amount; int newvalue = Direction.Value() 0) { while (newvalue < 360; newvalue += } 359) { while (newvalue > 360; newvalue -= } PersistentData.SetValue(DIR_DATA,newvalue); int left_pressed(void) int left_pressed(void) { Left.Value(); return } //------int right_pressed(void) { Right.Value(); return } //------int show_status(void) { %d, Direction %d", Status.printf("Speed //------//------We now add the C / C++ functions to to functions / C++ C the add We now devices. the to wrappers simple

RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.4

54 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 54 3.4.9

that we using.Add that code the are belowinto need Thisisbecause inputs. enable(or we unmask) the to 3interruptsthe respond to to much appears nothing that find now,you’ll this run to youtry If number in number turn. sends Unmaskthe action to VM’sthe ICUdevice, in passing each interrupt Then add this to the end of InitializeDevices() To see threada at work add the following declaration just before excellent choice for interfacing to real hardware. evendevices interrupts raise from and protect them from having Youcan without thread APIcalls a tomake in. from Windows within native of threads Windows built protection threads small amount are with a These OSEKthread). thread independently (the run of your that application RTA-OSEK forPC Threads inan dothis will We being pushed. after zero to back going to ‘spring’add a to theAccelerate nootherFor reason than show to you some interesting stuff, nowwe are Nearly there. Thread. extern voidAsyncThread(void);//Forward declaration vrtaSendAction(ICU_DEVICE_ID,&action); action.devEmbeddedData.uVal =POLL_ISR; vrtaSendAction(ICU_DEVICE_ID,&action); action.devEmbeddedData.uVal =BRAKE_ISR; vrtaSendAction(ICU_DEVICE_ID,&action); action.devEmbeddedData.uVal =ACCEL_ISR; action.devActionData =NULL; sizeof(action.devEmbeddedData.uVal); action.devActionLen = action.devAction =ICU_ACTION_ID_Unmask; action.devID =ICU_DEVICE_ID; vrtaAction action; vrtaSpawnThread(AsyncThread); allows you to create any number of threads of execution threads of number any of create youto allows RTA-OSEK forPC : InitializeDevices() interrupts. You can access the VECU’s the access can You interrupts. within thread,a which makes them an and Brakeswitchesthat so and theyflip InitializeDevices() : RTA-OSEK for PC . It

3.4

55

and and Brake . The basic . The basic and and AccelDetect devices.cpp to implement the thread thread the implement to Accelerate e Match event fires for one of of one for fires event e Match regularly within a thread so that that so a thread within regularly itch has been pressed. We then reset reset then We pressed. been has itch devices.cpp thread is usuallythis: something like to yield control to other threads if you have no no have you if threads other to control yield to vrtaIsAppFinished() compare devices. Whenever th Whenever devices. compare RTA-OSEK for PC for RTA-OSEK vrtaIsIdle() act.devAction = 1; act.devActionLen = sizeof(unsigned); act.devActionData = NULL; act.devID = Brake.GetID(); act.devEmbeddedData.uVal = 0; vrtaSendAction(act.devID, &act); } } //------void AsyncThread(void) { // Create a listener and associate its callback vrtaEventListener tListener = // Has ‘Accelerate’ become 1? // Has ‘Accelerate’ if ( AccelDetect.GetID()) && (event->devID == == 1)) { (event->devEmbeddedData.uVal // Set directly Accelerate.SetValue(0); } // Has ‘Brake’ become 1? if ((event->devID == BrakeDetect.GetID()) && (event->devEmbeddedData.uVal == 1)){ // Set via an action vrtaAction act; static vrtaErrType ListenCallback( static vrtaErrType ListenCallback( const void *instance, const vrtaEvent *event) { { (!vrtaIsAppFinished()) { while vrtaIsIdle(100); } } // Sleep 100ms void AsyncThread(void) void AsyncThread(void) The code for the thread can be added at the end of of end at the added be can thread the for code The an of shape You should check the VECU can perform an orderly tidy up when asked to terminate. You You terminate. to asked when up tidy orderly an perform can VECU the should use do. to work in the changes weIn ourto hook event thread, want that Note hooking the tothe value zero. switch below. is shown code and hook BrakeDetect sw associated the we that these, know theraisedwillcompare are before notPosition work event events because compare the hook, event the in switch the reset you If informed. are devices value. zero the see ever devices only to add to need we that The code RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.4

56 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 56 Accelerate and Brake devices. the reset used are to methods different purposes, illustration for that Notice } BrakeDetect.GetID(),1,false); tListener, vrtaHookEvent( AccelDetect.GetID(),1,false); tListener, vrtaHookEvent( //Tidyuphooksonexitfromthread } vrtaIsIdle(100); while(!vrtaIsAppFinished()){ //Nothingelsetodowhileappisrunning BrakeDetect.GetID(),1,true); tListener, vrtaHookEvent( //Hookevent1ofBrakeDetectintolistener AccelDetect.GetID(),1,true); tListener, vrtaHookEvent( //Hookevent1ofAccelDetectintolistener vrtaEventRegister(ListenCallback,0); 3.4

57 . vrtaIO and the menu in menu vrtaFlash Application to to device that inherits from from inherits that device ). ). F9 , there is no direct for support nonvolatile PersistentData device, though thatwill obviously make the vrtaFlash device and notice the speed decrease. speed decrease. the and notice device to feed some inputs and view the output, so start start so output, and view the inputs some feed to device and drag the Position event to the right right the to event Position the and drag device Right device and actionsend its Position value ‘1’. The . You will see the position value change to one and then will. seevalue position You the and then to change one Brake with these lines. lines. these with Left RTA-OSEK for PC for RTA-OSEK OK ), the VECU console and console), GUI will VECU flash return. the off The and then Accelerate vrtaMonitor // Add some persistence to vrtaIO to simulate nvram. // Add some persistence to vrtaIO to simulate nvram. // In this version we store the data in the file // "VECU.flash". The file gets read in when the device // starts, and written when the device is stopped. #include class vrtaFlash : public vrtaIO { protected: void Starting(void) { vrtaIO::Starting(); FILE *f = fopen("VECU.flash","rb"); if (f) { Non-volatile data Non-volatile data Trial run 2

Becauseare you getting good at this, you will nowa have (nearly) fully workingso VECU, let’s it. run We’ll need the Now expand it up (Ctrl+M)it up GUI. from embedded the the Expand hand side. Double click the Position action (not event) and the enter ‘1’ as the data value. Press zero in the monitor window. The status bar will show that speed the has increased. Double-click theon Position action a few times and you will see the further. up speed go the for same the Do job is done. The code to below. do this for theis shown Just replace current declaration PersistentData We have seen that the speed and direction values persist over a VECU reset. reset. a VECU over persist values and direction speed the that seen We have runs different completely between data keep to way a have yet we don’t But VECU. the of ECU. a real in memory Flash like looks that something have to like really We’d In this release of memory so we will have to make our own version. own to make our will have we memory so We will do this by creating a Save your project and perform a build ( and perform project your Save directionWestbackwilltoyou until to change go East zero. it to The the applies same We can then change the type of type of the then change We can direction go West to East. East. to direction West go the (for using thereset example VECU If you now vrtaMonitor andspeed directionwill have persistedacrossthe reset. 3.4.11 3.4.10 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.4

58 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 58 name, to avoid conflicts where two applications try to access the same file. hard-coded file from move a to away want youmight application real-life In a it lastdirection pointingwas inwhen it restarts. the remember will it VECUthat your rebuild you if that find now You will vrtaFlash PersistentData("PersistentData",DATA_SIZE); }; :vrtaIO(name,elements){}; vrtaFlash(constvrtaTextPtrname,unsignedelements) //Constructor public: } vrtaIO::Stopping(); fclose(f); f); GetPersistentDataSize(), 1, GetPersistentData(), fwrite( FILE*f=fopen("VECU.flash","wb"); voidStopping(void){ } } fclose(f); } GetPersistentDataSize()); buffer, GetPersistentData(), memcpy( ){ fread(buffer,1,GetPersistentDataSize(),f) if(GetPersistentDataSize()== charbuffer[100]; 3.4

59

. Set the the . Set

3 RTA-TRACE Advanced . enable traceenable link / pane to set the trace type to to type trace the set to pane Free running . Configuration values to to values second. So the code below returns time in the units defined as the stopwatch rate in the RTA-OSEK GUI. */ return vrtaReadHPTime( (1000000000 / OS_NS_PER_CYCLE) / OS_CYCLES_PER_SWTICK ); } #ifdef OSTRACE_ENABLED //------OS_NONREENTRANT(StopwatchTickType) osTraceStopwatch(void) //------OS_NONREENTRANT(StopwatchTickType) GetStopwatch(void) { /* vrtaReadHPTime(x) returns the current time in 'xticks', where there are ‘x' xticks per RTA-TRACE

tab GUI. the RTA-OSEK in Use the autostart

rebuild. to try Now In functions.andabout missing stopwatch warnings overrun You should get we police timingso or information, collect does not build status ‘s’, RTA-OSEK code. time-related any provide to needed yet not have things which at the about time know to need does course RTA-TRACE of itmustto Add the thewe code below help ithappen, give needs. so devices.cpp If you have RTA-TRACEa you can installed, get detailed view of the internal VECU. your of operation Close any ofinstances the VECU and theselect and monitors, 3.4.12 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.4

60 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 60 change the clockstosomething moresensible. lot better than that, so select the RTA-OSEK menu counter high-performance now Usingthe can means do that we stopwatch. a You may remember that the project was set up initially with a 1kHz

//------} status_printf("Overrunoccurred"); OS_HOOK(void) OverrunHook(void){ //------#endif } /*Notreallyrelevantforthistarget*/ return(StopwatchTickType)1U; { GetStopwatchUncertainty(void) OS_NONREENTRANT(StopwatchTickType) //------#if defined(OS_ET_MEASURE) #endif } returnGetStopwatch(); */ asthesystemstopwatch Ensurethatthetracestopwatchissame /* {

Target /TimingTarget data

and 3.4

61 button. RTA-TRACE will button. start readthe RTA-TRACE up, so that it now looks like this: this: like looks now it that so ). F9 main.c main.c RTA-TRACE } vrtaIsIdle(5); vrtaIsIdle(5); } ShutdownOS(E_OK); } OS_HOOK(void) StartupHook(void) { World"); status_printf("Hello } s) OS_HOOK(void) ShutdownHook(StatusType { occurred"); status_printf("Shutdown vrtaTerminate(); #include "osekmain.h" #include "osekmain.h" #include OS_MAIN() { StartOS(OSDEFAULTAPPMODE); show_status(); { while(!vrtaIsAppFinished()) #ifdef OSTRACE_ENABLED CheckTraceOutput(); UploadTraceData(); #endif /* Template code for 'main' in project: Tutorial2 */ for 'main' in project: /* Template code VECU’s configuration information and then launch it automatically for you. you. for automatically it launch then and information configuration VECU’s service! What Finally we must add some code in the idle task to pump the trace data out of of out data trace the pump to task idle the in code some add must we Finally the application. Edit ( rebuildNow the VECU and up earlier, you set button the custom from Server Start the RTA-TRACE the then press RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

3.4 25 24

Yes indeed, an ‘exercise for the reader’. reader’. for the an ‘exercise Yesindeed, Depending upon the speed of your machine, this may occur ina different position. 62 Tutorial RTA-OSEK for RTA-OSEK PCUser Guide Tutorial 62 Your mileage will vary, but get lookinglikewe trace a vary, the oneYour will mileage below. Hmm… that’s interesting. The trace is showing sort thissort one out yourself tools the knowledge and You younow. over that youneedto to all have It’s fourth instancefourth of

isrPoll 25 . 24 . We expecting . that! weren’t E_OS_LIMIT during the the during

3.4

63 as shown below. It just peeks at the the at peeks It just below. asshown AsyncThread } vrtaHookEvent( tListener, AccelDetect.GetID(), 1, false); vrtaHookEvent( tListener, BrakeDetect.GetID(), 1, false); } } } Right.SetValue(0); } } else { Accelerate.SetValue(1); } == 1) { if (Right.GetValue() Brake.SetValue(1); < 0) { if (GetAsyncKeyState(VK_UP) } < 0) { if (GetAsyncKeyState(VK_DOWN) vrtaIsIdle(100); } } { while (!vrtaIsAppFinished()) Left.SetValue(1); < 0) { if (GetAsyncKeyState(VK_LEFT) } Left.SetValue(0); } if (Left.GetValue() == 0) { } else { Right.SetValue(1); } if (Left.GetValue() == 1) { if (GetAsyncKeyState(VK_RIGHT) < 0) { if (Right.GetValue() == 0) { void AsyncThread(void) void AsyncThread(void) { tListener = vrtaEventListener 0); vrtaEventRegister(ListenCallback, vrtaHookEvent( 1, true); tListener, AccelDetect.GetID(), vrtaHookEvent( 1, true); tListener, BrakeDetect.GetID(), //------//------Addendum

state of the arrow keys on your keyboard and makes calls to your switches. switches. your to calls makes and keyboard your on keys arrow the of state Just to prove that you can link to real hardware, you might like to change the the change to like might you hardware, real to link can you that prove to Just the of implementation 3.4.13 RTA-OSEK for PC User Guide User PC RTA-OSEKfor Tutorial

4.1

64 ECUs and Virtual Devices RTA-OSEK for RTA-OSEK PC User Guide ECUsand Virtual Devices 64 4 4.1

• • • •

ECUs and Devices Virtual Registering the device device the Registering xlie ndti nscin93 “Value=%u,%u\nValues=%e.g. explained indetail in section 9.3. actionnames andthe valuesdatathe are formatdescriptions. Theseare devicethat the supportsthe anddata format for each action. The tags arethe list ofactions “Value=%u,%u(%u)\nValues=%a\n”e.g. explained indetail insection 9.3. event names theand the values formatare data descriptions. These are that the device supports and the data format for each event. The tags theare list ofevents “Type=Thruster\nVersion=1.2.3\n”e.g. programs. Typecontain Thisinfo Version tags. and should string the 2>…”. minimum Asa value “=\n=< info “LeftWindowSwitch”, “EjectorSeatTrigger”e.g. the device. Each device in VECUa must have differenta name. name When registering a device, you supply the following information: class that derives from vrtaStart() vrtaRegisterVirtualDevice() the bycalling device your exists the VMthat tell to You have devices. own of issues your the thatsome writing youshouldunderstand when that they implementedare asC devicesVirtual can be written from scratch usingC code,but we recommend structure. information passed function gets callback through The ‘state’ a vrtaAction through gets passed function a callback information The ‘action’ (action) or query its status (event). command a sendit becalledto name that can andprovides functions has a At its most basic level, a virtual device is simply a software component that PC howof examplesMany write to suchclasses areprovided with class that is defined in : Thisis : devicea string containing the information inthe about form , most notably, in : This is the name that external monitor programs will see when accessing when accessing see will programs monitor external that name the is This : : This string is a in the same format asabove that lists the events : This string is a in the sameformat as above that lists the actions structure. is called. (It is done automatically for you if you are using a you are if you for doneautomatically is (It called. is vrtaSampleDevices.h/.cpp vrtaDevice.h vrtaDevice a\nGetValue=%u\nGetValues\n” ++ classes that derive from the .) API. This must bedonebefore must This API. . rmation is used by external monitor . This chapter covers vrtaDevice RTA-OSEK for vrtaEvent

4.2

65 , the , the , the , the method. The The method. vrtaDevice vrtaDevice method. The basic basic The method. OnAction AsyncGetState AsyncGetState gister gets called whengister gets code in the thread; therefore the callback must take take must callback the therefore thread; thread; therefore the callback must take take must callback the therefore thread; method is shown below. below. shown method is . See the section below on how to handle to handle below on how the section . See any any , or when an external monitor sends data via via data sends monitor an external when , or , or when an external monitor queries the the queries monitor an external when , or method is shown below. shown method is :areference is This theto C function that called will be : Thisis a reference C function to the thatwill be called AsyncGetState vrtaGetState() OnAction vrtaSendAction() RaiseEvent(...); break; ErrorAction(action); return } default: return OKAction(action); } //------//------vrtaAction *action) vrtaErrType mydev::OnAction(const //------{ { switch (action->devAction) 1: case to action 1 */ /* respond

event callback is translated event callback into ais translated call to your basic formthe of care of any reentrancy issues. issues. reentrancy any of care from inherits that class a C++ as written is device your If VECU calls interface. diagnostic the via device from be invoked The callback can form of the the of form that you re callback function The state The action callback function that you register gets called when code in the register that in the called gets when you function The action callback code VECU calls action callback is translateda call intoyourto care of any reentrancy issues. issues. reentrancy any of care Often you will raise an event as a result of receiving an action. from inherits that class a C++ as written is device your If the diagnostic interface. interface. the diagnostic from be invoked The callback can action requests. function state callback section to below the on how toa See is sent the device. when query status queries. handle status action callback function callback action the device to actionan is sent when Handling state queries Handling actions

• •

4.3 4.2 RTA-OSEKGuidefor User PC ECUs and Virtual Devices

4.4

66 ECUs and Virtual Devices RTA-OSEK for RTA-OSEK PC User Guide ECUsand Virtual Devices 66 4.4

Raising events events Raising e.g. classes that inherit from it. vrtaDevice The events. its raises that device the within code only is it normally raise deviceAny codecan a event directly via by either tracked ‘hooking’ eventsor pollingthem. the RaiseEvent By convention, } RaiseEvent(event); ReadState(&event,1); vrtaEvent event; m_Val=val; { //------void mydev::NewValue(unsignedval) //------} return OKState(event); /*Update*event*/ default: } return case 1: ErrorState(event); break; switch(event->devEvent){ { //------vrtaErrType mydev::AsyncGetState(vrtaEvent*event) //------class provides a event sothat the inquestion the devicecan for state of be a AsyncGetState RaiseEvent() returns the value of the most recent thatmethod beusedcan by vrtaRaiseEvent() , but but , 4.5

67 . . to the ICU ICU the to ’s _Parent is is ’s _Parent ClockSource vrtaClock method that can be be can that method about this relationship about this relationship PollCompare which returns the device ID of of ID device the returns which 26 ’s _Parent is set to to is set _Parent ’s ICU_ACTION_ID_Raise ICU_ACTION_ID_Raise vrtaMonitor RaiseInterrupt() device that ‘belongs’ to a to ‘belongs’ that device PollCounter and and vrtaCounter class provides a provides class

PollCounter vrtaDevice RaiseInterrupt(m_Vector); } } } RaiseEvent(event); } //------val) void mydev::NewValue(unsigned //------{ m_Val = val; if (val == m_Match) { event; vrtaEvent ReadState(&event,1); if (m_Vector) { //------//------vector) void RaiseInterrupt(unsigned { action; vrtaAction = ICU_DEVICE_ID; action.devID = ICU_ACTION_ID_Raise; action.devAction = action.devActionLen action.devEmbeddedData.uVal = vector; action.devActionData = NULL; sizeof(action.devEmbeddedData.uVal); action); SendAction(ICU_DEVICE_ID, set to set to by implementing an called “_Parent”by implementing event the device that it belongs to. The program can then represent this relationship relationship this represent then can program The to. belongs it that device the visuallyandwill normally fromhide the view. event _Parent feature This is where below – in the screenshot demonstrated You can tell external programs such as You can such tell programs external used by classes that inherit from it. it. from inherit that classes used by e.g. another to’ ‘belongs somehow athat create device you want to Sometimes device. the is An example The Interrupts get raised by sending action sending by raised Interrupts get device using code like this: code device using Parent / Child relationships Raising interrupts

4.6 4.5 RTA-OSEKGuidefor User PC ECUs and Virtual Devices By convention this is the highest numbered event in the device. device. in the event numbered highest the is this convention By

26

4.6

68 ECUs and Virtual Devices RTA-OSEK for RTA-OSEK PC User Guide ECUsand Virtual Devices 68

4.7

69 Thread Thread Virtual device Windows part . Virtual device device . Virtual methodbe can that main() Virtual OSEK device part thread to perform operations operations to perform thread OSEK API Function SpawnThread() OSEK ISR ISR OSEK VM Internal thread Linkage DLL RTA-OSEK for PC for RTA-OSEK StartOS() RTA-OSEK kernel kernel RTA-OSEK Diagnostic/Event Interface OSEK Task Task OSEK classprovides the . The root thread is the thread created by Windows when the the when Windows by created thread the is thread root . The Root thread Application thread OS_MAIN() vrtaDevice User Application Virtual Machine (.dll) (.dll) Machine Virtual A virtual device can spawn an spawn can device virtual A main the applicationwith from thread. asynchronously Such threads can, cause can They methods. and data device the access interlocks, appropriate raised. be to interrupts and events The used by classes that inherit from it. it. from inherit that classes used by The diagram below illustratesare used threads a within how The VECU. application theapplicationruns VECU Windows thread that thread is the that calls thread is the tasks. This and RTA-OSEK code, including ISRs OS_MAIN() executes that thread the This is VECU was loaded. private contain also application the may thread but called by be drivers may threads. Threads

4.7 RTA-OSEKGuidefor User PC ECUs and Virtual Devices

4.7

70 vrtaServer RTA-OSEK for RTA-OSEK PCUser Guide vrtaServer 70 5

vrtaServer the remotePC. accessing a remote PC, so the directory structure that you see reflects that on VECUs load, they register with The figurebelow shows a a bank of test PCs. ECUs, so server perform its the youcan control ofremoteand monitoring and isthat note to point An important and attach to a VECUvia its diagnostic interface. such as A VECUinforms a Windows service. y locating of loading the and coordinating vrtaServer.exe access toaccess on files hostthe PC. Inthe dialog load below, necessarybecause the monitorbe running may remotePCa on without Monitor programs use Monitor also interfaces (dotted lines). vrtaMonitor machine and the TCP port numbers of their diagnostic interfaces (solid line). then queries Control PC

Virtual ECU vrtaMonitor vrtaServer Virtual ECU then communicates with the VECUs via their diagnostic vrtaServer Interface Diagnostic is a is program that small a runs unobtrusively on your PC can then can ask Interface Diagnostic vrtaMonitor tofindout what VECUs areloaded on thelocal vrtaServer when it starts or terminates. External programs vrtaServer vrtaMonitor vrtaMonitor vrtaServer

our Virtual ECUs. It normally normally It runs as ECUs. Virtual our attached to two VECUs. When the the When VECUs. two to attached to locate and load VECUs. This is This VECUs. load and locate to (dashed lines). Interface Control numbers back to monitors numbers backtomonitors port passes diagnosticinterface and Server loadsvirtualECU can be on a different PCto different beon a can what VECUs what are loaded, vrtaMonitor vrtaServer vrtaMonitor is

5.1

71

. Normally vrtaServer vrtaServer vrtaServer . Then run ‘ . Then run 27 has to generate a different alias. generatealias. a has to different as a Windows application.system-tray vrtaServer . vrtaServer ’ to stop the service the stop ’ to ’. will You see a tabbed dialog-style window appear along with keeps a count of the ECUs and monitors that know about the know that monitors and of the ECUs count keeps a normallyasa runs under Windows service the ‘SYSTEM’ vrtaServer

would start it again. again. it start would vrtaServer -stop Close any VECUs or monitors on your PC then run the command command the run then PC your on monitors or VECUs any Close ‘ this is just the file name of the VECU with the path information stripped off. off. stripped information path the with VECU the of name file the just is this program. monitor a in shown gets that name the is alias ‘user-friendly’ This Ifsame the VECU is twice, loaded anorwith if ECU the same a but name in loaded, is directory different Typically it will do this by adding _2, _3 etc. to the default alias. vrtaServer using it. are no programs aliaswhen differentanaliases. ‘frees’ It -standalone tray. system your in icon a new This dialog will give you informationabout the and VECUs monitors are that to connected vrtaServer it If element. user-visible any normally have not does therefore account. It Viewer. Event Windows the with problems, logs them encounters it You can alternatively run Each VECU that loads is assigned a (orname alias) by Server status information information status Server Multiple instances a of VECU instances Multiple

5.2 5.1 RTA-OSEK for PC User Guide PC User RTA-OSEKfor vrtaServer ’vrtaServer –start’

27

5.2

72 vrtaServer RTA-OSEK for RTA-OSEK PCUser Guide vrtaServer 72 from the system trayicon quit to theserver (or that Note closing this dialog window does not cause just minimizes back to th e system tray. Select the

’vrtaServer –stop’ Close Server vrtaServer menuitem to quit – it

). 5.3

73

, 26000

. 28 to listen on a non-standard TCP port port TCP non-standard a on to listen vrtaServer (and RTA-TRACE) are (and RTA-TRACE) allows remote monitor programs to to programs monitor remote allows probably behavior the thatwant. you vrtaServer vrtaServer vrtaServer . does not allow a monitor program to copy any programs or or any programs copy to program monitor a allow not does dialog. load the via files modify to user a remote allow not does

17185 and The default TCP ports used by by used ports TCP The default However if you are worried about malicious abuse of this feature, you should ofshould about thisabuse areHowever maliciousfeature, if you worried you to access external block to firewall your configure vrtaServer PC. host the to data vrtaServer as we seen, have However PC. host its launch on VECUs is this environment, test a controlled In 31765 Security issues issues Security

5.3 RTA-OSEK for PC User Guide PC User RTA-OSEKfor vrtaServer You could alternatively use the –p command-line option to force

28

number. A casual visitor would find it difficult to guess what port to connect to. to. connect to port what to guess difficult it find would visitor casual A number. 5.3

74 vrtaMonitor RTA-OSEK for RTA-OSEK PCUser Guide vrtaMonitor 74 6

vrtaMonitor element and selecting element and example,For youcan connect different PC to the a by right-clicking same thing through the application’s You can interact with within each host. vrtaMonitor ECUs on local and remote PCs. The program • • • • •

Pressing Enter on an el on Double-clicking elementan inthe view tree Shortcut keys (e.g. Ctrl Context menus (right-click on menusContext (right-click menu main The application’s vrtaMonitor.exe can connect to multiple PCs (Hosts), and multiple VECUs multiple PCs(Hosts), and connect to multiple can vrtaMonitor Add Host… ement in the tree view +L to load an ECU)load an +L to from the context menu. You can do the can beused to control virtual can inspect and File in a number or ways including: including: ways number or in a an element in the tree view) menu. menu. Hosts

6.1

75

Params… . button. button. double-clicks. double-clicks. Send Action menu or press Ctrl+Alt+S). from the context menu. the context from asks you to enter it the first time time first the it enter to you asks lue on subsequent on lue Device Send ). Ifaction the requires input data (e.g Device / CurrentDevice / Action Send vrtaMonitor ) to a virtual device in the following ways. ways. following the in device a ) to virtual tab on the right-hand side. You can enter data tab can data the right-hand side. enter You on ) then Detail Double-click on an action in theDouble-click tree action on anaction does not the view. If (e.g. immediately sent is action the then any data require ApplicationManager /Pause ICU /Raise round, then re-sends the same va the round, re-sends then (If you want to change the data that gets sent, select the the select sent, gets that data the change to want you (If option from the context or main or context option the from Go to the the to Go it the and by pressing send needed) (where Press Ctrl+S when an action is selected. This is the same asa double- same is the action This is selected. an when Ctrl+SPress click above. Right-click and the action select Select the main menu item item menu main the Select

• • • • • You can send an action ( anaction send You can Actions

6.1 RTA-OSEK for PC User Guide PC User RTA-OSEKfor vrtaMonitor

6.2 29

A second Ctrl+Awill turn auto-refresh off again. 76 vrtaMonitor RTA-OSEK for RTA-OSEK PCUser Guide vrtaMonitor 76 6.2

6.2.1 Events

You do bythis selecting views. detail and everyautomatically second or so and update the values displayed inthe tree ways. ways. Query You can queryevent ( thestatecan ofany You It is also possibleIt is also to ask

• • • • •

(where needed) and query the event by pressing the Go to the Select the main menu Right-click the action and select action the and Right-click above. click double- Ctrl+R eventPress same when isselected.a Thisisthe as an option from theoption context or main (If you want to change the data that gets sent, select the round, then re-sendsround, the vasame /DeviceInfo Pending / ICU dataany then the current of value the If event require view. doesnot event tree inthe onan Double-click

) then Detail ). If the event requires input data (e.g Auto Refresh vrtaMonitor tab on You enter side. right-hand the data can tab vrtaMonitor item Device / Current Event / Read Event/ item Device Current / (Ctrl+A) for the device Read to query all of the events of device a Device lue on subsequent asks you to enter it the first time ) in a virtual device in the following following inthe in device ) a virtual the event is readthe event from thecontext menu. menu or press Ctrl+Alt+R). Ctrl+Alt+R). press or menu double-clicks. Read 29 immediately (e.g. DeviceManager . button. . Params…

6.2

77

button. button. Stop an event rather than than rather event an monitor whenever a monitored event is is event a monitored whenever

vrtaMonitor

. All notifications are displayed in the monitorthe tab: in . displayed All notificationsare 30 You cana foran set up monitor using the event normalapplication menu or from the event way to just drag is simplest the but mechanisms, menu context pages. tab side right-hand the of one onto view tree the all across:abe of this causes itsYou can toalso device complete events drag monitored. the to device) its (or it drag just an event, monitoring stop To Monitor Monitor You can alternatively that specify you want to Pressing the button on its own cancels all event monitors. all monitors. event cancels own its button on the Pressing ‘raised’ just querying it. In this case, VECU notifies the

6.2.2 RTA-OSEK for PC User Guide PC User RTA-OSEKfor vrtaMonitor Events are typically raised when some value in the virtual device changes. 30

6.2

78 vrtaMonitor RTA-OSEK for RTA-OSEK PCUser Guide vrtaMonitor 78 6.2.3

Scripting usingvrtaMonitor VECU The options) beforecommand-line quitting. The –t1 option tells The –log option causes logging information to be written to the file log.txt. if one options of the events following occurs. The –koptiontells The directory Enter the text below into Scripting options can be options can on Scripting directly entered the The basic op scripting lineoptions.) command of list complete a for (Seesection 15.3 VECUs. for scripting capability of form Tutorial2.exe and that you run ‘ useful examples presentedare here. They assume that youhave built The command-line options documented indetailare but 15, inchapter a few character. Command-files can benested up to 5 times. as commenta if it starts with semi-colon,a forward-slash, space or tab treated is Aline line. oneoption per with file simple text a is file A command vrtaMonitor @commands.txt the form using command-file use a to easier it find probably will you but line, Tutorial2.exe -t1 -log=log.txt -k • • • • • • vrtaMonitor Tutorial2.exe Cannot auto-load specified a Virtual ECU. Cannot attach specified via toan alias Failure to connect to Failed to send an action or receive event. or an action send to an Failed Closed as aresultof load VECU. to Failed Closed as aresultof a

Event Tutorial2.exe Waiting for a termination condition condition atermination for Waiting Pausingforset a amounttime of event an Monitoring device a to action Sending an VECU existing to an Attaching VECU Loading a c:\Play\Tutorial2\MinGW\app command-line options can be limited support can options usedto a command-line vrtaMonitor vrtaMonitor vrtaMonitor erations include: parameter tells (without showing its embedded GUI). embedded its GUI). showing (without commands.txt –f vrtaServer –t . timeout. vrtaMonitor @commands.txt . to run to for1 second processing (after its to stop further stop scriptto processing the of . vrtaMonitor . –alias . vrtaMonitor . to load and run load the to command- ’ from the 6.2

79 , installer Tutorial2.exe RTA-OSEK for PC is already isspecifyingloaded by its naming the VECU then the VECU VECU the then VECU the naming for 5000ms then terminates. for then file 5000ms The before PollCompare.Match supports much more comprehensive scripting features by by features scripting comprehensive more much supports contains the results from the monitor window. window. monitor the from results the contains : -k -log=log.txt -t10 Tutorial2.exe -mon=PollCompare.Match -wait=5000 -send=ApplicationManager.Terminate -quit -alias=Tutorial2.exe -k -log=log.txt -alias=Tutorial2.exe -send=ApplicationManager.Terminate -k -log=log.txt -t1 -d -g -log=log.txt -k will load (and its devices become accessible), but the application thread will started.not be will GUI: showembedded VECU the thenSimilarly option its –g the you if use log.txt By contrast, if you use the option the –d By contrast, if you use Plug-Ins vrtaMonitor write scripts allow to to you are intended These using plug-in scripting DLLs. in high-level languages aand such Java Ruby. The does not currently provide any scripting DLLs. They may become available at a a availableat may become They DLLs. any scripting provide does not currently add-on. a as purchased date later You can send anaction to a device. The commands below will attach to an it. terminate then and VECU existing runs below example monitor The also events. You can that a VECU to monitor the attach can You alias event monitors

6.2.4 RTA-OSEK for PC User Guide PC User RTA-OSEKfor vrtaMonitor

7.1 you. OILfile is unfortunately necessary. If this worriesyou, contact our support department and wemay able be to perform this wor 31

At the time ofwriting, there isno automa 80 Migration Guide RTA-OSEK for RTA-OSEK PCUser Guide Migration Guide 80 7.1 7

7.1.2 7.1.1 Migration Guide OIL file

but will probably have different vectors and available priorities. priorities. and available havevectors different probably but will in target your controller The interrupt interrupt source. allows you to decide in software how to map your (virtual) hardware to an 32. 32 number 1to attached to oneof It a vector each with priorities and RTA-OSEK forPC Interrupts can use the GUIif you need to select a non-default variant. You file. OIL load whenthe you next variant default the target’s to beset will line( variant delete the You can To change to a different target modify the target to something like this:, in intheOIL likethis: file lines specified variant are The target and cannot change the target type itself. you GUI, RTA-OSEK the within variant target a modify youcan Although variant Target and the and scripts build by isdescribed VECUapplication Your This chapter covers the issues migration that you should expect to face. to load the compiled code onto your hardware. some way needcompatiblecompiler and a hardware. Youalso target your on run will that RTA-OSEK of version obtained a you have that assume will We neednow to migrate the applicationtoyour realhardware. Assume that you have developed application an using elements that you might have to modify in your OIL file are described next an to Migrating need. might documentationits to discover how encodeto the extra information that you to non migrating a youare If myproject.oil like something called syntax encoded is OIL inOSEK’s and information project //RTAOILCFGOS_TARGET"PIC18/IAR16task"; //RTAOILCFGTYPE="MinGW"; //RTAOILCFGOS_TARGET"VirtualOsek";

. tic way toswitch todifferent targets within simulates interruptan controller with 32 interrupt sources, RTA-OSEK RTA-OSEK based implementation isrelatively easy. The RTA-OSEK project file. The file. project contains project file the //RTAOILCFG TYPE hardware will have similar capabilities, capabilities, similar have will hardware system, then you will have to refer to refer to have will then you system, a combination of the C source code, Csource combination the of a the RTA-OSEK GUI, sosome editing of t RTA-OSEK for PC RTA-OSEK for ) because the variant and 31 . k for k for he 7.2

81 GUI they will appear GUI theywill RTA-OSEK line, and the vector goes in the the line, goes in andthe vector . finitions in your OIL file, The priority priority The file, OIL your in finitions . 33 32 processesallow that to you packmultiple line. RTA-OSEK ECUs can use up to 1024 tasks (1025 if you count the idle the count if(1025 you tasks to 1024 up use can ECUs //RTAOILCFG PRIORITY //RTAOILCFG

//------int left_pressed(void) { return Left.Value(); } ISR isr1 { = 2; CATEGORY PRIORITY = 22; //RTAOILCFG ADDRESS = 0x11; //RTAOILCFG //RTAOILCFG OS_EXECUTION_BUDGET OS_UNDEFINED; //RTAOILCFG OS_BEHAVIOUR OS_SIMPLE; }; //RTAOILCFG OS_USES_FP FALSE; //RTAOILCFG OS_STACK {OS_UNDEFINED }; as ‘undefined’ and you can set the priority and vector in the normal way. the normal in and vector the priority set can and you ‘undefined’ as Therefore you will need to assign new target-based vectorand numbers prioritiesapplicationfor your each ISR in This has to be done by editing the editing ISR de be done by This has to ADDRESS //RTAOILCFG goes in the ISR’s You simply provide different implementations for each of these interface interface these of each for implementations different provide simply You hardware. target your onto map they that functions so Number of tasks devices. virtual via simulated is hardware your of all not if most VECU, the In application. real your in replaced to be need These obviously By afortuitous coincidence, the inability of C code to interact directly with the C++ code hasalreadymeant that will you have written/ some C++ C below one the as such functions interface RTA-OSEK for RTA-OSEK for PC many this support that RTA-OSEK of ports few very are there However task). ports RTA-OSEK Most great. too is just run-time overhead the because tasks asmall,willthat Although find tasks.support you be thisseems to 32 16 or use make you if particularly – applications most in need you than more is this as such of features ISRs. and tasks into elements executable-code uses, currently VECU your than tasks fewer handle can port RTA-OSEK the If re-engineeringwill someapplication.toyou have your do of As anAscan and PRIORITY option, the simply you delete lines for each ADDRESS filethe into OIL load ISR. you the next When

Hardware drivers drivers Hardware 7.1.3

7.2 RTA-OSEKGuidefor PC User Migration Guide Unless you were far-sighted enough to configure your VECU to use the same interrupt model as in your target ECU. ECU. target your in as model interrupt same the use to VECU your configure to enough far-sighted were you Unless to Refer the tutorial chapter a fuller for explanation.

32 33

7.3

82 Migration Guide RTA-OSEK for RTA-OSEK PCUser Guide Migration Guide 82 7.3 7.5 7.4

Initialization Building the application application the Building Interrupts the best way to do this. for PC e.g. with the refer to the script that is supplied in the standard example program provided Youshould using. are you that script the custom-build to modify have will the within from buildyour application you to want If e.g. that it can adapt to different platforms. ISRcodeso of compilation useRTAmacros conditional implement to You can been serviced. to add code to your ISRs that tells the hardware that the interrupt source has Depending onyour controller interrupt and ECU the hardware, you needmay the of version specific hardware provide a to you need will Ineffect devices. clock/compare any hardware. In particular you may need to configure the interrupt controller and ECU’s your initialize to application your to code add needto You will as in the virtual device, this part of the migration should be straightforward. As long as you take care that each interface function has the same behavior #endif outp(0x12,99); #ifdef OS_TARGET_HC12X #endif //NothingneededtoclearinterruptforVRTA #ifdef OS_TARGET_VRTA change_speed(+1); { ISR(isrAccel) } returninp(0x1001); { int left_pressed(void) //------} applications. You must refer to the user-guide for your hardware for RTA-OSEK version for your target hardware. InitializeDevices() function usedin function RTA-OSEK GUIthen you RTA-OSEK 8.1

83

, and RTA-OSEK and and TraceCommInit() UploadTraceData() UploadTraceData() CheckTraceOutput() application isgenerally much application accurate can generate UploadTraceData() returns, the trace buffer can resume being being resume can buffer trace the returns, , RTA-OSEK for PC for RTA-OSEK plus a virtual device named “RTA-Trace”. “RTA-Trace”. named a virtual device plus regularly. RTA-OSEK for PC for RTA-OSEK RaiseEvent #ifdef OSTRACE_ENABLED CheckTraceOutput(); UploadTraceData(); #endif vrtaIsIdle(5); } } OS_MAIN() { StartOS(OSDEFAULTAPPMODE); { while(!vrtaIsAppFinished()) UploadTraceData() e.g. easier than in other applications because the trace communications communications trace the because applications other in than easier ‘built-in’. and efficient fast, is mechanism in the simply support enable RTA-TRACE applications you For most GUI, enable trace the comms link and call Whenever a block of trace data is ready to be sent, to be sent, ready is data a trace block of Whenever traces without being affected by ‘communication-interval gaps’ that affect affect that gaps’ ‘communication-interval affected by without being traces other ports. The VECU The VECU toapplication your added to is code VECU, build a trace-enabled When you APIs communication trace the implement osTraceCommInitTarget() then simply The device device. RTA-Trace the to andaddress size its passes raisesa‘Trace’ event with this dataattached. (e.g. it outside VECU or the within observers by ‘hooked’ can be The event vrtaMonitor),andofwill them get each anotification the whenis event raised. and efficient. quick is mechanism this devices, virtual of design the to Thanks Once the callto filled, so formost appears buffer purposes of emptying the to be an and instantaneous Running RTA-TRACE on an osTraceCommDataReady()

How it works How it works RTA-TRACE Reference Reference RTA-TRACE 8.1.1

8.1 8 RTA-OSEK for PC User Guide PC User RTA-OSEKfor RTA-TRACE Reference

8.2

data being fed toit. You mayfind itbetter to run the RTA-TRACE GUI ona different PC to the one that is hosting the VECU. 34 Note that this can include the RTA-TRACEGUI, which has to perform a very large amount of processing tokeep up with the trace 84 RTA-TRACE Reference RTA-OSEK for RTA-OSEK PCUser Guide Reference RTA-TRACE 84 8.2

8.1.2 Tuning process and thread priorities priorities process and thread Tuning

When you select a When VECU. that is accessible via via is accessible that dialog RTAOSEK-VRTA the be Thiscan results. donevia configuration best You may find it useful to adjust the process or thread priority for the VECU for must be e.g. For hookVECU theand Trace event of its RTA-Trace device. thename as DLL checks to seeif there isalready a VECUrunning with same paththe and for The RTA-TRACE-Server applications are running are applications irregularities in the trace that correspond to the moments where other time the same at running applications differentbetween processes in your PC.If there processor-intensive other are The quality of the trace data youthat see depends on heavily the interaction hooking the event. before it start and load DLL will the running, not already VECUis the If executable. Important: The astute reader will guess that the the that guess will reader The astute The thread within the VECU. The started with its embedded GUIvisible when started by RTA-TRACE-Server ProcessPriority RTA-TRACE ECUThreadPriority C:\Play\Tutorial2\MinGW\app\Tutorial2.exe C:\Play\Tutorial2\MinGW\app\Tutorial2.rta The

.rta communications driver communications driver .rta file, but with a .rta value affects the priority of the complete VECU. RTA-TRACE-Server to directly communicate RTA-Tracewith a deviceon a file for VECUa must be in the same directory theas 34 value affects the priority of the application (OSEK) file for a VECU file for a from withinthe . .exe GUI . as tracingas thenyouarelikelytosee rtcVRTAlink.dll value determined value determined whether a VECU is extension. If so, it will attach to to the attach it will so, If extension. rtcVRTAlink.dll RTA-TRACE adds the ability the ability adds . theVECU GUI, this this GUI,

.

8.3

85

, , or value in . This macro macro . This regularly for for regularly StopTrace() and and TraceCommInit() CheckTraceOutput() osgen.cpp StartBurstingTrace() SetTraceRepeat() SetTraceRepeat() UploadTraceData() CheckTraceOutput() to get called. called. get to when compiling , , and the RTA-Trace device from being added. being from device andthe RTA-Trace . This action can be used to change the applicationthe action. change This to can be used . This action can be used to change the VCU’s process process the VCU’s to change used can be action . This . This is sent On or Off to set the the set to Off or On sent is . This . This action can be sent the values Stop, FreeRunning, Bursting and FreeRunning, Bursting and values sent Stop,action the can. be This the VECU. Again, you must call acted upon. thisbe to ECUThreadPriority 8.2. section in described as way same the in priority thread’s ProcessPriority 8.2. section in described as way same the in priority State Triggering.asapplication Asyour long is calling regularly,this action will causeappropriate the target API ( StartFreeRunningTrace() StartTriggeringTrace()) Repeat

ƒ ƒ ƒ ƒ

osTraceCommInitTarget() If you want to write the RTA-TRACE communications link yourself instead of link yourself RTA-TRACE instead want communications writeIf to the you using the inbuilt version, define macro simply the OS_OVERRIDE_vrtaTraceDevice The RTA-Trace avirtual has device few up tricks other its sleeve. In addition to trace run-time the affect to use can you actions that 4 has it event, its Trace behavior. osTraceCommDataReady() will prevent trace the communicationAPIs Rolling your own Controlling the tracerun-time at

8.4 8.3 RTA-OSEK for PC User Guide PC User RTA-OSEKfor RTA-TRACE Reference

9.1

86 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 86 9.1 9 Parameters: Function declaration: The title gives the name of the API call. Notes: Notes: Return values: Description:

9.1.1 9.1.3 9.1.2 Virtual MachineAPIReferenceVirtual General notes notes General Return values Parameter Name Parameter Value Value

API Header Files Header API Interface in Csyntax. provided. of is the description API call A brief format: using standard the following chapter inthis described is API Each call The API Call Template C++ name so and mangling) may be C called from C++ or source. no (i.e. Clinkage use APIcalls Machine Virtual all otherwise specified Unless Linkage The file the detailed gives description of a This chapter Usage restrictions and notes for the API call. of of the APIcall. Explanation the functionality described here. It also chapter. order. in listed alphabetical API calls, Machine vrtaCore.h vrtaCore.h .

Description of return value. Description file #includes the files files the file #includes must be included to use the API calls listed in this inthis listed APIcalls use beincluded the to must prototypecontains declarations forthe APIcalls Input/Output Description. Description. Input/Output Input/Output Input/Output vrtaTypes.h Description RTA-OSEK forPC and and vrtaVM.h Virtual . 9.1

87 Listrelated of API calls. See also: See also: RTA-OSEKforGuide PC User VirtualMachine API Reference

9.2

88 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 88 9.2

9.2.1 9.2.7 9.2.6 9.2.5 9.2.4 9.2.3 9.2.2 Common Data TypesCommon Data

vrtaDevID vrtaDevID functions. Itfunctions. can take one theof values: This scalar value gets used statusas a return type by many of the API vrtaErrType to 32. A scalar value that contains interruptan priority. Priorities from zero (no ISR) vrtaIntPriority a but value A scalar that contains number the ISR. of an 32, ISRsrange 1to from vrtaISRID A scalar value that contains the ID of an action or event in a virtual Device. vrtaActEvID start1. at A scalar value that contains the ID of an event in avirtual device. Events IDs vrtaEventID start1. at A scalar value that contains the IDof actionan in device.a virtual Actions IDs vrtaActionID respectively. standardthe VMdevices DeviceManager, ICU ApplicationManager and 2 1 Devices0, are and device. virtual that a contains value IDof the A scalar These data types declared are all in • • • •

vrtaISRID RTVECUErr_VAL : Value fault. Value value : fault. Typically isout of range. Typically ID : fault. Device fault. : RTVECUErr_VAL No /success : error RTVECUErr_ID RTVECUErr_Dev RTVECUErr_NONE can sometimes be set to zero to mean ‘no ISR’. vrtaTypes.h Typically invalid device ID device invalid Typically . invalid action or event or ID action invalid 9.2

89 . 35 passed in it. within themselves. themselves. within was called must be of milliseconds since the VM was loaded. loaded. VM was the since milliseconds of (described in a moment). Both of in amoment). Both (described vrtaEmbed in milliseconds. This is normallythe OS_MAIN() monitor applications if the link to the VECU VECU the to link the if applications monitor fails. , then the data data the , then is used to represent boolean values. represent In this booleanto is used in milliseconds. in vrtaEvent . (Currently 0xffff.) 0xffff.) . (Currently type is taken to be “true” when it is non-zero it is non-zero when “true” be to is taken type and current ECU time ECU current interval vrtaEmbed , then the time recorded is the number number is the recorded time the , then vrtaBoolean vrtaBoolean is a ‘C’ union containing the followingthe fields: containinga ‘C’ union is and virtual of in out operations support passing data is used to

vrtaAction vrtaDataLenMax int int unsigned uVal iVal double dVal vrtaByte bVal[16] OS_MAIN() RTVECUErr_Conn RTVECUErr_Conn remote with Occurs fault. : Connection

• • • • • vrtaEmbed vrtaEmbed vrtaDataLen vrtaDataLen vrtaBoolean vrtaByte

Whenever the amountWhenever the of data passed in or of an out action event will or fit aninside instance of A scalar that represents the size (in bytes) of some data size (inA scalar bytes) that the of into some being passed represents or out of a The maximum device. value this that can takeof is given by the value macro the vrtaEmbed vrtaEmbed via devices The scalar type type The scalar a ofRepresents single byte dataa into passed of or Normally part out device. of an array of bytes. these data structures embedan instance of vrtamillisecond vrtamillisecond an representing scalar A vrtaTimestamp the representing scalar A number of millisecondsnumber(just of before) since document adocument and “false” when it is zero. zero. is it when “false” and

9.2.13 9.2.12 9.2.11 9.2.10 9.2.9 9.2.8 RTA-OSEKforGuide PC User VirtualMachine API Reference If a timestamp is taken before before is taken timestamp a If

35 This allows events to be where timed a VECU is started in slave mode.

9.2

90 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 90 9.2.14 vrtaTimestamp devTimeStamp vrtaEmbed devEmbeddedData const void*devActionData vrtaDataLen devActionLen vrtaActionID devAction vrtaDevID devID type andname In all common situations the data passed easily fits within the a virtual device.a virtual The fields in The worry dataabout buffersallocating data and ownership issues. isonly It largerwhere amounts of data instance, so low-overhead code such as this is common: is common: this such code as low-overhead so instance,

vrtaAction thisEvent.devEmbeddedData.uVal =32; vrtaAction structure is used to pass data value(s) specific to a action in vrtaAction inclusive then change during the call. referenced by senddata to an action, any data Where must point to this storage. vrtaAction be provided by the creator of the must the data storage the input for then If there are more than 16 bytes of data devEmbeddedData beeither NULL or the address of below). the contains address the (see of note data If it is more than 16 then devEmbeddedData the data is present in the then 1 isfrom to 16 inclusive, value its If zero. be Thiscan bytes of of data. The number The IDof the action. action. theThe IDof device the containing passing the action to the device. This fieldisupdatedby is no larger than 16 bytes. The union that contains the data where it If

description devEventLen need to be passed that we need to

are: vrtaSendAction() and devActionData is from zero to 16 devEventData

. union. union. the VM just before devActionData devEventData is called to called is vrtaEmbed must not must must

9.2

91

. must must must must . . the event via via the event devEventData does not change does not change vrtaGetState() union. . out of devEventData devEventData is from zero to 16 16 to zero from is are: and vrtaGetState() is called from the same thread same the from called is vrtaRaiseEvent() devEventData . caller The of The time that a query was made made was a query that The time into passed was data the that time The to

• • devEventLen vrtaEvent Description

The union that contains the data where it it where data the contains that The union bytes. 16 than larger no is to show VM the by This field is updated one of: The ID of the device containing the event. the event. containing device the The ID of event. the The ID of The numberdata. of of bytes This can be zero. If its value inclusive,16 to is from 1 then the in present is data the devEmbeddedData then 16 than more is it If data note of (see the address contains the below). If either be NULL or the address of of address the or NULL either be devEmbeddedData data of bytes 16 than more are If there thenforinput the storage data the must the of creator the by be provided vrtaEvent inclusive then

point to this the storage. note See below ownership. on data vrtaGetState()

, the data that is passed passed is that data , the vrtaGetState() may not change from the time that the call returns up up returns call the that time the from change not may vice. The fields in fields The vice. structure is used to pass state information about a specific aspecific about information state to pass used is structure devEventData: devEventData: the event via via event the Where the current value of an event is being queried, data can be passed be passed can data being queried, is an event of value current the Where into ensures that any data referenced by by referenced any data that ensures during the call. being queried via an is event value of the current Where vrtaGetState() devEventData that time next the to This can clearly be very complicated to achieve. However this is almost almost is this However achieve. to complicated very be clearly can This never necessary in real applications. Mostreturn data fitswithin vrtaEvent

vrtaEvent vrtaEvent ƒ ƒ

Ownership of The event in a virtual de a virtual in event type and name type and name vrtaEmbed devEmbeddedData vrtaTimestamp devTimeStamp const void * devEventData vrtaDevID devID vrtaEventID devEvent vrtaEventID devEventLen 9.2.15 RTA-OSEKforGuide PC User VirtualMachine API Reference

9.2 36

returns are all allocated during initialization and do not change during the application, so no special protection is necessary is protection special sono application, the during change not and do initialization during allocated areall returns For example the DeviceEvents event in the DeviceManager often returns string data that is larger than 16 bytes. The strings th strings The bytes. 16 than larger is that data string returns often DeviceManager the in event DeviceEvents the example For 92 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 92 9.2.16 9.2.18 9.2.17 e.g. =. form the each with items A pointer to ASCIIZan string that comprises zero or more \n separated option e.g. items. A pointer to ASCIIZan string that comprises zero or more \n separated list e.g. toA pointer ASCIIZsimple a string.

ƒ vrtaTextPtr vrtaOptStringlistPtr vrtaStringlistPtr

Melinda”; vrtaOptStringlistPtr op=“Name=Bill\nAge=51\nWife= vrtaStringlistPtr lp=“One\nTwo\nThree”; vrtaTextPtr tp=“HelloWorld”; the datathe does not change during the call. they need, of sothecaller that data any of copy a take must Listeners listeners. its to data supply Where an event isbeing raised via anyway devEmbeddedData 36

. , and in most other cases the data does other cases and change inmost the not , data vrtaRaiseEvent() vrtaRaiseEvent() only to has ensure that , the device may . at it 9.3

93 time time ). in VECU code to send data of the the of data send to code VECU in es not hold where external programs programs external where hold es not its actions and events. This information This information and events. actions its Description 32-bit signed integer 32-bit integer,a normally in binary represented by monitor program. value32-bit with zero values through is 4 that normally represented by a monitor asprogram one strings separated | the of integers. signed 32-bit 3 comprising structure A

Integer that can take values 1 through 32. 32. through 1 values take Integer can that Loaded|Running|Paused|Terminating|Resetting access the data. For this reason a device must supply a a supply must a device reason this For the data. access

. vrtaMonitor 37

String %d %d:;1;32 %b Loaded|Running|Paused|Ter minating|Resetting %d,%d,%d Within the VECU, all data is handled in native machine format,an i.e. ‘int’ for an integer value. It is your responsibility While this is a reasonable assumption in the C and C++ code that gets gets that code C++ and C the in assumption reasonable a is this While compiled into it the clearly VECU, do such as by is used that thedescription data of interpret and a device to sent data the format to programs remote by used is and range checking on data size The VM performs the back. data it sends device each by be done to have not does it that so remote programs from itself. are: strings Example format

Overview Overview with associated data some have commonly events and actions device Virtual them. 1 range the in integer an passed be to has action Raise ICU’s the example For a represents that value supplies The ApplicationManager’sto event State 32. ( state application thread the correct type between actions and events. As long as you trust your code to to code your trust as you As long events. and actions between type correct within your checks range to omit choose can you data, of type right the pass devices

Data format Strings Strings format Data 9.3.1

9.3 RTA-OSEKforGuide PC User VirtualMachine API Reference By all means add range checking code if you wish. Our design aim is to allow (but not force) devices to have a very small run- small very a have to devices force) not (but to allow is aim design Our wish. you if code checking range add all means By

37

overhead. 9.3

94 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 94 9.3.2 %a[:] %s[:] ||…[:] %b[:] %x[:] %f[:] %u[:] %d[:] Data-item descriptor

Definition constraint has the form: constraint a include descriptor optionally may A data-item descriptors asfollows are inside“ (text multiple data-item descriptors then they are separated by ‘ A data format string consists of one or more data-item descriptors. If there are is the number of bits used of number isthe can becan 8, 16,32 64. or [[!]][;;] data-item size unless there is a constraint. constraint. is a there unless size data-item is given then it specifies the size of the array. of thelength or event data. If action a is given then the size of the array is inferred from the The data-item is an array of bytes. If no have not ‘ a trailing The data-item is ASCIIan string – which may or may Enumeration value represented series a as ofenumeration values. that should unsigned is number The data-item an (aC bits isstored By inbinary. this in32 default represented that should unsigned is number The data-item an the data-item size unless there is a constraint. (aC 32 bits By is this default stored inhexidecimal. represented in that should unsigned is number The data-item an C (a in64bits isstored this The data-item is floating-point number. By default constraint. determined by the data-item size unless there is a is stored is The data-item unsignedan number. Bydefault this in 32 constraint. is a there unless size data-item the by bits (astored C in 32 bits signed is The data-item Bydefault is number. this a (a C

of the action or event data. If a then the size of the string is inferred from the length trailing ‘ trailing itthen specifies the size of the string (including a enumeration value constraint. determined by the data-item size unless there is a By default isBy default storedthis in C 32 (a bits Description Description \0 unsigned [] ’ if there is one). unsigned ” is optional): ” isoptional): \0 ). The range is determined by the by isdetermined range The ). to store a numeric store a to int ’. If no corresponds to the number0, corresponds the to to the number 1, and 1, to number so and the on. ). The range isdetermined by ). The range isdetermined). Therange unsigned double , ’s. The data-item unsigned ). Therange is ). Therange is value. This value is given is value value isgiven value . Where: . A value value value value ). ). 9.3

95 ). int ). ) and should be displayed in binary. in displayed should be and ) unsigned ) and should be displayed in hexidecimal. This is item and the start of the next data-item. data-item. next the of start the and item stored in a numeric data-item. data-item. a numeric in stored be may that values maximum and minimum are the data- the of start the between bytes of number the is unsigned char and and There is a 10 character string. This is followed by an unsigned number an number unsigned followed by string. This is a 10 character There is data- next the since padding; of 3 bytes arethen bits. There in 8 stored itemafter stored is 4 bytes the start of the 8 bit value. This padding is stored100 inclusive in numberthe 1 to range followed an in by unsigned 64 bits There is anThere is unsigned numberthatwill be stored in 16 bits (a C unsigned short immediately followedanthat number will be stored unsigned by 8 bits in (a C There is a single signed number that will be stored in 32 bitsin 32 C (a stored will that number be a single signed isThere thean inclusiveThere range 1 to number in is that 10 will unsigned be C (a bits stored in 32 “%s:10,%u:8!4,%u:64;1;100” “%s:10,%u:8!4,%u:64;1;100” “%x:16,%b:8” For example: For example: “%d“ “%u:;1;10” RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

96 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 96 9.4 Parameters: Function declaration: Parameters: Function declaration: Return values: Description: Notes: Notes: See also:

9.4.1 9.4.2 API Functions Functions API Value Value Parameter Parameter

InitializeDevices() OS_MAIN() The entry-point for the application thread. OS_MAIN() void InitializeDevices(void) hook Device initialization function. Reset actiontoinform it that the application threadis about to start. InitializeDevices() code that carries out initialization of virtual devices. By the time that calls calls the a by is called It code. application You must provide provide You must the module, typically typically module, C++linkage has This function so mustbeand implemented C++source in a OS_MAIN() OS_MAIN()

, Input/Output Input/Output vrtaStart() devices.cpp . InitializeDevices()

Description InitializeDevices() is called, each virtual device will have been have device will sent a virtual each called, is Description Description Description Description . pplication thread immediately before it is normally used to execute execute to used normally is hookfunction inyour 9.4

97

or call or because because the code that that the code RTA-OSEK for PC for RTA-OSEK OS_MAIN() OS_MAIN() should be made so that that so made be should StartOS() That is, it is the code that runs when when runs that is the code is, it That . On the return from from return the . On vrtaIsAppFinished() when sucha request occurs then thewill VM forcibly , the application can return from from return can application the , Description Description

to cause the applicationto the cause to finish. This might the be because function is provided by the Virtual ECU applicationand ECU the Virtual code by is provided function , which has implementation-dependent behavior. behavior. implementation-dependent which, has StartOS() normally has the structure shown below in an below in shown structure the normally has OS_MAIN() OS_MAIN() RTA-OSEK for PC for RTA-OSEK while(!vrtaIsAppFinished()) { vrtaIsIdle(5); } ShutdownOS(E_OK); } OS_MAIN() { initialize_something(); StartOS(OSDEFAULTAPPMODE); this has no meaning in a typical it embedded might Sometimes system. call ShutdownOS() For ShutdownOS() example. for complete is simulation ECU the then default) (the mode autostart in loaded has been ECU Virtual the If complete Virtual Machine will terminateautomatically. the Virtual mode then was in slave been loaded the VECU If, however, Machine will wait foraTerminateaction to be received by the Application the after queried be to devices VECU’s the of state the allows This Manager. application thread has terminated. no task or ISR isactive. Normallyan OSEK application does not ‘return’ from executes is deemed to be the ‘idle task’. task’. the ‘idle to be is deemed executes is the entry-point for the application thread. thread. application the for entry-point the is Typically anapplication will make initialization some callsandstart the then OS kernel via The application. callto The OS_MAIN() external requests to terminate the program get recognized promptly. If you you promptly. If recognized get program the terminate to requests external don’t quit terminate the application thread after a few seconds. seconds. a few after thread application the terminate InitializeDevices(), vrtaStart(),vrtaIsAppFinished(), vrtaIsIdle() Value Return values: values: Return Description: Description: Notes: See also: See also: RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

98 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 98 Function declaration: Function declaration: Return values: Description: See also: Notes: Parameters: 9.4.3 9.4.4 Value Value Parameter

void vrtaEnterUninterruptibleSection(void) Enter sectioncritical a that cannot beinterrupted. vrtaEnterUninterruptibleSection() vrtaEventCallbackeCallback,const void*tag) vrtaEventListener vrtaEventRegister( Register eventan handler. vrtaEventRegister() executes. with thestack manipulation thatoccurs when an functions cannot cope library runtime non-reentrant C/C++ functions and vrtaLeaveUninterruptibleSection() vrtaEnterUninterruptibleSection() it callmust then function library C/C++ runtime non-reentrant or Important: critical section. Calling Calling section. critical Thisfunction enters critical a section. Onlyinthethreadbeonetime may ata vrtaLeaveUninterruptibleSection() calls thread application the If section. critical inthe is already thread if another thread calling the block then it cannot be interrupted until it leaves the critical section. section. critical leaves the until it be interrupted itcannot then if the application thread needs to call any APIfunction Windows needsany call to thread application the if

Input/Output

Description vrtaEnterUninterruptibleSection() Description Description vrtaEnterUninterruptibleSection() afterwards. APIWindows afterwards. the before call making and RTA-OSEK forPC

interrupt will will

9.4

99

tag is only valid argument will type. type. vrtaHookEvent() vrtaHookEvent() event event . vrtaRaiseEvent() vrtaRaiseEvent() , should always return return always should and its its and which is defined as follows: follows: as defined is which vrtaEvent argument will be set to the eCallback . If you need to use this data after after . If you need to use this data eCallback as the function to call when the specified specified the when call to as function the . structure pointed to by pointed structure instance 38 Description Description vrtaHookEvent() eCallback A caller provided value that willan be passedas to argument , handle is needed when callingwhen handle is needed vrtaEventCallback eCallback . Your function must be thread-safe because it is quite is quite it because thread-safe . Your be must function vrtaEventRegister() Description Description for more information more for about the A handle for the event handler. handler. event the for handle A vrtaEvent . is called its be in a different thread. thread. a different in be Input/Output Input Input function. handling anevent A pointer to is of type type is of has returned then you must take a copy of the data. data. the of a copy take must you then returned has

will eCallback const void *instance, const vrtaEvent *event); const void *instance, typedef vrtaErrType (*vrtaEventCallback)( typedef vrtaErrType (*vrtaEventCallback)( vrtaGetState() vrtaEventUnregister() This API call registers an event hook callback routine with the VM. The The VM. the with routine callback hook an event This API call registers vrtaEventListener so that it can identify identify can it that so event is raised. is event eCallback The event hook callbackThe event function hook called gets during the of execution vrtaRaiseEvent() are the of that threads independent raise from events tonormal devices for monitor an external from provoked gets that event Any thread. application application When argument passed to passed argument The content of the the of The content RTVECUErr_NONE contain the event raisedcontain the event for the duration of the call to to call the of duration the for eCallback Value Parameter Parameter eCallback tag

Parameters: Parameters: See also: See also: Notes: Description: Description: Return values: values: Return RTA-OSEKforGuide PC User VirtualMachine API Reference See the description of of description the See 38

9.4

100 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 100 Parameters: Function declaration: Parameters: Function declaration: See also: Notes: Description: Return values: 9.4.5 9.4.6 ev id RTVECUErr_VAL RTVECUErr_NONE listener Value Value Parameter Parameter

vrtaEventUnregister() vrtaErrType vrtaGetState(vrtaDevIDid, vrtaEvent*ev) Query thecurrentstate (value)ofevent. an vrtaGetState() vrtaEventListenerlistener) vrtaErrType vrtaEventUnregister( Unregister an event handler. vrtaEventRegister() handler. event an be called within from APIcannot This vrtaEventRegister() haevent an unregisters APIcall This handler are unhooked. are handler nu TheIDof the virtual device to be queried. Input/Output Input Input/Output Input Input Input/Output The successful. was The APIcall Description listener , . Anyevents that have been hookedbytheevent vrtaHookEvent() and its data. data. its and A pointer to the structure that specifies the event Description Description vrtaEventRegister() An event-handler returned handle by Description argument is invalid. invalid. is argument ndler previously registered with registered previously ndler , vrtaRaiseEvent() . 9.4

101

vrtaEvent now references references now , ev , orage. The queried device The queried device orage. , the data in the VM passes the passes the VM copies the event data into the the into data event the copies termines the the valuetermines event’s (possibly appropriate times and times can be these appropriate vrtaRaiseEvent() , , you must set the correct device and event event and device correct the set must , you field to point to this st this to point to field vrtaEventUnregister() vrtaGetState() , vrtaGetState() field or places the data in storage that it has allocated has that it in storage data the field or places Description Description The API callwas successful. The specified device ID is invalid. The specified ID is event invalid. range?). of (out is invalid event the in provided The data field to zero. zero. to field vrtaGetState() devEventData . If the event needs to be passed some data as part of the query (e.g. (e.g. the query of as part data some to be passed needs . If the event ev structure to the device. The device de The device the device. to structure using the data) and either input devEmbeddedData the sets and is responsible for managing any storage that it allocates. Refer to section allocates.to it that section any Refer storage managing for is responsible for 9.2.15 details. vrtaRegisterVirtualDevice() This API is used toThis the current API is obtain used supportedana virtual valueevent by of at events raise devices device. Virtual multicast to interested receivers. However, sometimes it is useful to be able to to able be to useful is it sometimes However, receivers. interested to multicast for events sense most makes This event. an of value” the “current discover interrupt current the discover to wish may one example, For data. contain that than rather unit control interrupt Machine’s Virtual the of level (IPL) priority not do which Events changes. IPL the when raised be to an event for waiting containsimply dataindicate but somethinghasthat can still happened be do. to so useful really not itqueried, but is When calling IDs in the then event), DeviceAction DeviceManager’s the for device the of name the the set call.databefore the If is needed, no up be set must data devEventLen from return successful On event. the value of the current During call the of vrtaEventRegister() vrtaHookEvent() Value RTVECUErr_NONE RTVECUErr_Dev RTVECUErr_ID RTVECUErr_VAL See also: See also: Description: Description: Return values: values: Return Notes: RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

102 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 102 Parameters: Function declaration: Description: Notes: Notes: Return values: 9.4.7 RTVECUErr_VAL RTVECUErr_ID RTVECUErr_Dev RTVECUErr_NONE capture ev dev listener Value Value dev Parameter Non- Non-

zero zero vrtaHookEvent() vrtaDevIDdev,vrtaEventIDev,vrtaBooleancapture) vrtaErrType vrtaHookEvent(vrtaEventListenerlistener, event is raised. the when called event isnot handler is or event unhookan Hook or sothat an If If This API may not be from inside called eventan handler. depends on the values of hooked with thisAPIcall. Thebehavior of whenthe call If associated with 0 0 All event hooks Allevent are removed from 0 0 capture capture ev Non- zero 0 is true then this call ‘hooks’ the event so that the event handler is false then this call unhooks call then this isfalse Input True True hookto event,an false to unhook event. an TheIDof the event. TheIDof the device. Input Input Input Input Input/Output removed from hooksAll event for events owned by the specified device are listener The event hookfor the specifiedevent is removed from Result Result listener event handler. The invalid. event IDis The specified IDisinvalid. device The specified successful. was The APIcall Description listener dev . is called iscalled when the event gets raised. listener and and vrtaEventRegister() An event-handler returned handle by Description ev argument is invalid or called from inside an an inside from called or invalid is argument as follows: follows: as . one events more previously or listener . capture . is false false is 9.4

103 , and and

argc vectors[1] , structure containing the containing the structure entry-point. . is defined as is follows: defined main() is called automatically for you. Description and a fatal error generated if the value is not not is value the if generated error a fatal and The number of command line arguments The number command of on the line. command ECU’s Virtual the from line arguments command array of The line. command ECU’s Virtual vrtaVectorTable vrtaStart() vrtaEventUnregister() , vrtaVectorTable arguments should be taken directly from the from directly taken be should arguments field must be 32. This is checked by the Virtual Machine Machine the Virtual by checked This is be 32. must field is anarray interrupt of 32 vectors. The Virtual Machine’s and before before and argv . , ICU interrupt vector number 2 corresponds to corresponds 2 number , vector ICU interrupt Input/Output points to a points to Input Input Input table.vector interrupt the A pointer to and vrtaInitialize() arguments of the Virtual ECU’s ECU’s Virtual the of arguments numVectors argc vectors[] #define RTVECU_NUM_VECTORS (32) typedef struct { unsigned numVectors; vrtaIntVector vectors[RTVECU_NUM_VECTORS]; } vrtaVectorTable; and so on up to ICU interrupt vector number 32 which corresponds to which corresponds 32 number vector to ICU interrupt up and so on vectors[31] vrtaEventRegister() vrtaRaiseEvent() vrtaRaiseEvent() For an RTA-OSEK VECU, this API this VECU, an RTA-OSEK For The This API call is used to initialize the Virtual – it Machine must be called after vrtaLoadVM() interrupt control unit (ICU) numbers interrupt vectors from 1 to 32 (0 is used used is (0 32 to 1 from vectors interrupt numbers (ICU) unit control interrupt to mean no interrupt). ICU interrupt to number vector 1 corresponds vectors[0] The during 32. vrtaInitialize() vrtaInitialize() Initialize Virtual the Machine. argc, void vrtaInitialize(int vrtaVectorTable* vecTable) char* argv[], const vectTable table. vector interrupt argv

Parameter Parameter argc argv vecTable 9.4.8 See also: See also: Description: Description: Function declaration: Function Parameters: Parameters: RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

104 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 104 Return values: Value Value Each interrupt Each interrupt vector isdefined follows: as argument in the corresponding interrupt vector and its its called is handler interrupt When an An interrupt handler has the following definition: called. it is when handler interrupt to the ispassed that that is lowest(1 priority and 32the highest priority). isthe – interrupt corresponding this numbermust be ina 1 the 32range to inclusive arrives. interrupt corresponding The A trivial exampleA trivial ECU of Virtual starting might looka like: interrupt handler. code inan running the for interrupt of or the priority handler interrupt set to prioritythe of the code –interrupted zero for code not in running an } <...snip...> /*Theapplicationthreadstartshere.*/ OS_MAIN() { }; {IntHandler,32,(vrtaTag)32}} <...snip...> {IntHandler,2,(vrtaTag)2}, {{IntHandler,1,(vrtaTag)1}, RTVECU_NUM_VECTORS, vrtaVectorTable IntVectors={ } /*Handleinterrupt.*/ vrtaIntPriorityoldIPL){ void IntHandler(vrtaAppTagtag, vrtaIntPriorityoldIPL); typedef void(*vrtaIntHandler)(vrtaAppTagtag, } vrtaIntVector; vrtaAppTagtag; vrtaIntPrioritypriority; vrtaIntHandlerhandler; typedef struct{ } *threadterminates.*/ /*Controlreturnsherewhentheapplication vrtaStart(); vrtaInitialize(argc,argv,&IntVectors); vrtaLoadVM(); void main(intargc,char*argv[]){ handler field points to the interrupt handler to be run when the

Description priority tag argument is set to the is the priority of the tag oldIPL is application data is application argument is argument tag

9.4

105 . osgen.cpp entry-point in the support file in the entry-point d via d via This API call is not for application application for not is call API This SEK support files toSEK support initialize the OSEK main() Description Description #include that is is that vrtaStart() vrtaStart() , Input/Output

if a if Virtual ECU is usingthis OSEK API should not be called

vrtaIsAppFinished() vrtaIsAppFinished()

vrtaLoadVM() Determine if the application thread has terminated or is about to terminate. terminate. to about is or terminated has thread application the if Determine vrtaBoolean vrtaIsAppFinished(void) explicitlyas it is called by the vrtaOSEKSupp.cpp vrtaInitializeOS() Initialize theMachine kernel within Virtual OS the DLL. void vrtaInitializeOS( * osLinkageTablePtrPtr, vrtaLinkageTablePtr * traceLinkageTablePtrPtr) vrtaLinkageTablePtr Not documented. This API call inside RTA-O is used from kernel within the Virtual Machine DLL. Not documented. Important: use.

Parameter Parameter 9.4.10 9.4.9 Notes: See also: See also: Function declaration: Function Parameters: Function declaration: Function Parameters: Description: Notes: See also: Return values: values: Return RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

106 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 106 Parameters: Function declaration: See also: Notes: Return values: Description: Description: Return values: 9.4.11 false true false true Parameter Value Value Value vrtaBoolean vrtaIsAppThread(void) thread. isthe application thread calling ifthe Determine vrtaSpawnThread() if the calling thread is not the application thread. thread. not is the application thread calling the if or false thread the is application thread calling the if true returns APIcall This another thread has called tothread discover is if it to be about – terminated forcibly because e.g. the by application be used may APIcall This otherwise. or false terminate, This API call returns true if the application thread has terminated or is about to RTA-OSEK for PC RTA-OSEK for been senttothe ApplicationManager Device.This beusedinalso APImay

vrtaIsAppThread()

Input/Output threads to discover if they should terminate themselves. The calling thread is not the application thread. thread. not is thread the application The calling thread. is thread the application The calling terminate. to about isnot has thread terminated not and The application terminate. is to thread or terminated about The application has Description Description vrtaTerminate() Description or a Terminate or a actionhas 9.4

107 an an t+10

. For example, if at at if example, . For and at time at time and

thread that iscall idle should this vrtaIsIdle() vrtaIsIdle(100) Description Description . Description Description

t+10 Input/Output Input/Output

Input millisecondsfor. for The number yield to the application the threadcalls t vrtaLeaveUninterruptibleSection() vrtaLeaveUninterruptibleSection() vrtaIsIdle() vrtaIsIdle()

This API call tells the Virtual Machine that the calling thread will be idle for the specified of milliseconds.a number Ideally thread the suspend to VM the allows so Doing busy-waiting. than rather API thread. another run to the processor can use Windows so that The application will thread still respond to interrupts and run the while inside acorrespondingcall ISRs of time interruptarrives, ISR will the corresponding be runapplication by the thread after, shortly or at, Leave a critical section. section. a critical Leave void vrtaLeaveUninterruptibleSection(void) Yield thewhilst processor idle. msecs) void vrtaIsIdle(vrtamillisecond Parameter Parameter Value Parameter Parameter msecs

9.4.13 9.4.12 Parameters: Parameters: Parameters: Notes: See also: Notes: See also: Description: Description: Return values: values: Return Function declaration: Function Function declaration: Function RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

108 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 108 Function declaration: Parameters: Return values: Description: See also: Notes: See also: Notes: Description: Return values: 9.4.14 Value Value Parameter Value vrtaOSEKSupp.cpp the by is called it as explicitly Important: void vrtaLoadVM(void) Virtual Machine DLL. Load the This API call loads the correct VM DLL API the use. correct and prepares loads for its APIcall This vrtaEnterUninterruptibleSection() vrtaInitialize() vrtaLoadVM() is: ECUrunning aVirtual start to sequence APIcalls The correct of before any be API called This must vrtaEnterUninterruptibleSection() calling by entered previously section leaves a critical function This

vrtaLoadVM() if a Virtual ECU is using OSEK this API does not need to becalled needto doesnot ECU API Virtual isusingOSEKthis a if

Input/Output , vrtaInitialize()

Description Description that is , vrtaStart()

#include Description Description other Virtual Machine API is called. APIis called. Machine Virtual other main() and and d by entry-point inthe file support vrtaStart() osgen.cpp . . . 9.4

109

This API call is not not is call API This API call is made by a thread other other a thread by made is call API Virtual Machine. Machine. Virtual SEK support files to generate a fatal a fatal generate to files support SEK SEK support files to get the interrupt interrupt the get to files support SEK RTA-OSEK for PC for RTA-OSEK

This API call is not for application use. application for not is call API This vrtaOSGetIPL() vrtaOSGetIPL() vrtaNoneUserThread() vrtaNoneUserThread()

Not documented. error when an RTA-OSEK API call is made by a thread other than the the than other thread a by made is call API RTA-OSEK an when error application thread. VM. the within level priority interrupt the Get vrtaIntPriority vrtaOSGetIPL(void) Not documented. This call API is from used inside RTA-O priority level within the than the application thread. thread. application the than funcName) char * void vrtaNoneUserThread(const Not documented. This API call is used frominside RTA-O use. for application Not documented. Generatea fatal error when an RTA-OSEK 9.4.16 9.4.15 Notes: Return values: values: Return Function declaration: Function Parameters: Description: Function declaration: Function Parameters: Description: Notes: Return values: values: Return RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

110 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 110 Parameters: Function declaration: Notes: Return values: Description: Parameters: Function declaration: Return values: Description: 9.4.17 9.4.18 RTVECUErr_VAL RTVECUErr_ID RTVECUErr_Dev RTVECUErr_NONE ev dev Parameter Value Value constvrtaEvent*ev) vrtaErrType vrtaRaiseEvent(vrtaDevIDdev, event.Raise an documented.Not for application use. the within level priority interrupt the set to files support RTA-OSEK inside used is from APIcall This documented.Not vrtaIntPriority vrtaOSSetIPL(vrtaIntPrioritynewIPL) Set the interrupt priority level within the VM. This APIisused by a virtual device to raise an event.

vrtaOSSetIPL() vrtaRaiseEvent() vrtaRaiseEvent() nu TheIDof the virtual device raising the event. Input Input Input/Output The data provided in the event is invalid. in provided invalid. the The data is event invalid. event IDis The specified IDisinvalid. device The specified successful. was The APIcall Description

RTA-OSEK for PC be raised. A pointer to structurea that contains the event to Description Description Virtual Machine. This API call is not 9.4

111 .

structure as an structure , , desired_ticks_per_s vrtaEvent Description Description The number of “ticks” requiredThe number of “ticks” per second. is derived by reading theis derived PC’s high- vrtaGetState() , vrtaEventUnregister() Input/Output Input

, Description Description and passes them the the them and passes The number of “ticks” that have elapsed since the the elapsed since that ofThe number have “ticks” a is “ticks” in second number of The ECU started. Virtual argument call API the set by vrtaRegisterVirtualDevice() vrtaRegisterVirtualDevice() vrtaReadHPTime() vrtaReadHPTime()

argument. argument. vrtaRegisterVirtualDevice() vrtaEventRegister() vrtaHookEvent() The VM calls any event handlers that have hooked the event during during event the hooked have that handlers any event calls The VM vrtaRaiseEvent() performance timer; therefore the resolution of the value returned depends on on depends returned value the of resolution the therefore timer; performance CPU the of multiple a low be to appears this practice In PC. the of details the a PC. typical on clock speed This API call returns the number of caller defined “ticks” that have elapsed elapsed have that “ticks” defined caller of number the returns call API This The value ECU started. since the Virtual Register a virtual device. device. a virtual Register Read the PC’s high-performance timer. timer. high-performance PC’s Read the desired_ticks_per_s) unsigned vrtaReadHPTime(unsigned Value Parameter Parameter desired_ticks_per_s 9.4.20 9.4.19 See also: See also: Parameters: Parameters: Notes: Return values: values: Return Notes: See also: Description: Description: Function declaration: Function RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

112 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 112 Description: Parameters: Function declaration: tag sCallback aCallback actions events info name Parameter of the form: name device. virtual a isused to register APIcall This is thetype ofdevice e.g. info error. name not uniquea fatal is the generate Machine thewill Virtual constvoid*tag) constvrtaStateCallbacksCallback, constvrtaActionCallbackaCallback, constvrtaOptStringlistPtractions, constvrtaOptStringlistPtrevents, constvrtaOptStringlistPtrinfo, constvrtaTextPtrname, vrtaDevID vrtaRegisterVirtualDevice( prescribe thevalues of events with (e.g. manager device Machine’s byquerying be obtained Virtual can the that items information descriptions are separated using ‘ separateddescriptions are insectiondefined 9.3. Where device supports multiple events then eventthe forms: Eachdevice. event supported isdescribed by the oneof stringa following of (b) (c) (a) : : the the “=()” “” “=” : isthename of the event and the info name is the version of the device. The Virtual Machine does not Input Input Input Input Input Auniquename device. thefor virtual Input Input Input Input/Output events “Type=\nVersion=\n” argument describes the virtual device. This should be a string describes device. argument virtual Thisshouldbea the argument specifies uniquea name for the virtual device. If

argument describes the events supported by the virtual “clock” vrtaMonitor

sCallback the to passed data Application handle pointerA callback state to a function calledto handle actions sent to the virtual device. to called function callback to action an A pointer the actions supported by the virtual device. A ‘ eventsthe bysupported the device. virtual A ‘ A ‘ about the virtualdevice. Description

\n \n \n \n and , ’. ’. ’ ’ separated string descriptionscontaining of ’ separated string descriptionscontaining of “actuator” ’ separated string information containing vrtaGetState() ). functions. functions. . or or is adata format string as “CAN Channel” as these are simply theseare as requests. where aCallback , and and and

9.4

113

fields of fields is invalid, on success, on success, ”. action () argument is set the the set is argument for a for of description argument passed to to passed argument structure containing structure containing and any storage pointed andany pointed storage is a data format string as as string format a data is field of field of devActionData . It shouldthen extractany actions inside the “ inside the with the following definition: definition: following the with instance or RTVECUErr_NONE are only valid for the duration of of duration the for valid only are action is invalid. ine what action is to be carried out out action is to be carried ine what vrtaAction ). action vrtaRegisterVirtualDevice() an event that simply happens at some at some happens simply that an event the second has event ID 2, and so on. and on. so ID 2, has event second the devAction a virtual device will alsosenta been action ’. ” and input databy when queried vrtaSendAction() action structure defined as follows: defined structure structure in section 9.2.14). 9.2.14). in section structure \n ()

field of argument points to an action callback function field of devEmbeddedData argument describes the actions supported supported the actions argumentby device. describes . vrtaActionCallback if the data if the in vrtaAction vrtaSendAction() as described by

devAction structure pointed to by aCallback argument to passed argument points to the the to points argument if the action if the ID in the before the “ the before actions . The (c) form describes an event that contains data as described as described contains data an that event . describes (c) The form the the tag : vrtaDevResetInfo the the devActionData : action is the name of the action and action of is the name the (again see “=” “” (a) (b) vrtaAction typedef vrtaErrType (*vrtaActionCallback)( typedef vrtaErrType (*vrtaActionCallback)( vrtaAction *action); void *instance, const RTVECUErr_VAL that is called to handle actions sent to the virtual device. The action callback callback action The device. virtual the to sent actions handle to called is that type the has function the action callback function. If the application wishes to use this data after the the after data this use to wishes application the If function. callback action the own its into data the copy must it returned has function callback action storage. In addition actions in the to described handling The first action in the list has action ID 1, the second has action ID 2, and so and so action ID 2, has second action ID 1, the has the list action in The first on. aCallback The (a) form of action description describes an action that does not have any actionan thatThe (a)action any does not of have describes form description as data contains that action an describes form (b) The data. associated by described to by the the by to vrtaRegisterVirtualDevice() special Reset command with action ID zero. In thiscaseactionthe data will be a of a copy Each action supported is described by a string of one of the following forms: forms: following the of one of astring by described supported is action Each event the then actionsmultiple supports device Where 9.3. defined in section descriptions are separated using ‘ data required from the required the data from action The action callback should return function RTVECUErr_ID or The actions The first event in the list has event ID 1, event has list the in event The first The action callback function should determThe action callback function the by examining the action sent to the device (see device the to sent action the the of contents the The (a) form of event description describes an event that does not have any any not that have an does event The (a) describes description form of event used for be would This data. associated as described data contains that an event describes form (b) point in time. The by by vrtaGetState() and the value of the value the of action function callback When the is called its RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

114 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 114 vrtaDevReadFromPersistentStorage vrtaDevWriteToPersistentStorage vrtaDevStop vrtaDevStart vResetType vrtaStateCallback supported bythe virtual The device. state callback function has typethe when called is that the value ofthe value the vrtaEvent vrtaRegisterVirtualDevice() When thestate callback its function iscalled sCallback The typedef vrtaErrType(*vrtaStateCallback)( } vrtaDevResetInfo; vrtaBytevResetType; vrtaByte**vPSAddr; vrtaDataLen*vPSLen; typedef struct{ vrtaDevReadFromPersistentStorage}; vrtaDevWriteToPersistentStorage, vrtaDevStop, vrtaDevStart, enum vrtaResetTypes{ void*instance,vrtaEvent*state); vResetType value structure containing theevent to be queried. There may be : the fielddescribes the reasonfor the“reset” action asfollows: sCallback vrtaGetState() with the following definition: argument points to a state callback function state callback to points a argument tag and the is called to query one the query to of iscalled events argument passed to to passed argument callback handler returns. from virtual device must copy the data point tothe data propagated. The propagated and and propagated data bytes of of number the contain propagate. *vPSAddr propagate to data of and reset. If it did then propagate data from before the virtual device may have arranged to The Virtual ECUhas been reset. The set should doesit it reset. If the across arrange for data to be propagated The virtual device may wish to The Virtual ECU is about to be reset. terminate. to is Machine about The Virtual running. start to is about thread The application Reason for “reset” action state instance *vPSLen *vPSAddr argument points to the to points argument to point to the data to argument is set to theto number of bytes before the action *vPSAddr *vPSLen will will will will 9.4

115

if or or , fields of fields of RTVECUErr_VAL RTVECUErr_ID devEmbeddedData ) continue to be able) be continue to to vrtaSendAction() vrtaSendAction() , devEventData or on success, structure. structure. is invalid, or vrtaEventRegister() , . It should thenany extract input state vrtaMonitor structure. See section 9.2.15 for a for 9.2.15 See section structure. state vrtaEvent or field of vrtaHookEvent() Description ,

RTVECUErr_NONE field of devEmbeddedData vrtaEvent vrtaRaiseEvent() Description Description is invalid. The ID of the virtual device. device. virtual the The ID of vrtaServer devEvent , fields. fields. devEvent state Input/Output

and storethe result of the query in the vrtaReset()

communicate with the VECU after reset and don’t notice the handover of of handover the notice don’t and reset after VECU the with communicate processes. incomingthe data in description of the contents of the the of contents the of description This API call instructs the VM to reset. It does this by creating a new Windows Windows a creating new this Itreset. by does VM toThis API call the instructs the a of VECU in it.and Certainrunningsuch information copy new process are programs external to and connections line options as command an ECU being reset of effect the This creates process. to the new propagated external to connections Since reset from vector. its andstarting execution with communicating programs to process, the new are propagated programs asthe VECU (such vrtaGetState() Reset the Virtual Machine. Machine. Virtual the Reset void vrtaReset(void) The callback functions can be called from different threads, so they must be be must they so threads, different from called be can functions callback The thread-safe. The state callback should determinewhat event function is to be queried by examining the vrtaEventUnregister() the event ID in the ID in the the event if the data in data required from the the required from data state devEventData The function should return Parameter Parameter Value

9.4.21 Description: Description: See also: See also: Notes: Function declaration: Function Parameters: Parameters: Return values: values: Return RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

116 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 116 Return values: Parameters: Function declaration: See also: Notes: Description: 9.4.22 a id Value Value Parameter Windows process. restores state information from the temporary file created by the original vrtaInitialize() vrtaLoadVM() sequenceof calling initialization carries normal out the entry-point main() hashappenedOnce this new the Windows process starts runningthe and The call of The call programs)in atemporary file. VMsaves the Next certain connections information external to (such state as each virtual device to inform it that the VECU is about to reset. Once the application thread has terminated the VM sends Reset a action to within 10 not terminate seconds it is terminated. forcibly OS_MAIN() 10 approximately seconds by to cleanly fromterminate (either returning After constvrtaAction*a) vrtaErrType vrtaSendAction(vrtaDevIDid, Send an actionto virtual a device. vrtaStart() This API call causes the data in the inthe data the causes APIcall This virtual device.

vrtaSendAction() vrtaReset() entry-point of the VECU is called by the C/C++ start-up code. This start-up bythe of C/C++ the VECUiscalled entry-point vrtaStart() Input Input Input or or calling Input/Output , vrtaTerminate() , vrtaInitialize()

Description has been called the application thread is is thread allowed the has been application called is called the VM determines that it has been reset been and has reset it that determines the VM called is vrtaTerminate() that started the application thread then returns. be sent. A pointer to structurea that contains the action to should be sent. The ID of the virtual device to which the action Description Description vrtaAction and ). If the application thread does thread the application If ). vrtaStart() structurebetheto sent to . However, when 9.4

117 starts, you you starts,

OS_MAIN() . should terminate itselfas soon thread.awrapper This API is function that allows the VM to keep keep to VM the allows that function to terminate. This is normally done by done This is normally to terminate. regularly.athread If not does do this it will thread. thread. Description RTA-OSEK for PC for RTA-OSEK vrtaSendAction() vrtaSpawnThread() CreateThread() Description Description Description Description

The API callwas successful. The specified device ID is invalid. actionThe specified ID is invalid. actionThe data the provided is invalid. in RTA-OSEK for for PC RTA-OSEK Input/Output starts. starts. Input new thread. for the function The entry vrtaIsAppFinished() vrtaSpawnThread() vrtaSpawnThread()

This API call createsa new You will normally call this API during the initialization of your devices, before OS_MAIN() If you call it from within the application threadafter interrupted. be cannot it that ensure must The action callback function of the target device is called by the same is called by the same device target of the The action callback function calls that thread Windows vrtaRegisterVirtualDevice() around the Windows VECU. the in running threads of number the of track with created thread A as it discovers that the VECU is about the VECU that as it discovers polling continue running until forcibly terminated as the VECU process terminates. terminates. process VECU the as terminated forcibly until running continue Create a new void vrtaSpawnThread(void (*func)(void)) void vrtaSpawnThread(void Value Parameter Parameter Value func

RTVECUErr_NONE RTVECUErr_NONE RTVECUErr_Dev RTVECUErr_ID RTVECUErr_VAL

9.4.23 Return values: values: Return Notes: Description: Description: Notes: See also: Return values: values: Return Function declaration: Function Parameters: RTA-OSEKforGuide PC User VirtualMachine API Reference

9.4

118 Virtual Machine API Reference RTA-OSEK for RTA-OSEK PCUser Guide Virtual Machine APIReference 118 Return values: Parameters: Function declaration: Description: Notes: Notes: See also: 9.4.24 Value Value Parameter action is sentaction ApplicationManagerto the device). vrtaOSEKSupp.cpp the by is called it as explicitly Important: void vrtaStart(void) Start theapplicationthread. InitializeDevices() function application-provided the to call a by followed is This thread starts to inform them that the application thread starting. before the Reset virtualThe VMsends devicejust actionapplication a each to is sentaction ApplicationManagerto the device. Start a until started isnot thread application then the mode inslave loaded thread isstarted assoon as If theVECUhas been loaded inautostart mode (default) then the application thread. the application tostart the VM requests APIcall This vrtaLoadVM() is: ECUrunning aVirtual start to sequence APIcalls The correct of application thread or another thread calls vrtaStart() OS_MAIN() function entry-point ECU application Virtual the main Finally initialization. vrtaLeaveUninterruptibleSection() vrtaIsAppFinished(),vrtaEnterUninterruptibleSection(),

vrtaStart() if a Virtual ECU is using OSEK this API should not be called becalled not APIshould OSEKthis using ECUis Virtual if a

is called. called. is Input/Output does not return until the VM terminates (e.g. because the , vrtaInitialize()

Description that is that shouldcarry out any necessary virtual device

vrtaStart() #include Description Description main() and and d by vrtaTerminate() entry-point inthe file support is called. If the VECU has been iscalled. IftheVECUhas vrtaStart() osgen.cpp . . or a Terminate 9.4

119 ). ). , vrtaTerminate() or calling calling or vrtaLoadVM() ,

OS_MAIN() that started the application thread returns. returns. thread application the started that Description OS_MAIN() , is calleda thread is application than other by the thread Description Description

vrtaStart() vrtaReset() vrtaReset() , Input/Output

vrtaTerminate() vrtaTerminate() vrtaTerminate()

InitializeDevices() vrtaStart() This API call instructs VM the toterminate. If this API is called by the any other by called is API this If returns. never it then thread application return. does it then thread If to terminate 10 seconds allowedapplicationthenapproximately thread the is from returning by (either cleanly Ifapplication theforcibly 10 seconds itwithin does not is terminate thread terminated. to action a Reset sends VM the terminated has thread application the Once terminate. to about is VECU the that it inform to device virtual each Finally the call of Terminate the Virtual Machine. Machine. Virtual the Terminate void vrtaTerminate(void) vrtaInitialize() vrtaInitialize() Value Parameter Parameter

9.4.25 Return values: values: Return See also: See also: Notes: See also: Description: Description: Parameters: Parameters: Function declaration: Function RTA-OSEKforGuide PC User VirtualMachine API Reference

10.1

120 Standard Device Reference RTA-OSEK for RTA-OSEK PCUser Guide Standard Device Reference 120 10.1 10 10.2

Standard DeviceReference vrtaStdDevices.h Action and Event Descriptions andEvent Descriptions Action YYYY ZZZZ ID data in the action (e.g. “ For actions, ( data event or action inthe event (e.g.“ queried, events doFor that data not to input require be suppliedwhen they any are contains theIDofactionoreventThe table ( or event. table, by standard toas below, text explainfollowed purpose the of the action event or Each internal by supported action an by deviceisdescribed a IDsused devices. andevent internal action bythe The header file events they support. This chapter describes the of purpose these 3 devices the and actions and code. in your application create three standard devices which behave in just the same way as devices that you VM’s isaccessed through the Machine Virtual the theof of functionality Most automatically included if included if you include automatically enclosed in“ ZZZZ For events that do require input data to be supplied when they are queried, Refer to section 9.3 for a description of data format strings. queried). when data input value containsas singleunsignednumeric requires stringthat dataa and data required eventinput when the “ isqueried (e.g. event.in the The data second data format string describes the format of the will be a data format string followed by a second data format string format data by a second followed string format data bea will ZZZZ ZZZZ () will be a data format string describing the format of the data of the data format describing the string format be will data a ”. The first data format string describes the format of the data vrtaStdDevices.h will be a data format string describing the format of the of format the describing string format data bea will %u ZZZZ ” for a singleunsigned numeric value). %s ). ” for string data). vrtaCore.h contains definitions of the device, the of contains definitions YYYY Data Format . vrtaStdDevices.h ), and the format of the %s(%u) ”event for an is 10.3

121 for the the for . Where ’ separated list of ”. \n is an event ID in decimal. Data Format Data Format Data Format Data Format n breaks orn breaks if another EventRegister 3=1,3,6\n5=2\n7=2,3 - e.g. “ e.g. - Name

DeviceManager DeviceManager ’ separated values. The first value is the IP address of value of is the IP address values. The first ’ separated \n =,,…, is a device ID in decimaland Action: HookEvents HookEvents Action: Action: EventRegister EventRegister Action:

action is received. received. is action the listener - e.g. “192.168.0.100” or “localhost”. The second value is the the value is second The or “localhost”. -the e.g. “192.168.0.100” listener “2034”. e.g. - in decimal TCP port number to connection a network open to interface the diagnostic action causes This the specified port TCP/IP associateanda then ‘listener’ instancewith it. Each listener. such one at most have can connection diagnostic The listener is removed if the connectio used by external monitor programs. monitor external used by interface to the which events hook for diagnostic This action specifies connectionaction on which The data is received. the is a ‘ This action is only available for use via the diagnostic interface and is only and only is diagnostic interface the via use available for action is only This This action is only available for use via the diagnostic interface and is only and only is diagnostic interface the via use available for action is only This programs. monitor external used by a is string events.a The data wishing port to hook TCP/IP This action registers containing a list of ‘ The Device Manager (DM) is the internal device that manages all devices. The The devices. all manages that device internal the is (DM) Manager Device The follows:DMas is identified items of the form form the of items device with ID with ID device Such an item means hook the events with IDs with the events hook means an item Such The data forms the complete list of events to hook for the diagnostic hook forto the diagnostic list the complete ofThe data events forms rather hooked the events replace actions HookEvents Subsequent connection. will be hooked. means events list that no empty thanadd them. to An Action ID Constant Device ID Constant Action ID Constant DM_ACTION_ID_HookEvents %s DM_ACTION_ID_EventRegister %s DM_ACTION_ID_EventRegister DM_DEVICE_ID Device Manager

10.3.2 10.3.1 10.3 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Standard Device

10.3

122 Standard Device Reference RTA-OSEK for RTA-OSEK PCUser Guide Standard Device Reference 122 10.3.4 10.3.3 10.3.8 10.3.7 10.3.6 10.3.5

DM_EVENT_ID_DeviceActions %s(%s) DM_EVENT_ID_DeviceList %s DM_ACTION_ID_GetDeviceInfo %s DM_ACTION_ID_GetDeviceEvents %s DM_ACTION_ID_GetDeviceActions %s DM_ACTION_ID_ListAll Event ID Constant Constant ID Action Constant ID Action Constant ID Action Constant ID Action Event ID Constant a virtual device in the same device inthe form as usedfor list specifying the of supportedactions by is The data ‘ a Machine. is The data a ‘ data.the action This action causes the DM to raise DeviceInfoa event for the device named by by the action data. This actioncauses the DM toraise De a by the action data. This action causes the DM to raise DeviceActionsa event for the device named This causesaction the DM to raise a DeviceList event. raised in response to a GetDeviceActions action then the device is named by

Action: GetDeviceActions Action: GetDeviceActions Action: ListAll Event: DeviceActions Event: DeviceList Action: GetDeviceInfo Action: GetDeviceEvents \n \n ’ separated list of all of the devices registered with the Virtual ’ separated list of all of the the ’ of actionsseparated of by supported list all namedthe vrtaRegisterVirtualDevice() viceEvents event for the device named Data Format Data Format Data Format Data Format Data Format Data Format call. If If the event is call. 10.3

123 call. isevent the If Data Format Data Format Data Format action then the device is named by is named the device then action call. If the event is raisedtoin response vrtaRegisterVirtualDevice() ’ separated list of all of the events supported by the named the named by supported all events the list of of ’ separated \n Event: DeviceInfo DeviceInfo Event: Event: DeviceEvents DeviceEvents Event:

the action data. If the event is queried the device is named by the event input input event the by named is device the is queried event the If action data. the data. raised in to aresponse GetDeviceEvents aaction GetDeviceInfo the by the device is named action then data. If the data. input event the by is named the device is queried event the action data. If the event is queried the device is named by the event input input event the by named is device the is queried event the If action data. the data. for as used form same the in device named the about information is data The the in information device virtual specifying vrtaRegisterVirtualDevice() The data is a‘ is The data by supported list of the events specifying for as used form same device in the the in device a virtual Event ID Constant Constant Event ID Event ID Constant Constant Event ID %s(%s) DM_EVENT_ID_DeviceInfo %s(%s) DM_EVENT_ID_DeviceEvents 10.3.10 10.3.9 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Standard Device

10.4

124 Standard Device Reference RTA-OSEK for RTA-OSEK PCUser Guide Standard Device Reference 124 10.4 10.4.1

Interrupt Control Unit ICU_ACTION_ID_Raise %d:;1;32 ICU_DEVICE_ID Action ID Constant ID Action Constant ID Device interrupt’s pending flag). This makesaction the specified interrupt number pending (i.e. sets the The ICUisidentified as follows: current IPL is zero. interrupts the(disabled) aremaskedECU and starts all Virtual When the interrupt vector number is handled first. If two interrupts of the same priority are pending then the one with the lower handler. interrupt lower priority pre-empt handler a can interrupt priority A higher ends. the first as soon as run will handler interrupt the of instance second pendinga and again become will the interrupt interrupt same the interru handler foran if the Therefore pending just before is cleared its handlerflag is invoked.An interrupt’s interrupt. be not invoked IPLdrops will thehandler until ofthe priority the below the current IPL is higher or equal to the priority of the interrupt then its beinvoked is interrupt not until unmasked. the If interrupt ispendingbut an pending handler is but its will is masked If IPL. an interrupt the current than unmasked pending priority hashighest and interrupt that highera priority a Raise action to the ICU.The ICUin An interrupt ispending pending its (i.e. made is (enabled). flag byset) sending Each interrupt pending has a bemay and flag masked or unmasked (disabled) code isinterrupt running currentthe IPLis zero. non If corresponding of the interrupt. the priority to IPLisequal current the range zero to 32inclusive. If interrupt an handler is running then the is a numberThis in level(IPL). priority interrupt the current The ICUmaintains vector table. entry. See the The priority of interruptan is setin the corresponding interrupt vector table vector n. number interrupt32 hasEach 1to inthe priority range inclusive. a number Interrupt 1tonumbered 32 n inclusive. corresponds interrupt to There 32 controller. are interrupts interrupt a The ICUimplements multilevel thread. application the within beinvoked to handlers interrupt Machinefor arranges and Virtual the within The Interrupt Control Unit (ICU) is the internal device that manages interrupts

Action: Raise vrtaInitialize() ICU

Name Name call for descriptiona of the interrupt ptsends RaiseICU action to thefor a vokes the interrupt handler for the Data Format 10.4

125 Data Format Data Format Data Format Data Format Data Format Data Format Data Format Data Format Action: GetIPL Action: SetIPL Action: GetPending Action: Mask Action: Unmask Action: Clear Action:

This action sets the IPL to the specified value. value. specified the to IPL the sets action This This action causes aThis action to Pending causes raised. be event raised. be to event an IPL action causes This This action masks (disables) the specified interrupt number. number. interrupt specified the (disables) masks action This number. interrupt specified the (enables) unmasks action This This action clears the specified interrupt number’s pending flag. Note that it is interruptpending flag. specified This action clears the that Note number’s it clear to handler interrupt an in ICU the to action this send to necessary not the an pending flag of the pending interrupt’s being handled since interrupt flagclearedits is just before handler is invoked. Action ID Constant Action ID Constant Action ID Constant Action ID Constant Action ID Constant Action ID Constant ICU_ACTION_ID_SetIPL %d:;0;32 ICU_ACTION_ID_GetPending ICU_ACTION_ID_GetIPL %d:;1;32 ICU_ACTION_ID_Unmask ICU_ACTION_ID_Clear %d:;1;32 ICU_ACTION_ID_Clear %d:;1;32 ICU_ACTION_ID_Mask

10.4.7 10.4.6 10.4.5 10.4.4 10.4.3 10.4.2 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Standard Device

10.4

126 Standard Device Reference RTA-OSEK for RTA-OSEK PCUser Guide Standard Device Reference 126 10.4.8 10.4.12 10.4.11 10.4.10 10.4.9 ICU_EVENT_ID_MASKS %b ICU_EVENT_ID_IPL %d ICU_EVENT_ID_Stop %d ICU_EVENT_ID_Start %d ICU_EVENT_ID_Pending %b Event ID Constant Event ID Constant Event ID Constant Event ID Constant Event ID Constant The event is raised when the listof enabled interrupts changes. bit). significant least Bit n is setin the event if interrupt number n is enabled (where bit 1 is the interrupts. enabled currently the (unmasked) of all of list contains This event a action or when the current IPL changes. This event contains the current IPL. The event is raised inresponse to GetIPLa the interrupt is specified in the event data. inte an after just raised is event This the interrupt is specified in the event data. This eventis just beforeraised an in pending interrupts changes. in response a to is raised event The bit). significant in the event if interrupt number n is pending(where bit 1 is the least This event contains lista of all of the currently pending interrupts. Bit n is set

Event: EnabledVecs Event: IPL Event: Stop Event: Pending Event: Start terrupt handler isinvoked. The number of rrupt handler handler Thenumber rrupt has ended. of GetPending or whenaction the list of Data Format Data Format Data Format Data Format Data Format 10.5

127 Data Format Data Format Data Format Data Format Data Format Data Format suspend execution suspend the applicationof Name

ApplicationManager call. mode. mode. slave Action: Restart Action: Pause Action: Start Action: Terminate

This action tells the Virtual Machine to restart execution of the application application the of execution restart to Machine Virtual the tells action This suspended. been previously after has it thread This action tells the Virtual Machine to thread. This action starts the application thread running in a Virtual ECU that was was that ECU a Virtual in running thread application the starts action This loaded in the as effect same the has It terminate. to Machine Virtual the tells action This vrtaTerminate() The Application Manager (AM) is the internal device that manages the Virtual Virtual the manages that device internal the is (AM) Manager Application The ECU application follows: as is identified The AM Action ID Constant Action ID Constant Action ID Constant Device ID Constant Action ID Constant AM_ACTION_ID_Restart AM_ACTION_ID_Pause AM_ACTION_ID_Start AM_ACTION_ID_Start AM_ACTION_ID_Terminate AM_DEVICE_ID Application Manager

10.5.4 10.5.3 10.5.2 10.5.1 10.5 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Standard Device

10.5

128 Standard Device Reference RTA-OSEK for RTA-OSEK PCUser Guide Standard Device Reference 128 10.5.6 10.5.5 10.5.10 10.5.9 10.5.8 10.5.7

AM_EVENT_ID_Started AM_ACTION_ID_ReadParam %u AM_ACTION_ID_ReadOption %s AM_ACTION_ID_TestOption %s AM_ACTION_ID_GetInfo AM_ACTION_ID_Reset Action ID Constant ID Action Constant ID Action Constant ID Action Constant ID Action Constant ID Action Event ID Constant This event is raised to indicate that so on. executable second isnumber name) zero, the parameter isnumber one, and the specified command-line parameter. The first command line parameter (the of text causes ParamText event full This action beraised the to containing a the command-line option that starts with the specified string. causes This action OptionTextan event to option exists. Thecommand-line option prefix or (‘-‘ isnot specified. ‘/’) This action causes Optionan event to be raised to signal if the named This causesaction Infoan event to be raised. vrtaReset() This action tells the Virtual Machine to reset. It has the same effect as the

Event: Started Action: GetInfo Action: Reset Action: ReadParam Action: ReadOption Action: TestOption call. call. theapplicationthreadhas started. be raised containing the full text of text full the beraised containing Data Format Data Format Data Format Data Format Data Format Data Format 10.5

129 Data Format Data Format Data Format Data Format Data Format Data Format Data Format Data Format the named option is present the on the named e application thread has been restarted. restarted. been has e application thread Event: Option Event: Event: Terminated Terminated Event: Info Event: Event: Reset Reset Event: Event: Paused Paused Event: Restarted Event:

command line or zero if it is not. If the raised event is in response a to is event the If data. action the in named is option the then action TestOption (‘-‘ or prefix option The inputthe data. in named is the option queried then name. the in included not is ‘/’) This event contains the number 1 if the This event contains This event is raised to indicate that the Virtual Machine is about to terminate. terminate. to about is Machine Virtual the that indicate to raised is event This informationaboutVirtualversion and thecontains application ECU This event Machine. the Virtual This event is raised to indicate that the Virtual ECU has been reset. reset. has been ECU the Virtual that to indicate raised is This event This event is raised to indicate that the application thread has been been has thread application the that indicate to raised is event This suspended. th that to indicate raised is This event Event ID Constant Constant Event ID Event ID Constant Constant Event ID Event ID Constant Constant Event ID Constant Event ID Event ID Constant Constant Event ID Constant Event ID AM_EVENT_ID_Option %u(%s) AM_EVENT_ID_Terminated AM_EVENT_ID_Terminated AM_EVENT_ID_Info %s AM_EVENT_ID_Reset AM_EVENT_ID_Paused AM_EVENT_ID_Paused AM_EVENT_ID_Restarted

10.5.16 10.5.15 10.5.14 10.5.13 10.5.12 10.5.11 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Standard Device

10.5

130 Standard Device Reference RTA-OSEK for RTA-OSEK PCUser Guide Standard Device Reference 130 10.5.17 10.5.19 10.5.18

AM_EVENT_ID_State AM_EVENT_ID_ParamText %s(%u) AM_EVENT_ID_OptionText %s(%s) Event ID Constant Event ID Constant Event ID Constant This event contains the current state of the Virtual ECU. If the eventdata. is queried then the parameter number isin data. the input parameter the ReadParam action response then number isinthe to action a exist eventdoes not the empt the contains isnumberparameter one, soon. and If the specified lineparameter command first command line parameter (the executable name) is zero, the second This event contains the full textof the specified command-line parameter. The data. Ifaction the event is queried then the prefix is data. the input the event is inresponseraised to a Re option. ofthe text eventIf contains the full then doesexist the prefix specified the specified prefix does not exist. If commanda line option starting with the containsThis event empty an commandstring if with starting a lineoptions

Event: OptionText Event: State Event: ParamText adOption adOption action then the prefix is the y string. Iftheevent in israised Resetting Terminating| Paused| Running| Loaded| Data Format Data Format Data Format 11.1

131 . All of the base class (see the file (see the file base class A clock source for counter counter for source clock A devices. upwards. that counts A counter that counts A counter downwards. sensor. A generic switch. “toggle” A two position A multi-position switch. actuator. A generic off. or on canA light be that to set canA light be that different levels of brightness. to set canA light be that colors. different A comparatorthat can generate another other when an interrupt device reaches a specified value. An I/O space. as clocks, counters, comparators, as comparators, counters, clocks, vrtaDevice vrtaSampleDevices.h and and includes a includes collectionsample of virtual devices that ). RTA-OSEK for PC RTA-OSEK for devices such implement used commonly virtual the C++ from) derived are (i.e. of use make devices virtual sample by thedevice framework provided vrtaDevice.h provided: are devices sample The following vrtaClock actuators and sensors. These are contained in the files files the in contained are These sensors. and actuators vrtaSampleDevices.cpp vrtaUpCounter vrtaDownCounter vrtaSensor vrtaSensorToggleSwitch vrtaSensorMultiwaySwitch vrtaActuator vrtaActuatorLight vrtaActuatorDimmableLight vrtaActuatorMultiColorLig ht vrtaCompare vrtaIO Summary Sample Device Reference Reference Device Sample

11.1 11 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.2

132 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 132 11.2

Compiling the Sample Devices Devices Sample the Compiling osgen.cpp preprocessor macro automatically RTA-OSEK application, creating an youare If if you application want to use of devices. the any sample You must and linkthecompile file . #include VRTA_EXCLUDE_SAMPLE_DEVICES d within d within vrtaSampleDevices.cpp osgen.cpp vrtaSampleDevices.cpp unlessyoudefine the when compiling compiling when with your is is 11.3

133 ), and the XXXX Description Description ). ). YYYY ID of the action or event ( or event action the ID of Input/Output Input/Output Description. Description Description Description of return value. value. return of Description

. Data Format Data Format Actions and Events and Events Actions Methods

Explanation of the functionality of the method.functionalitythe the Explanation of of The table the contains numeric Each action or event supported by a sample device is described by a standard a is described by a standard sampleaction device by supported Each or event table, as below, followed by text to the explain purpose the actionof or event. ( data event or action the of format Each sample device is described in the same way. The description starts with with starts way. The description same the in is described device Each sample is followedthe device. This and operation of purpose an the to introduction and then the device class by exported methods of theby a C++ description device. the by supported and events actions the as follows: form standard a in described is method C++ Each method is provided. the A brief description of C++ syntax. in Interface ID ID Value Parameter Parameter XXXX YYYY Return values Parameter Name Device Descriptions Descriptions Device

11.3.2 11.3.1 Description: Description: values: Return The title gives the name of the method. method. the of the name gives The title Method declaration: Parameters: 11.3 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.4

134 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 134 11.4 Parameters: Method declaration: Description: Return values: 11.4.2 11.4.1

vrtaClock interval name Parameter Value Value mult interval Multiplecounters maybe attached to thesame mult /div) interval (set in the constructor or with the clock tick Ifthe divisor. and a a has multiplier factor The scaling factor. scaling calculated by multiplying the by the multiplying calculated A 1ticks. millisecond ofvery-close-to source to provide a timer multi-media vrtaDownCounter Set the tickinterval. vrtaClock(const vrtaTextPtrname,unsignedinterval) The constructor. dependingdone onyourautomatically compiler.) (This be might library. need to belinked will thewith Windows multi-media Important: A This is the constructor used to create an instance of a

Method: SetInterval() Method: vrtaClock() vrtaClock vrtaClock / div , and the scaling factor (set with the if using a a using if , then an , thenan attached counte device ticks an attached counter every milliseconds. By default the scale factor is 1 scale the By is default /1. factor milliseconds. device provides timea source for

Description counter devices. A counter vrtaClock Input The number of milliseconds in of Thenumber milliseconds Thename of the device. virtual Input Input Input/Output Input/Output vrtaClock device in a VECU,theVECUexecutable deviceina r wouldbetickedevery vrtaClock device’s clock tick interval by its SetInterval() vrtaClock one clock tick. Description SetScale() vrtaClock device uses a Windows deviceuses a vrtaUpCounter T milliseconds. milliseconds. device. (interval* method) is method) is device. and and T is 11.4

135 Description Description Description Description one clock tick. tick. one clock factor. Input/Output Input/Output Input milliseconds The number of in Input Input The multiplier scaling for the factor. scaling the for The divisor Description Description Description Description

Method: Start() Method: SetScale()

void SetInterval(unsigned interval) void SetInterval(unsigned This method sets the scaling factor for the clock. clock. the for factor scaling the sets method This This method is used to change the number of milliseconds in one clock tick.clock milliseconds one of number in the to change isThis used method Start the clock ticking. Start void Start(void) Set the scaling factor. Set the scaling factor. unsigned div) void SetScale(unsigned mult, Value Parameter Parameter Value Parameter Parameter mult div interval 11.4.4 11.4.3 Parameters: Parameters: Method declaration: declaration: Method Return values: values: Return Description: Description: Return values: values: Return Description: Description: Method declaration: Method declaration: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.4

136 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 136 Parameters: Method declaration: Return values: Description: Return values: Description: Parameters: 11.4.6 11.4.5

1 %u Value Value Parameter Value Parameter Action ID ID Action SetInterval() the to equivalent is This action tick. clock ina milliseconds of number the in The a clock the tick. number data ofmilliseconds sets is action This action void Stop(void) clockticking. the Stop Thismethod stops the clockdevice ticking any attachedcounters. This method starts the clock device ticking any attached counters.

Action: Interval Method: Stop() Data Format method.

Description Description

Input/Output Input/Output Input/Output Input/Output Description Description 11.4

137 ce’s tick interval changes. The event event The changes. interval tick ce’s method. method. ce’s scaling factor changes. The event arted or stopped. The event data is 1 if The event arted or stopped. method. SetScale() method. method. Start() Stop() Data Format Data Format Data Format Data Format Data Format Data Format Data Format Data Format Data Format Data Format Event: Running Event: Event: Interval Interval Event: Scale Event: Action: Start Action: Stop Action: Scale Scale Action:

This event is raised when the clock devi when raised This event is datascalingfactor new is the multiplier followed the new divisor. by the clock is st This event is raised when This event is raised when the clock devi when raised This event is now is not clock zero the if started) or (i.e.running been has is now the clock stopped).running been (i.e. has This action stops the clock device ticking any attached actioncounters. is This the to equivalent interval. tick new the is data This action sets the device’s scaling factor. The first number in the action data data action the in number first The factor. scaling device’s the sets action This This divisor. is the number multiplierand second scaling the factor is the action the equivalent to is action is attached counters. This device ticking any theThis action clock starts the to equivalent Event ID Event ID Event ID Action ID Action ID Action ID 3 %u:;0;1 1 %u 2 %u,%u 4 2 %u,%u 2 %u,%u 3

11.4.12 11.4.11 11.4.10 11.4.9 11.4.8 11.4.7 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.5

138 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 138 11.5 Parameters: Method declaration: Description: Return values: 11.5.1

vrtaUpCounter vrtaUpCounter clock name Value Value Parameter cyclic period of a maximum value then its current value is set back to its minimum value. The When the th value maximum its than less is value a device. It has a minimum value, a maxi vrtaUpCounter(const vrtaTextPtrname,vrtaClock&clock) The constructor. theandcurrent value starts atzero. By default the minimum value is zero, the maximum value is 4294967295, A This is the constructor used to create instancean of a device.

vrtaUpCounter Method: vrtaUpCounter() vrtaUpCounter vrtaUpCounter vrtaUpCounter

device is ticked by a Description is a counter devicethata is by driven is a nu Thename of the device. virtual Input Input Input/Output Input/Output is ticked and its current value is equal its equal to is value current its ticked and is is thus (maximum – minimum) + 1. mum value and a current value. Whenvalue. current and a value mum en its current is value incremented. vrtaClock be used to drive the counter. The Description vrtaClock device itsand current vrtaUpCounter device that will that device vrtaClock

11.5

139 Description Description Description Description Input/Output Input/Output

Description Description Description Description The maximum value of the counter. counter. value the The maximum of The minimum value of the counter. The minimum valuecounter. of the Method: Max() Method: Min() Method: Min()

This method is used to get the maximum value of the counter. counter. the of value maximum the get to used is method This This method is used to get the minimum value of the counter. counter. the of value minimum the get to used is method This Get the maximum value. value. maximum the Get unsigned Max(void) Get the minimum value. value. minimum the Get unsigned Min(void) Value Parameter Parameter Value Parameter Parameter 11.5.3 11.5.2 Description: Description: values: Return Description: Description: values: Return Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.5

140 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 140 Parameters: Method declaration: Parameters: Method declaration: Return values: Description: Return values: Description: 11.5.4 11.5.5 v Parameter Value Parameter Value Value void SetMin(unsignedv) Set the minimum value. unsigned Value(void) Get the current value. This method is used to get the current value of the counter. value is set to the new minimum value. value of the counter is smaller than the new minimum value then the current isThis method used to set the valueminimum of the counter. If the current

Method: Value() Method: SetMin() of counter. the current value The Description Description Input The new minimum value for the Thenew value for minimum Input Input/Output Input/Output Input/Output Input/Output counter. counter. Description Description 11.5

141 Description Description Description Description counter. Input/Output Input/Output Input The new maximum value for the Input counter. the for value The new Description Description Description Description

Method: SetVal() Method: SetVal() Method: SetMax() Method:

This method is used to set the current value of the counter. If the new current counter. Ifthe current the value new This method of the to current set is used the than greater or value minimum the than smaller is counter the of value value. minimum the to set is value current the then value maximum This method is used to the the set maximum value counter. of If the current current the then value maximum new the than greater is counter the of value value. minimum the to set is value Set the current Set the current value. void SetVal(unsigned v) Set the maximum value. value. maximum Set the v) void SetMax(unsigned Value Parameter Parameter Value Parameter Parameter v v 11.5.7 11.5.6 Description: Description: values: Return Description: Description: values: Return Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.5

142 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 142 Parameters: Method declaration: Parameters: Method declaration: Description: Return values: Description: Return values: 11.5.8 11.5.9 Parameter Value Parameter Value Value void Start(void) counting. counter the Start void Stop(void) counting. counter the Stop attached This method is used to start the counter counting when ticked by the vrtaClock This method isused to stop counter the counting when byticked the attached

Method: Start() Method: Stop() vrtaClock device.

Description Description device.

Input/Output Input/Output Input/Output Input/Output Description Description 11.5

143 method. method. Start() method. Stop() device. It is the equivalent of the the of equivalent the is It device. device. It is the equivalent of the the of equivalent the is It device. Data Format Data Format Data Format Data Format Data Format Data Format Data Format Data Format Data Format Data Format method. method. method. vrtaClock Action: Report Action: Start Action: Stop Action: Set Action: Minimum Action: Action: Maximum

This method is used to stop the counter counting when ticked by the attached attached the ticked by when counting the counter stop to is used This method vrtaClock abe raised. to This action Set event causes This method is used to start the counter counting when ticked by the the by ticked when counting counter the start to used is method This attached This action sets the current value of the counter. It is the equivalent of the the of equivalent the is It counter. the of value current the sets action This SetVal() This action sets the minimum value of the counter. It is the equivalent of the the of equivalent the is It counter. the of value minimum the sets action This SetMin() the of equivalent the is It counter. the of value maximum the sets action This SetMax() Action ID Action ID Action ID Action ID Action ID Action ID 6 4 5 3 %u 1 %u 2 %u

11.5.15 11.5.14 11.5.13 11.5.12 11.5.11 11.5.10 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.5

144 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 144 11.5.16

1 %u Event ID Event ID a Report action. inresponse to counter. israised the It contains current of This event the value

Event: Set Data Format 11.6

145

vrtaClock device thatwill device and its vrtaDownCounter is thus (maximum – vrtaClock vrtaClock Description Description The counter. the drive to be used is ticked and its current value is mum mum value a and current value. When vrtaDownCounter Input/Output Input Input virtual device. the of The name vrtaDownCounter device is ticked by a a by ticked is device is a counter device that is driven by a driventhat is by is a device counter Description Description

vrtaDownCounter vrtaDownCounter Method: vrtaDownCounter() Method: vrtaDownCounter()

current value is greater than its minimum value then its current value is is value current its then value minimum its than greater is value current When the decremented. maximum its to set back is value current its then value minimum its to equal ofa period value. The cyclic 1. + minimum) 4294967295, is value maximum the zero, is value minimum the default By at zero. starts value current and the device. It has a minimum value, a maxia value, a minimum has It device. a This is the constructor used to create an instance of a of an instance create to used constructor the is This device. device. The constructor. The constructor. name, vrtaDownCounter(const vrtaTextPtr vrtaClock &clock) A Value Parameter Parameter name clock

vrtaDownCounter

11.6.1 Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: 11.6 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.6

146 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 146 Parameters: Method declaration: Parameters: Method declaration: Return values: Description: Return values: Description: 11.6.2 11.6.4 11.6.3 Parameter Value Parameter Value Value Get the current value. unsigned Max(void) Get the maximum value. unsigned Min(void) Get the minimum value. This method is used to get the minimum value of the counter. This method is used to get the maximum value of the counter.

Method: Min() Method: Value() Method: Max() The maximum value ofThe maximum the value counter. ofthecounter.value The minimum Description Description

Input/Output Input/Output Input/Output Input/Output Description Description 11.6

147 Description Description Description Description counter. Input/Output Input/Output Input minimum for value The new the Description Description Description Description

The value current the counter. of Method: SetMin()

unsigned Value(void) unsigned Value(void) This method is used to set the minimum value of the counter. If the current current the If counter. the of minimum value the set to used This method is current the then value minimum new the than smaller is counter the of value value. minimum new the to set is value This method is used to get the current value of the counter. counter. the of value current the get to used is method This Set the minimum value. value. minimum Set the void SetMin(unsigned v) Value Parameter Parameter Parameter Parameter Value v 11.6.5 Parameters: Parameters: Method declaration: declaration: Method Return values: values: Return Description: Description: Return values: values: Return Description: Description: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.6

148 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 148 Parameters: Method declaration: Parameters: Method declaration: Return values: Description: Return values: Description: 11.6.6 11.6.7 v v Parameter Value Parameter Value Value void SetVal(unsignedv) value.Set thecurrent void SetMax(unsignedv) Set the maximumvalue. value is set to the minimum value. value of the counter is greater than the new maximum value then the current current the If of counter. value maximum set the the isusedto This method maximumvalue thenthe current valueisset to the minimumvalue. value of the counter is smaller than the minimum value or greater than the isused set current to the of This method new value the currentthe If counter.

Method: SetMax() Method: SetVal()

Description Description nu Thenew value for the counter. Input the for value maximum new The Input Input/Output Input/Output Input/Output Input/Output counter. counter. Description Description 11.6

149 Description Description Description Description Input/Output Input/Output

device. device. Description Description Description Description

device. device. vrtaClock Method: Stop() Method: Start() Method:

This method is used to stop the counter counting when ticked by the attached attached the ticked by when counting the counter stop to is used This method vrtaClock This method is used to start the counter counting when ticked by the the by ticked when counting counter the start to used is method This attached Stop the counter counting. void Stop(void) Start the counter counting. void Start(void) Value Parameter Parameter Value Parameter Parameter 11.6.9 11.6.8 Return values: values: Return Description: Description: Return values: values: Return Description: Description: Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.6

150 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 150 11.6.11 11.6.10 11.6.15 11.6.14 11.6.13 11.6.12 6 5 4 3 %u 2 %u 1 %u Action ID ID Action ID Action ID Action ID Action ID Action Action ID ID Action This action causesevent Set This action to be raised. a vrtaClock This method isused to stop counter the counting when byticked the attached attached This method is used to start the counter counting when ticked by the SetVal() This action sets the current value of the counter. It is the equivalent of the SetMax() This action sets the maximum value of the counter. It is the equivalent of the SetMin() This action sets the minimum value of the counter. It is the equivalent of the

Action: Maximum Action: Minimum Action: Report Action: Stop Action: Start Action: Set vrtaClock method. method. method. method. Data Format Data Format Data Format Data Format Data Format Data Format device. It is the equivalent of the device. It is the of equivalent the Stop() method. method. Start() method. 11.6

151 Data Format Data Format Event: Set Event:

This event contains the current value theThis event of current contains It the is raised counter. to in response action. a Report Event ID 1 %u

11.6.16 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.7

152 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 152 11.7 Parameters: Method declaration: Parameters: Method declaration: Description: Return values: 11.7.2 11.7.1

vrtaSensor Name Value Value Parameter Parameter unsigned GetMax(void) Get the maximum value. vrtaSensor(const vrtaTextPtrname) The constructor. vrtaSensor application. beread by to onesource, input from then the an stores thatallows input and A This is the constructor used to create an instance of a 4294967295. When sensora is created the current value is zero theand maximum value is Events areraisedwhenever thecurr sensor can be set to valuea between zero theand maximum value inclusive. A sensorhas current value a maximum value.a and Thecurrent ofthe value represent more specialized sensors. vrtaSensorMultiwaySwitch

Method: GetMax() Method: vrtaSensor() vrtaSensor represents a generic represents a sensor; device models a sensor. That is, device a takeswhich input

Description Thename of the device. virtual Input Input/Output Input/Output Input/Output are derived are from ent value or maximum value changes. changes. value maximum or value ent vrtaSensorToggleSwitch Description Description vrtaSensor vrtaSensor device. and and 11.7

153 Description Description Description Description sensor. sensor. Input/Output Input/Output Input The new maximum value for the

Description Description Description Description The current value of the sensor. value the sensor. The of current The maximum value of the sensor. sensor. value the of The maximum Method: SetMax() Method: Value() Method: Value()

This method is used to get the maximum value of the sensor. sensor. the of value maximum the get to used is method This This method is used to set the maximum value of the sensor. If the current current the If sensor. the of value maximum the set to used is method This current the then value maximum new the than greater is sensor the of value valueset is to zero. This method is used to get the current value of the sensor. sensor. the of value current the get to used is method This Set the maximum value. value. maximum Set the void SetMax(unsigned v) Get the current value. value. current Get the unsigned Value(void) Parameter Parameter Value Parameter Parameter Value V 11.7.4 11.7.3 Return values: values: Return Description: Description: Description: Description: Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.7

154 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 154 Parameters: Method declaration: Return values: Description: Return values: 11.7.5 11.7.7 11.7.6

2 %u 1 %u v Action ID ID Action Value Parameter Value Action ID ID Action SetMax() This action sets the maximum value of the sensor. It is the equivalent of the SetVal() setsThis action thecurrent ofthe value sensor. ofthe Itistheequivalent void SetVal(unsignedv) value.Set thecurrent is not set. value of the sensor is greater than the maximum value then the current value isThis method used to set the current ofvalue the sensor. If the new current

Method: SetVal() Action: Maximum Action: Value method. method. method. Data Format Data Format

Description Description nu Thenew value for the sensor. Input Input/Output Input/Output Description 11.7

155 the sensor. It is raised whenever It is raised whenever the sensor. Data Format Data Format Data Format Event: Maximum Maximum Event: Event: Value Value Event:

the maximum value of the sensor changes. changes. sensor the of value maximum the This event contains the maximum value of maximum the This event contains This event contains the current the value of the sensor. It is raised whenever the current This contains event changes. sensor the value of Event ID Event ID 1 %u 2 %u 11.7.9 11.7.8 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.8

156 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 156 11.8 Parameters: Method declaration: Parameters: Method declaration: Description: Description: Return values: 11.8.1 11.8.2

vrtaSensorToggleSwitch vrtaSensorToggleSwitch name Value Value Parameter Parameter unsigned Value(void) Get the current value. vrtaSensorToggleSwitch(const vrtaTextPtrname) The constructor. When a possible two zerovalues, one,correspondingand to “off” “on”. and A vrtaSensorToggleSwitch This istheconstructor used tocreate instance of an a This method is used to get the current value of the sensor.

Method: vrtaSensorToggleSwitch() Method: Value() vrtaSensorToggleSwitch vrtaSensorToggleSwitch

Description Thename of the device. virtual Input Input/Output Input/Output Input/Output Input/Output device. is a special form of a sensor that has only only has that sensor of a form special a is is created its current value is zero. zero. is value current its created is Description Description 11.8

157 Description Description Input/Output Input sensor. the for value The new Description Description Description Description

The current value of the sensor. value the sensor. of The current method. method. Data Format Data Format Data Format Data Format SetVal() Action: Position Position Event: Method: SetVal() Method: SetVal()

This method is used to set the current value of the sensor. If the new current new current the If sensor. the value of current the set to used This method is set. not is value current the then 1 than greater is sensor the of value This eventcurrent contains the value (position)of the sensor. Itraised is changes. sensor the of value the whenever This actionThis setsthe current value (position) sensor. the of Itthe is equivalent of the Set the current Set the current value. void SetVal(unsigned v) Event ID Action ID Parameter Parameter Value Value 1 %u:;0;1 1 %u:;0;1 v

11.8.5 11.8.4 11.8.3 Return values: values: Return Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.9

158 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 158 11.9 Parameters: Method declaration: Parameters: Method declaration: Return values: Description: 11.9.1 11.9.2

vrtaSensorMul ways name Value Value Parameter Parameter unsigned GetMax(void) Get the maximum value. unsignedways) vrtaSensorMultiwaySwitch(const vrtaTextPtrname, The constructor. When a ispositions set when the device is created (but can be changed later). of Thenumber possiblepositions. of number switch with a a represents A range zeroto vrtaSensorMultiwaySwitch This istheconstructor used tocreate instance of an a

Method: vrtaSensorMultiwaySwitch() Method: GetMax() vrtaSensorMultiwaySwitch vrtaSensorMultiwaySwitch ways tiwaySwitch inclusive. inclusive.

Description positions of the Thenumber Thename of the device. virtual Input Input Input/Output Input/Output Input/Output Input/Output device. The sensor may have in a value the is a special is a form of sensora that is created its current value is zero. is zero. value current its created is switch may take minus 1. minus take may switch Description Description 11.9

159 Description Description Description Description sensor. sensor. Input/Output Input/Output Input The new maximum value for the

argument used in the constructor). If the current value value current the If constructor). the in used argument Description Description Description Description The current value of the sensor. value the sensor. The of current The maximum value of the sensor. sensor. value the of The maximum ways Method: SetMax() Method: Value() Method: Value()

This method is used to get the maximum value of the sensor. sensor. the of value maximum the get to used is method This This method is used to set the maximum value of the sensor (i.e. to override override to (i.e. sensor the of value maximum the set to used is method This the the value of is value current the then value maximum new the than greater is sensor the of zero. set to This method is used to get the current value of the sensor. sensor. the of value current the get to used is method This Set the maximum value. value. maximum Set the void SetMax(unsigned v) Get the current value. value. current Get the unsigned Value(void) Parameter Parameter Value Parameter Parameter Value v 11.9.4 11.9.3 Return values: values: Return Description: Description: Description: Description: Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.9

160 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 160 Parameters: Method declaration: Return values: Description: Return values: 11.9.5 11.9.7 11.9.6

2 %u 1 %u v Action ID ID Action Value Parameter Value Action ID ID Action SetMax() This action sets the maximum value of the sensor. It is the equivalent of the SetVal() setsThis action thecurrent ofthe value sensor. ofthe Itistheequivalent void SetVal(unsignedv) value.Set thecurrent is not set. value of the sensor is greater than the maximum value then the current value isThis method used to set the current ofvalue the sensor. If the new current

Method: SetVal() Action: Maximum Action: Value method. method. method. Data Format Data Format

Description Description nu Thenew value for the sensor. Input Input/Output Input/Output Description 11.9

161 the sensor. It is raised whenever It is raised whenever the sensor. Data Format Data Format Data Format Event: Maximum Maximum Event: Event: Value Value Event:

This event contains the current the value of the sensor. It is raised whenever the current This contains event changes. sensor the value of value of maximum the This event contains changes. sensor the of value maximum the Event ID Event ID 1 %u 2 %u

11.9.9 11.9.8 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.10

162 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 162 11.10 Method declaration: Parameters: Method declaration: Return values: Description: 11.10.2 11.10.1

vrtaActuator name Value Value Parameter unsigned GetMax(void) Get the maximum value. vrtaActuator(const vrtaTextPtrname) The constructor. 4294967295. is When an actuator iscreated thecurrent iszero value the and maximum value changes. raisedinclusive. Events whenever are the actuator can be set valueto a between zero the and maximum value An actuator has currenta value and a represent more specialized actuators. vrtaActuatorMultiColorLight vrtaActuatorLight, vrtaActuatorDimmableLight the ECU. setvalue by then signalsapplication an and that value entitiesto outside of A This is the constructor used to create an instance of a

Method: GetMax() Method: vrtaActuator() vrtaActuator vrtaActuator device models an actuator. That is, a device which has its

Description nu Thename of the device. virtual Input Input/Output Input/Output represents generica actuator; are derived are from the current value or maximum value maximumThe current of value value. Description vrtaActuator vrtaActuator and device. and 11.10

163 Description Description Description Description Description Description actuator. actuator. Input/Output Input/Output Input/Output Input The new maximum value for the

Description Description Description Description The current value of the actuator. the actuator. value of The current The maximum value of the actuator. actuator. the value of The maximum Method: SetMax() Method: Value()

This method is used to get the current value of the actuator. actuator. the of value current the get to used is method This This method is used to get the maximum value of the actuator. actuator. the of value maximum the get to used is method This Set the maximum value. value. maximum Set the void SetMax(unsigned v) Get the current value. value. current Get the unsigned Value(void) Parameter Parameter Value Parameter Parameter Parameter Parameter Value V

11.10.4 11.10.3 Parameters: Parameters: Description: Description: values: Return Return values: values: Return Description: Description: Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.10

164 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 164 Parameters: Method declaration: Return values: Description: Return values: Description: 11.10.5 11.10.7 11.10.6 2 %u 1 %u v Action ID ID Action Value Parameter Value Action ID ID Action SetMax() This action sets the maximum value of the actuator. It is the equivalent of the SetVal() This action sets the current value of th void SetVal(unsignedv) value.Set thecurrent current value is not set. currentvalue of the actuatorgreateris than themaximum valuethenthe new current the of isusedto actuator. the If value the set This method value is set to zero. zero. to is set value value of the actuator is greater than the new maximum value then the current This method is used to set the maximum ofvalue the If theactuator. current

Method: SetVal() Action: Maximum Action: Value method. method. method. Data Format Data Format

Description Description Input The new value for the actuator. the actuator. for new value The Input Input/Output Input/Output e actuator. Itisthe equivalent of the Description 11.10

165 Data Format Data Format Data Format Event: Value Value Event: Maximum Event:

This event contains the current value of the actuator. It is raised whenever the the whenever raised It is actuator. the value of current the contains This event changes. actuator the of value whenever raised is It actuator. the value of maximum the contains This event changes. actuator the of value maximum the Event ID Event ID 1 %u 2 %u

11.10.9 11.10.8 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.11

166 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 166 11.11 Parameters: Method declaration: Parameters: Method declaration: Description: Description: Return values: 11.11.1 11.11.2

vrtaActuatorLight name Value Value Parameter Parameter When a representing “off” “on”.and unsigned Value(void) Get the current value. vrtaActuatorLight(const vrtaTextPtrname) The constructor. A light. A This is the constructor used to create an instance of a This method is used to get the current value of the actuator. device.

Method: vrtaActuatorLight() Method: Value() vrtaActuatorLight vrtaActuatorLight vrtaActuatorLight

Description is speciala form of an actuator that represents a Thename of the device. virtual Input Input/Output Input/Output Input/Output Input/Output is created its current value is zero. is zero. value its current created is has two possible values zero two possible one, values has and Description Description vrtaActuatorLight

11.11

167 Description Description e actuator. It is the equivalent of the the of equivalent It is the actuator. e Input/Output Input The valuenew for actuator.the Description Description Description Description

The current value of the actuator. the actuator. value of The current Data Format Data Format Data Format Data Format method. Event: Value Value Event: Action: Value Method: SetVal() Method: SetVal()

This methodset the value If the actuator. is used to of the current new not is value current the then 1 than greater is actuator the of value current set. This event contains the current value of the actuator. It is raised whenever the the whenever raised It is actuator. the value of current the contains This event changes. actuator the of value This action sets the current value of th of value current the sets action This SetVal() Set the current Set the current value. void SetVal(unsigned v) Event ID Value Action ID Parameter Parameter Value 1 %u 1 %u v

11.11.5 11.11.4 11.11.3 Return values: values: Return Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.12

168 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 168 11.12 Parameters: Method declaration: Parameters: Method declaration: Description: Return values: 11.12.1 11.12.2

vrtaActuatorDimmableLight levels name Value Value Parameter Parameter unsigned GetMax(void) Get the maximum value. unsignedlevels) vrtaActuatorDimmableLight(const vrtaTextPtrname, The constructor. When a later). the iscreated bechanged (but when can actuator levelsisset brightness light represents whose brightness a be can Thenumberset. of possible A the range zero to to zero range the vrtaActuatorDimmableLight This istheconstructor used tocreate instance of an a

Method: vrtaActuat Method: GetMax() vrtaActuatorDimmableLight vrtaActuatorDimmableLight levels

Description orDimmableLight() inclusive. inclusive. brightness of Thenumber levels Thename of the device. virtual Input Input Input/Output Input/Output Input/Output device.The actuator have may in value a is a isa special form of an actuator that is created its current value is zero. is zero. value current its created is minus 1 minus Description Description 11.12

169 Description Description Description Description actuator. actuator. Input/Output Input/Output Input The new maximum value for the

argument used in the constructor). If the current current the If constructor). the in used argument Description Description Description Description The current value of the actuator. the actuator. value of The current The maximum value of the actuator. actuator. the value of The maximum levels Method: SetMax() Method: Value() Method: Value()

This method is used to get the maximum value of the actuator. actuator. the of value maximum the get to used is method This value of the actuator is greater than the new maximum value then the current current the then value maximum new the than greater is actuator the of value valueset is to zero. This method is used to set the maximum value of the actuator (i.e. to override actuator(i.e. override to the value of maximum the set to used This method is the value of the This method is used to get the current value of the actuator. actuator. the of value current the get to used is method This Set the maximum value. value. maximum Set the void SetMax(unsigned v) Get the current value. value. current Get the unsigned Value(void) Parameter Parameter Value Parameter Parameter Value v 11.12.4 11.12.3 Return values: values: Return Description: Description: Description: Description: Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.12

170 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 170 Parameters: Method declaration: Return values: Description: Return values: 11.12.5 11.12.7 11.12.6

2 %u 1 %u v Action ID ID Action Value Parameter Value Action ID ID Action SetMax() This action sets the maximum value of the actuator. It is the equivalent of the SetVal() This action sets the current value of th void SetVal(unsignedv) value.Set thecurrent current value is not set. currentvalue of the actuatorgreateris than themaximum valuethenthe new current the of isusedto actuator. the If value the set This method

Method: SetVal() Action: Maximum Action: Value method. method. method. Data Format Data Format

Description Description Input The new value for the actuator. the actuator. for new value The Input Input/Output Input/Output e actuator. Itisthe equivalent of the Description 11.12

171 Data Format Data Format Data Format Event: Value Value Event: Maximum Event:

This event contains the current value of the actuator. It is raised whenever the the whenever raised It is actuator. the value of current the contains This event changes. actuator the of value whenever raised is It actuator. the value of maximum the contains This event changes. actuator the of value maximum the Event ID Event ID 1 %u 2 %u

11.12.9 11.12.8 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.13

172 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 172 11.13 Parameters: Method declaration: Parameters: Method declaration: Return values: Description: 11.13.1 11.13.2

vrtaActuatorMultiColorLight vrtaActuatorMultiColorLight colors name Value Value Parameter Parameter unsigned GetMax(void) Get the maximum value. unsignedcolors) vrtaActuatorMultiColorLight(const vrtaTextPtrname, The constructor. zero. When a when the actuator is created (but can be changed later). is set colors of possible Thenumber be set. can whose color light a represents A in the range zero to vrtaActuatorMultiColorLight This istheconstructor used tocreate instance of an a

Method: vrtaActuat Method: GetMax() vrtaActuatorMultiColorLight vrtaActuatorMultiColorLight

colors Description orMultiColorLight() Thenumber of colors 1 minus Thename of the device. virtual Input Input Input/Output Input/Output Input/Output inclusive. inclusive. device. Thedevice. actuatorhave value may a is a special form of an actuatorofthat an formspecial is a is created its current value is is value current its is created Description Description 11.13

173 Description Description Description Description actuator. actuator. Input/Output Input/Output Input The new maximum value for the

argument used in the constructor). If the current current the If constructor). the in used argument Description Description Description Description The current value of the actuator. the actuator. value of The current The maximum value of the actuator. actuator. the value of The maximum colors Method: SetMax() Method: Value() Method: Value()

This method is used to get the maximum value of the actuator. actuator. the of value maximum the get to used is method This value of the actuator is greater than the new maximum value then the current current the then value maximum new the than greater is actuator the of value valueset is to zero. This method is used to set the maximum value of the actuator (i.e. to override actuator(i.e. override to the value of maximum the set to used This method is the value of the This method is used to get the current value of the actuator. actuator. the of value current the get to used is method This Set the maximum value. value. maximum Set the void SetMax(unsigned v) Get the current value. value. current Get the unsigned Value(void) Parameter Parameter Value Parameter Parameter Value v 11.13.4 11.13.3 Return values: values: Return Description: Description: Description: Description: Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.13

174 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 174 Parameters: Method declaration: Return values: Description: Return values: 11.13.5 11.13.7 11.13.6

2 %u 1 %u v Action ID ID Action Value Parameter Value Action ID ID Action SetMax() This action sets the maximum value of the actuator. It is the equivalent of the SetVal() This action sets the current value of th void SetVal(unsignedv) value.Set thecurrent current value is not set. currentvalue of the actuatorgreateris than themaximum valuethenthe new current the of isusedto actuator. the If value the set This method

Method: SetVal() Action: Maximum Action: Value method. method. method. Data Format Data Format

Description Description Input The new value for the actuator. the actuator. for new value The Input Input/Output Input/Output e actuator. Itisthe equivalent of the Description 11.13

175 Data Format Data Format Data Format Event: Value Value Event: Maximum Event:

This event contains the current value of the actuator. It is raised whenever the the whenever raised It is actuator. the value of current the contains This event changes. actuator the of value whenever raised is It actuator. the value of maximum the contains This event changes. actuator the of value maximum the Event ID Event ID 1 %u 2 %u

11.13.9 11.13.8 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.14

176 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 176 11.14 Parameters: Method declaration: Description: 11.14.1

vrtaCompare vrtaCompare vector match source name Parameter unsignedvector) unsignedmatch, vrtaComparable&source, vrtaCompare(const vrtaTextPtrname, The constructor. A The This is the constructor used to create instancean of a Multiple Multiple value. match specified a reaches device the attached value of when the current interrupt an generate will It theof devices following done by sending an Unmask action to the ICUdevice.) (Note that current of the device value specifiedby

Method: vrtaCompare() vrtaCompare vrtaActuatorMultiColorLight vrtaActuatorDimmableLight vrtaActuatorLight vrtaActuator vrtaSensorMultiwaySwitch vrtaSensorToggleSwitch vrtaSensor vrtaDownCounter vrtaUpCounter vrtaCompare vrtaCompare vrtaCompare devicerepresents comparator a thatbe attached may to any device will raise interrupt number number interrupt raise will device devicesbe may attached tothesame device. will not enable the interrupt vector. vector. interrupt This enable must not the be will Input The interrupt vector number vector Theinterrupt to attach. to to device which The Thename of the device. virtual Input The Input Input Input match value. Input/Output Input/Output source interrupt. be generated or zero for no Description reaches the value vrtaCompare vector when the device. match . 11.14

177 Description Description Description Description Input/Output Input/Output Input The matchnew value.

Description Description Description Description Description Description

value. match The current Method: SetMatch() Method: GetMatch() Method: GetMatch()

This method is used to set the match value. value. match the set to used is method This This method is used to get the current match value of the device. device. the of value match current the get to used is method This Set the match value. Set the match void SetMatch(unsigned val) Get the match value. match Get the unsigned GetMatch(void) Value Parameter Parameter Parameter Parameter Value Value val

11.14.3 11.14.2 Return values: values: Return Description: Description: values: Return Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.14

178 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 178 Parameters: Method declaration: Parameters: Method declaration: Return values: Description: Return values: Description: 11.14.4 11.14.5 val val Parameter Value Parameter Value Value unsigned IncrementMatch(unsignedval) Increment the match value. void SetVector(unsignedval) Set the interrupt vector number. This method is used to increment the match value. number is set to zero then no interrupted will be generated. be will generated. to zero nointerrupted is then set number vector interrupt vector the If set interrupt number. isusedto the This method

Method: IncrementMatch() Method: SetVector() newThe match value. Description Description nu Thenew interrupt vector number. Input match the by which Theamount Input Input/Output Input/Output Input/Output Input/Output value should be incremented. be should incremented. value Description Description 11.14

179

device. device. SetMatch() vrtaCompare is raised whenever the current value of value of the current is raised whenever method. method. Data Format Data Format Data Format Data Format Data Format Event: Match Match Event: Action: Match Action: Action: Vector

the attached device reaches the match value the match of the reaches device the attached This event contains the match value. It value. match the This event contains This actionThis setsthe match value. It is the equivalent of the method. the of equivalent the is It number. vector interrupt the sets action This SetVector() Event ID Action ID Action ID 1 %u 1 %u 2 %u

11.14.8 11.14.7 11.14.6 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.15

180 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 180 11.15 Parameters: Method declaration: Parameters: Method declaration: Description: Description: Return values: 11.15.1 11.15.2

vrtaIO value offset elements name Value Value Parameter Parameter void SetValue(unsignedoffset,unsigned value) I/Oofcell. an Set thevalue vrtaIO(const vrtaTextPtrname,unsignedelements) The constructor. A This is the constructor used to create instancean of a This method is used to set the value of an I/O cell. I/O cell. of value an usedthe is method to set This and read by an application. haveoffsets in the range zero to vrtaIO

Method: vrtaIO() Method: SetValue() vrtaIO device will contain an array of an array contain will device device represents an array of 32-bit I/O cells that may be written may that I/Ocells 32-bit of array an represents device

Description Input The value to write. Thevalue to write. be cellto I/O the of Theoffset Input Input cells I/O be of to Thenumber Thename of the device. virtual Input Input Input/Output Input/Output Input/Output Input/Output elements elements – 1inclusive. set. used. Description Description I/O cells. The I/O cells will TheI/O cells cells. I/O vrtaIO device. The 11.15

181 values values . number offset Description Description Description Description be set. be set. Input/Output Input/Output Input I/Othe cell get. The offset of Input Input Input The offsetthe of first I/O cell to write.array values to of An write. to values of The number Description Description Description Description

are written to the array of I/O cells starting at at starting cells I/O of array the to written are values[] Method: GetValue() Method: GetValue() Method: SetValues() Method: SetValues()

Thisto is method an value getcell. the used I/O of This method is used to set the values of multiple values I/O cells. the of set The to This method is used from from Getan the value I/O of cell. unsigned GetValue(unsigned offset) const Set the value multipleof I/O cells. offset, void SetValues(unsigned const unsigned *values, unsigned number) Parameter Parameter Value Parameter Parameter Value offset offset values number

11.15.4 11.15.3 Return values: values: Return Return values: values: Return Description: Description: Description: Description: Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

11.15

182 Sample Device Reference RTA-OSEK for RTA-OSEK PC User Guide Sample Device Reference 182 Parameters: Method declaration: Return values: Description: Return values: 11.15.5 11.15.7 11.15.6

2 %a 1 %u,%u Action ID ID Action Value Parameter Value Action ID ID Action equivalent to the values to write to the I/O cell array starting at offset zero. This action is of array is an data The action cells. I/O multiple of values the sets action This equivalent to the is This action to write. value the is number the second and offset cell I/O the cell. I/O of an the value sets action This const unsigned*GetValues(void) I/O cells. of all values the Get zero. This method is used to get the values of all I/O cells. I/O cells. of all the used values get is method to This

Method: GetValues() Action: Values Action: Value Data Format Data Format SetValue() SetValues() A pointer toA pointer the ofarray I/O cells. cell. I/O specified ofthe The value Description Description

Input/Output Input/Output method. method with the method Thefirst number in the action data is Description offset argument setto 11.15

183 raised for the offset specified in the specified in the the offset raised for cell. The first number is the offset of of offset the is number first The cell. Data Format Data Format Data Format Data Format Data Format Data Format Data Format Event: Values Values Event: Event: Value Value Event:

Action: GetValue Action: GetValue Action: GetValues

the I/O cell. The second number is the value of the I/O cell. If the event is raised in responsea toaction Value then the I/O cell offset is in the action data. input the in is offset cell I/O the then queried is event the If data. containsThis eventall of values the cells. of the I/O This action causes a Values event to be raised. raised. be to event a Values action causes This I/O an value of the contains This event This action causes a event to be Value This action causes action data. Event ID Event ID Action ID Action ID 2 %a 1 %u,%u(%u) 3 %u 4 11.15.11 11.15.10 11.15.9 11.15.8 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Device Sample

12.1

184 Virtual ECU Server Library Reference RTA-OSEK for RTA-OSEK PCUser Guide ECU Server Virtual Library Reference 184 12.1 12 12.3 12.2

Virtual ECUServerVirtual LibraryReference Using the Source Source Code the Using Virtual ECU Aliases ECUAliases Virtual DLL the Using Virtual ECU registers with unique. unique. are aliases all that ensure to aliases specified the to suffixes numeric apply vrtaServer called DLL a as provided is also library The server use library the should include the interfaces\vrtaClientSupport.cpp interfaces\VESLib\veslib.cpp in form the file code insource isprovided library The server library. provided bythis APIthe calls order, for communication with The Virtual ECU Serverlibrary is librarya that provides C programming a API VECU byusing the “ It is also possible VECU’s for a alias to be set on the command line of the thenbe it loaded will “ assigned the alias “ alias assigned the be example,VECU withtheexecutableifFor a unique executable name suffix the to to is alias.a generate numeric applied VECUs with the same executable name register with alias for VECU a is simply the name of its executable. However if multiple VESLIB_DLL veslib.dll file. header Any source files that wish to use the library should include the veslib.h within the DLL. Prototypes for all of the library API functions can be found in GetProcAddress() Windows between compilers. If you wish to use library is not provided for the DLL since the format of import libraries varies LoadLibrary() . makes use of defined. defined. produced bycompiling was –alias function to get pointers to the library API functions vecu.exe vrtaServer vrtaServer function to load the DLL and then Windows the the DLLand load to function ” command lineoption. Again aliases veslib.h ”. If a second If ofa ”. instance to keep track ofVirtual ECUs. When a veslib.dll . You will also need the support file need support the also Youwill . . This . chapter describes, in alphabetic vecu.exe_2 it is it assigned Thedefaultalias. an veslib.cpp . Any sourcefiles that wish to header file. vecu.exe veslib.dll you will need to usethe you needto will ”. ”. vrtaServer is loaded loaded then it is will with the C++ macro vrtaServer vecu.exe . An import veslib.h then a will will is is

12.4

185 Description Description definition:has the Description

Description of return value. value. return of Description type Virtual is used to ECU aliases. contain type is used to identify Virtual ECU executables to to executables ECU Virtual identify to used is type Input/Output Input/Output Description. has the definition: has VesLibEcuInfoType

. field should contain the full path of the Virtual ECU executable. executable. ECU Virtual the of path full the contain should field VesLibEcuAliasType VesLibEcuInfoType path typedef struct { char name[VESLIB_MAX_PATH]; } VesLibEcuAliasType; typedef struct { typedef struct char path[VESLIB_MAX_PATH]; } VesLibEcuInfoType; Explanation of the functionalitytheExplanation API call. the of of call. API the for notes and restrictions Usage the server library. library. server the The callEach API is described in this chapterfollowingthe standard using format: A briefAPI call descriptionthe is of provided. C syntax. in Interface The The VesLibEcuAliasType Value Parameter Parameter Return values Parameter Name The API Call Template The API Call Template VesLibEcuAliasType VesLibEcuAliasType VesLibEcuInfoType VesLibEcuInfoType

Notes: Description: Description: values: Return The title gives the name of the API call. call. the API of the name gives The title declaration: Function Parameters: 12.6 12.5 12.4 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Library Virtual ECU Server

12.7

186 Virtual ECU Server Library Reference RTA-OSEK for RTA-OSEK PCUser Guide ECU Server Virtual Library Reference 186 12.7 Parameters: Function declaration: Return values: Description: See also: Notes: See also:

VesLibAttachToECU() VESLIB_STATUS_ECU_NOT_LOADED VESLIB_STATUS_NO_ECU VESLIB_STATUS_SERVER_COMMS VESLIB_STATUS_OK port alias Value Value Parameter VesLibEcuAliasType*alias,intport) VesLibStatusType VesLibAttachToECU( Attach to a loaded Virtual ECU. ECU’s diagnosticECU’s interface. loaded. On successful return return Onsuccessful loaded. This function isused to connect to has ECU Virtual that a beenalready VesLibListLoadedECUs() List of related API calls. APIcalls. of related List Output Output Input Input/Output

*port , VesLibLoadECU()

ECU’s diagnosticECU’s port. Virtual of TCPportthe number the contain will A pointer variable to a that on successful return of the ECU. a loadedspecifying alias Virtual A pointer to a Description Description

contains the port number of number of Virtual the the contains port

The API call succeeded. succeeded. The APIcall The alias is not loaded. isnotloaded. The alias The doesalias not exist. vrtaServer The library cannot communicate with Description VesLibEcuAliasType . structure 12.8

187 structure structure structure structure structure allocated allocated structure identifies a Virtual ECU ECU a Virtual identifies ecu . VesLibEcuInfoType VesLibEcuAliasType contains a new alias for the Virtual Virtual the for alias a new contains Description The API call succeeded. succeeded. The API call

The library cannot communicate with with communicate cannot library The vrtaServer exist. not does executable ECU The Virtual *alias VesLibtEcuAliasType Description A pointer to a to pointer A ECU executable. Virtual the identifies that A pointer to a thatalias. will contain new the VesLibLoadEcu()

, points to a to points

Input/Output Input Output alias VesLibFreeAlias() This API call createsaliasan a for Virtual ECU. executable. executable. Shutdown the library.Shutdown the VesLibStatusType VesLibExit(void) Create an alias for a Virtual ECU. VesLibCreateAlias( VesLibStatusType * ecu, VesLibEcuInfoType * alias) VesLibEcuAliasType by the caller. On successful return return successful On caller. the by ECU. referencealias for The count the willto set have 1. been Value Parameter Parameter VESLIB_STATUS_OK VESLIB_STATUS_SERVER_COMMS VESLIB_STATUS_NO_ECU ecu alias

VesLibExit() VesLibCreateAlias() VesLibCreateAlias()

Notes: See also: Description: Description: Function declaration: Function Function declaration: Function Parameters: Return values: values: Return 12.9 12.8 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Library Virtual ECU Server

12.10

188 Virtual ECU Server Library Reference RTA-OSEK for RTA-OSEK PCUser Guide ECU Server Virtual Library Reference 188 12.10 Parameters: Function declaration: See also: Notes: Description: Description: Parameters: eunvle: Return values:

VesLibFindECUs() VesLibFindECUs()

results dir VESLIB_STATUS_OK Parameter Value Parameter vrtaServer char*results) VesLibStatusType VesLibFindECUs(char*dir, Find out what Virtual ECU executables present.are resources allocated within within allocated resources VesLibSelectServer() from disconnect isusedto This APIcall directory containingdirectory the directory to be searched –either as an absolute path or patha relative to the local PC (or remote PC if discover the used is to APIcall This vrtaServer VesLibInitialize() VesLibFreeMemory() (but it does not release memory any *results points to a ‘ Output Output Input Input/Output Input/Output running on aremote PC). .

can be called subsequently to re-attach to re-attach subsequentlycalled to be can ). VesLibSelectServer() \n VesLibInitialize() vrtaServer , ’ separated list of the Virtual ECUs executables vrtaLibInitialize() will point to a list of Virtual ECU executables. ECU executables. of Virtual to point a list will A pointer to variablea which on successful return ECU executables. The path of the directory to be searched for Virtual Description Description Description Description

The API call The APIcall succeeded. Description Description Virtual ECUexecutables present onthe that should beenfreed via have executable. Onsuccessful return dir vrtaServer contains paththe of the and subsequent and APIcalls has been has used to select

and release any 12.11

189

structure structure contains contains " for a non- " for vrtaServer .. *results ’s PC. ’s PC. . . VesLibEcuAliasType vrtaServer ount of the specifiedountthe Virtual ofalias. ECU Description (one per line), per (one " including The API call succeeded. succeeded. The API call

The library cannot communicate with with communicate cannot library The vrtaServer dir Description specifying an alias. A pointer to a VesLibFreeMemory() ’ separated to list by pointed that may be valid Virtual ECU applications. \n dir

Input/Output Input points to memory allocated by the server library. The memory memory The library. server the by allocated memory to points The current path. path. current The A comma separated list of drivesthatare readable. of The subdirectories root directory. A blank line. A list of files in

1. 2. 3. 4. 5. the followingthespecified order below: items in the VesLibFreeMemory() found in the specified directory plus directory information that allows that remote information directory plus specified directory the found in available on the directories navigation of ‘ the return successful On This API call decrements the reference c This API call reference the decrements application the If zero. reaches count reference its when removed alias is An that is using the library without terminates freeing aliases then will automatically decrement the reference counts of aliases appropriately. *results released callingshould by be Free aalias.Free Virtual ECU VesLibStatusType VesLibFreeAlias( VesLibEcuAliasType * alias) Parameter Parameter Value alias

VESLIB_STATUS_OK VESLIB_STATUS_SERVER_COMMS

VesLibFreeAlias()

Return values: values: Return See also: See also: Description: Description: Notes: Function declaration: Function Parameters: 12.11 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Library Virtual ECU Server

12.12

190 Virtual ECU Server Library Reference RTA-OSEK for RTA-OSEK PCUser Guide ECU Server Virtual Library Reference 190 12.13 12.12 Parameters: Function declaration: Return values: Description: See also: Notes: See also: Notes: Return values:

VesLibGetAliases() VesLibFreeMemory()

results VESLIB_STATUS_NO_ECU VESLIB_STATUS_SERVER_COMMS VESLIB_STATUS_OK Value Value Parameter Value VesLibListLoadedECUs() Get a list of the aliases that exist for a Virtual ECU executable. void VesLibFreeMemory(void*results) Free memory allocated by the server library. This API call is used to free memory returned from other library functions. VesLibCreateAlias() VesLibFindECUs() VesLibListAliases()

Input A pointer the Apointer tomemory be freed Input Input/Output

, VesLibGetAliases()

, , VesLibListLoadedECUs() VesLibGetAliases() , VesLibGetInfo() Description Description vrtaServer The library cannot communicate with The doesalias not exist.

The API call The APIcall succeeded. Description Description

Description , . VesLibListAliases() , , 12.13

191

. , structure structure *count *results VesLibEcuAliasType VesLibEcuAliasType VesLibLoadEcu() , . VesLibEcuInfoType . identifies the Virtual ECU executable. On ECU executable. Virtual identifies the Description The API call succeeded. succeeded. The API call

The library cannot communicate with with communicate cannot library The vrtaServer exist. not does executable ECU The Virtual ecu Description . A pointer to a to pointer A executable. ECU Virtual the identifies that return successful on which avariable to pointer A will pointa to list of return successful on which avariable to pointer A will containaliasesthe number of in structures containing the aliases for the specified specified the for aliases the containing structures executable. ECU Virtual points of an array to points or have been created when the Virtual ECU the Virtual when or have been created VesLibFreeAlias() ,

VesLibFreeMemory()

*results vrtaServer Input/Output Input Output Output points to memory allocated by the library. The memory should be be should memory The library. the by allocated memory to points structures containing all aliases for the Virtual ECU executable and executable ECU Virtual the for aliases all containing structures contains the numberaliases of array. in the If no alias exists for specified the Virtual ECU executable, willreference be created. one countThe alias of each 1. by incremented is returned VesLibFreeMemory() successful return return successful VesLibStatusType VesLibGetAliases( VesLibStatusType * ecu, VesLibEcuInfoType * * results, VesLibEcuAliasType int * count) *results released by calling VesLibListAliases() This API call getsa list of allaliases the that existsfora specified Virtual ECU with explicitly created been have aliasesmay The executable. VesLibCreateAlias() registered with with registered Value Parameter Parameter VESLIB_STATUS_OK VESLIB_STATUS_SERVER_COMMS VESLIB_STATUS_NO_ECU count ecu results Return values: values: Return See also: See also: Parameters: Parameters: Function declaration: Function Notes: Description: Description: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Library Virtual ECU Server

12.14

192 Virtual ECU Server Library Reference RTA-OSEK for RTA-OSEK PCUser Guide ECU Server Virtual Library Reference 192 12.14 12.15 Parameters: Function declaration: Parameters: Function declaration: Description: Notes: Notes: See also: Return values:

VesLibGetInfo() VesLibGetInfo() VesLibInitialize() VesLibInitialize() VESLIB_STATUS_NO_ECU VESLIB_STATUS_SERVER_COMMS VESLIB_STATUS_OK results alias Value Value Parameter Parameter VesLibStatusType VesLibInitialize(void) the library. Initialize VesLibEcuAliasType*alias,charresults) VesLibStatusType VesLibGetInfo( information version Get about ECU. a Virtual On successful return ECU Virtual alias. the specified returnsabout version information This APIcall released by calling bycalling released *results version number information as a series of “ points to memory allocated by the library. The memory should be Output Input Input/Output Input/Output

VesLibFreeMemory() *results

will point to version information. information. to version point will A pointer to variablea which on successful return specifying analias. a to A pointer Description Description Description Description points to ‘ a vrtaServer The library cannot communicate with The doesalias not exist.

The API call The APIcall succeeded. Description Description key=value . VesLibEcuAliasType \n . ’ separated containing list ’ ” pairs. ” pairs. structure 12.16

193 . . structures structures *results contains the the contains . or have been been or have running on the the running on . On successful . On successful VesLibEcuAliasType *count cannot be started. be cannot . vrtaServer vrtaServer as a service on the selected PC PC as a on the selected service VesLibEcuAliasType VesLibSelectServer() at have been created. The aliases may may aliases The created. been at have VesLibCreateAlias() Description VesLibSelectServer() The API call succeeded. succeeded. The API call

vrtaServer with communicate cannot library The vrtaServer is called. will This only succeed if

Description A pointer to a variable which on successful return return successful on which a variable to pointer A will pointa to list of structures containing all aliases. return successful on which a variable to pointer A will containaliasesthe number of in vrtaServer vrtaLibExit() ,

points to an array of anarray of to points is not already running PC then on the the selected server has been installed as a service on the selected PC. selected the on a service as installed been has Input/Output Output Output VesLibInitialize() *results vrtaServer vrtaServer when library will attempt to start By default the server library communicates with with communicates library server the By default local changed by callingThiscan be PC. If This API callprepare isto used the library for use. This API must called be beforeall other API calls except for created when Virtual ECUs registered with with registered ECUs Virtual when created return This API calla gets list of allaliases th with createdhave explicitly been containing all aliases that and have created been VesLibSelectServer() Get a list allof aliases that exist. VesLibStatusType VesLibListAliases( VesLibEcuAliasType * * results, int * count) Parameter Parameter Value results count

VESLIB_STATUS_SERVER_START VESLIB_STATUS_SERVER_START VESLIB_STATUS_SERVER_COMMS VESLIB_STATUS_OK VesLibListAliases() VesLibListAliases()

Return values: values: Return Description: Description: Description: Description: Notes: See also: Function declaration: Function Parameters: 12.16 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Library Virtual ECU Server

12.17

194 Virtual ECU Server Library Reference RTA-OSEK for RTA-OSEK PCUser Guide ECU Server Virtual Library Reference 194 12.17 Return values: Parameters: Function declaration: Notes: Notes: Description: See also:

VesLibListLoadedECUs() count results VESLIB_STATUS_SERVER_COMMS VESLIB_STATUS_OK Parameter Value incremented by 1. number of aliases in the array. The reference count of each alias returned is int*count) VesLibEcuAliasType*results, VesLibStatusType VesLibListLoadedECUs( Get a list of the Virtual ECUs that have been loaded. *results containing the aliases of all loaded Virtual ECUs and ECUs the Virtual of loaded containing and aliases all *results loaded (i.e. the Virtual ECU executable the a to discover used is APIcall This VesLibGetAliases() bycalling released incremented by 1. number of aliases in the array. The reference count of each alias returned is VesLibFreeMemory() points to an array of points to memory allocated by the library. The memory should be Output Output Output Input/Output

VesLibFreeMemory() , VesLibFreeAlias() will contain the number of aliases in of number the aliases contain will A pointer to variablea which on successful return ECUs. structures containing the aliases of loaded Virtual of list to a point will A pointer to variablea which on successful return Description Description vrtaServer The library cannot communicate with

The API call The APIcall succeeded. Description Description liases of Virtual ECUs that have been been have that ECUs Virtual of liases s are running). Onsuccessful return VesLibEcuAliasType . . , VesLibLoadEcu() *count VesLibEcuAliasType contains the *results structures , .

12.18

195

structure structure ). If cmd alias VesLibLoadEcu() , VesLibEcuAliasType . . thenalias the is loaded mode. in silent thenalias the is loaded in GUI mode. Description The API call succeeded. succeeded. The API call

The library cannot communicate with with communicate cannot library The vrtaServer then the alias then the is loaded mode. in slave If Description A pointer to a to pointer A ECU executable Virtual the alias of the specifying load. to return successful on that a to variable pointer A will contain the numberthe TCP port of Virtual port. ECU’s diagnostic then the alias is loaded in autostart mode. If If mode. autostart in loaded is alias the then VesLibFreeAlias() , VesLibDMGui VesLibFreeMemory()

VesLibDMSilent is Input/Output VesLibSMSlave Input Input Input Input the Virtual for ECU. mode The start Output Virtual ECU.the for mode The display VirtualECU.for the line The command VesLibSMAuto is is is points to memory allocated by the library. The memory should be be should memory The library. the by allocated memory to points (i.e. to run the Virtual ECU executable identified by by identified executable ECU Virtual the run to (i.e. displayMode VesLibFreeMemory() This API callanda load is to alias used connect to Virtualby ECU specified alias *results released by calling Load a Virtual ECU. a Virtual Load VesLibStatusType VesLibLoadECU( alias, VesLibEcuAliasType * VesLibStartMode startMode, VesLibDisplayMode displayMode, char * cmd, int * port) startMode startMode displayMode If Parameter Parameter Value port alias startMode displayMode cmd VESLIB_STATUS_OK VESLIB_STATUS_OK VESLIB_STATUS_SERVER_COMMS

VesLibLoadECU()

See also: See also: Return values: values: Return Description: Description: Notes: Function declaration: Function Parameters: 12.18 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Library Virtual ECU Server

12.19

196 Virtual ECU Server Library Reference RTA-OSEK for RTA-OSEK PCUser Guide ECU Server Virtual Library Reference 196 12.19 See also: Notes: Description: Return values: Parameters: Function declaration:

VesLibSelectServer() port host VESLIB_STATUS_ECU_LOADED VESLIB_STATUS_NO_ECU VESLIB_STATUS_SERVER_COMMS VESLIB_STATUS_OK Parameter Value specifies additional command line parameters. On successful return Select the VesLibInitialize() VesLibSelectServer() for search will library server can can specify this number with the port numbers. If Similarly defaults with communicate will VesLibAttachToECUs() VesLibCreateAlias() hostnameof the remote PC as communicate with to library server the direct can PC. ThisAPIcall local onthe running The server library is normally used to communicate with contains the port number of the Virtual ECU’s diagnostic interface. intport) VesLibStatusType VesLibSelectServer(constchar*host, host vrtaServer vrtaServer nu Thehost name of the PC running Input Input Input/Output to “localhost”). “localhost”). to vrtaServer

vrtaServer is normally found bysearching TCP pre-defined found three isnormally

to use. use. to vrtaServer . If it is called after called after it is If . , vrtaServer VesLibListLoadedECUs() should normally be called before becalled shouldnormally

vrtaServer of TCP beingusedby the The number port Description Description is set to use a different port number then you host running on a on running remotea PC by passing the port vrtaServer The library cannot communicate with The doesalias not exist.

The alias isloaded. already The alias The APIcall succeeded. Description Description . If running on the local PC (it internally internally PC (it local onthe running argument.If host on the pre-defined port numbers. . is NULL then the server library VesLibInitialize() . port , is zero then the vrtaServer vrtaServer *port but .

12.19

197 then VesLibExit() cannot be started. be cannot . Description The API call succeeded. succeeded. The API call

vrtaServer with communicate cannot library The vrtaServer

VesLibExit() to reset the connection. the to reset , then thethen function will itself call

VesLibExit() before before VesLibInitialize() VesLibInitialize() Value VESLIB_STATUS_OK VESLIB_STATUS_SERVER_START VESLIB_STATUS_SERVER_COMMS Return values: values: Return Notes: See also: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Library Virtual ECU Server

13.1

198 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 198 13 13.2 13.1

13.2.1

COM Bridge Tutorial andReference Sample of use of Sample Overview use themulti-threaded apartment(MTA). COMBridge threads worker create bythe objects hosted the and therefore access from as variety of wide possible. COMclients a TheCOMBridgeas can support dual enable interfaces COMBridge hostedto bythe The COMobjects The code below shows how to create a VECUs. to attach or The demonstrate how to use the COMBridge. The section shows code snippets writ processthe of any client towishing use it. The DLL is into beloaded Itwill Server. COM DLL implemented as a Bridge is The COM COM programming. with is reader the familiar that Important: This chapter describes the objects and interfaces provided by the COM Bridge. used by protocols TCP/IP the and client-side translates between COM onthe protocols Visual Basic to allow them to interact with Virtual ECUs. The COM Bridge The COMBridge provides services COMto enabled such clients Microsoftas ourexe connect to create vrtaServer, the local the for VECUnamedalias an by

CVcServer ' Declareaservercomponent End Sub <...snip...> Private SubForm_Unload(Cancel AsInteger) ' Releasetheservercomponentinform unload End Sub <...snip...> Private SubForm_Load() ' Createtheservercomponentinformload Private local_ServerAsCVcServer CVcServer Set local_Server=Nothing Set local_Server=NewCVcServer vrtaServer , then load it. This chapter is not intended as a tutorial on COM. It is assumed objectis used to connect to vrtaServer so that youcan load and VECUs. VECUs. and CVcServer ten in Microsoft Visual Basic that named named vrtaMSCOM.dll local_Server . , 13.2

199

local_Server.LoadECU( local_Server.FreeAlias(ouralias) local_Server.Connect("localhost", 0) local_Server.CreateAlias(ourexe, ouralias) local_Server.Disconnect Dim diagport As Long Call CheckServerStatus("LoadECU", ) < ... snip ...> Call CheckServerStatus("FreeAlias", ouralias, AUTO, GUI, "", diagport) ) End Sub End Sub Private Sub DoSomething() Call CheckServerStatus( ) "Connect to server", Dim ouralias As String Call CheckServerStatus( ) "Create alias", ret = "ECU_SLAVE" Then ElseIf val = ECU_ALIASED ret = "ECU_ALIASED" Then ElseIf val = NOT_LOADED ret = "NOT_LOADED" Else **" ret = "** UNKNOWN End If return status: " + ret) AddLine (location + " AddLine ("Test failed") ' Quit program Unload fTest Private Sub CheckServerStatus(location, val) Private Sub CheckServerStatus(location, STATUS_OK Then If val = Sub Exit = SERVER_START Then ElseIf val "SERVER_START" ret = = SERVER_COMMS Then ElseIf val "SERVER_COMMS" ret = = NO_ECU Then ElseIf val "NO_ECU" ret = = ECU_LOADED Then ElseIf val ret = "ECU_LOADED" Then ElseIf val = ECU_NOT_LOADED ret = "ECU_NOT_LOADED" Then ElseIf val = ECU_SLAVE server component that checks the function ' A helper ' return codes RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.2

200 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 200 13.2.2 The connect it to a VECU, hook display and eventan then terminate the VECU. showsThe codebelow to how create a its devices.

CVcECU 'Quitprogram AddLine("Testfailed") AddLine(location+"returnstatus:ret) EndIf ret="**UNKNOWN**" Else ret="ECU_ValErr" ElseIfval=ECU_ValErrThen ret="ECU_IDErr" ElseIfval=ECU_IDErrThen ret="ECU_DevErr" ElseIfval=ECU_DevErrThen ExitSub Ifval=ECU_OKThen DimretAsString Integer) Private SubCheckECUStatus(locationAsString,val ' returncodes ' AhelperfunctionthatcheckstheECUcomponent End Sub <...snip...> Setmonitored_ECU=Nothing Private SubForm_Unload(CancelAsInteger) ' ReleasetheECUcomponentinformunload End Sub <...snip...> Setmonitored_ECU=NewCVcECU Private SubForm_Load() ' CreatetheECUcomponentinformload Private WithEventsmonitored_ECUAsCVcECU ' DeclareanECUcomponentthathasevents ",Value"+value) ",Event"+Str(id) End Sub "**Device"+Str(dev) AddLine( hook_count=+1 Long, ByValidAsvalue String) Private Submonitored_ECU_OnEventChange(ByVal devAs ' monitored_ECUgetsraisedintheVECU ' Thisgetscalledeachtimeaneventhooked by End Sub UnloadfTest CVcECU object is used to connect to a VECU so that you can interact with CVcECU named named monitored_ECU , 13.2

201 monitored_ECU.DoAction(2, 2) monitored_ECU.DoAction(2, monitored_ECU.Disconnect monitored_ECU.Connect("localhost", diagport) monitored_ECU.Connect("localhost", monitored_ECU.Hook( Call CheckECUStatus("Terminate", ) ' Terminate Call CheckECUStatus("Disconnect", ) < ... snip ...> End Sub Call CheckECUStatus("Connect", Call CheckECUStatus("Connect", ) AddLine ("Loaded ok") a_device_ID, ecu", Call CheckECUStatus("Hook an_event_ID, 1 ) ) WaitOnEvents Private Sub WaitOnEvents() Private Sub WaitOnEvents() Do = 0 hook_count = 0.5 ' Set duration. PauseTime = Timer ' Set start time. Start Timer < Start + PauseTime Do While processes. ' Yield to other DoEvents Loop (hook_count = 0) Loop Until End Sub Private Sub DoSomething() < ... snip ...> ' This waits for at least one event to be hooked to be hooked least one event waits for at ' This we – normally test purposes only here for ' It is events to arrive asynchronously ' just allow RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.2

202 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 202 13.2.3 must be bound to a parent They cannot be created via ‘New’ like eventdevice, and action respectively. The GetActionByName The code belowshows how to create these objects, hook displayand events. GetEventByName A A GetDeviceByName A

CVcDevice, CVcActi CVcDevice, <...snip...> Private SubDoSomething() End Sub AddLine("--Value"+value) hook_count=+1 String) Private Submonitored_Event_OnEventChange(ByValvalueAs ' monitored_EventgetsraisedintheVECU ' Thisgetscalledeachtimeaneventhookedby +Event"Str(id)",Valuevalue End Sub ) AddLine( hook_count=+1 Long, ByValvalueAsString) Private Submonitored_Device_OnEventChange(ByValidAs ' monitored_DevicegetsraisedintheVECU ' Thisgetscalledeachtimeaneventhookedby Private WithEventsmonitored_EventAsCVcEvent Private monitored_ActionAsCVcAction Private WithEventsmonitored_DeviceAsCVcDevice ) monitored_Device.GetEventByName("f01") CallCheckECUStatus("Hook device", monitored_Event.EventID, monitored_Device.GetActionByName("f01") Setmonitored_Event= 1) monitored_ECU.GetDeviceByName("Test") Setmonitored_Action= Setmonitored_Device= CVcAction CVcDevice CVcEvent CVcDevice monitored_Device.Hook( object by is obtained the calling object is obtained by calling the callingthe by obtained is object , object is obtained by calling the the bycalling obtained is object CVcAction or or or or or or GetEventByID GetActionByID GetDeviceByID on andCVcEvent CVcECU and and CVcEvent or or CVcDevice CVcServer method. method. method. method. componentsVECU represent a . or or CVcECU CVcDevice CVcDevice because they CVcECU ’s ’s ’s 13.3

203

. The fCar to to Form1 , again with range 0 to 100. 100. to 0 range with again , to use the COM Bridge in Microsoftthe to use sBrake with a range 0 to 100. 0 a range with and alongside it. . find this You should be ableto in a location like with the default content ‘Example2.exe’. pSpeed . eAlias bConnect sThrottle Car monitored_Event.Hook(1) monitored_Event.Hook(1) RTA-OSEK for PC add a TextBox a TextBox add add a Button a Button add aadd ProgressBar a Sliders add ) ("1.01") monitored_Action.Send ("2.02") monitored_Action.Send ("3.03") monitored_Action.Send ("4.04") monitored_Action.Send ("5.05") monitored_Action.Send WaitOnEvents < ... snip ...> End Sub event", CheckECUStatus("Hook Call

Setting up the project project Setting up the ƒ ƒ ƒ ƒ

Ensure that you have ProgressBar and Slider components available (you may available (you may and Slider components ProgressBar thatEnsure you have Controlsthe Project to addWindows Microsoftneed to Common the Components), then below as the ascreenshot use reference to: Firstly create a new empty Visual Basic application, renaming renaming application, Basic Visual empty a new create Firstly anThis tutorial of example gives how Visual Basic. You will create a simple application that can monitor and control 5.0, Basic version developed using Visual should a but is The example VECU. versions. later to transferable easily be that VECU ‘Example2’ the with interacts that a program creates tutorial The with ships Example 2 C:\rta\vrta\samples\Applications\RTA-OSEK application is verysimplistic: will it only attach to theif VECU it is already running,andthere will very little be error handling done. This the is because Basic Visual between interface to how you show to is tutorial the of aim main and VECUs. caption the with A short tutorial tutorial short A

13.3.1 13.3 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.3

204 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 204 13.3.2 You will now add the code connect add to to now You will the vrtaMSCOM Library isselect Library vrtaMSCOM the Save theproject as‘Car.vbp’. the project: have accessnow the to You

Connecting tovrtaServer End Sub Setserver=Nothing Private SubForm_Unload(Cancel AsInteger) End Sub Setserver=NewCVcServer Private SubForm_Load() Private serverAsCVcServer CVcServer ed in the Project References: object, so object, lines add the following to vrtaServer . Firstly ensure that

13.3

205 as the as the . before you can get beforeyou can get CVcServer CVcServer : ”). ”). is exampleassume we will that . The connection will fail connection . The if there ecu Example2.exe can be used to access and control and control access to used be can eAlias localhost server to access VECUs, you must connect it to to it connect must you VECUs, access to for the diagnostic port number of the VECU VECU the of port number diagnostic for the gets set to a new instance of of instance a new to set gets server server server running on aspecifiedPC. th For (“ PC same the on is object a is used to VECU. with communicate You can specific CVcECU Exit Sub End If If Not (ECU_OK = ecu.Connect("localhost", diagport)) Then server.Disconnect MsgBox ("Cannot connect to ECU") Exit Sub End If Set server = New CVcServer Set server = New CVcServer Set ecu = New CVcECU End Sub As Integer) Private Sub Form_Unload(Cancel Set server = Nothing Set ecu = Nothing End Sub Dim diagport As Long If Not (STATUS_OK = server.AttachECU(eAlias.Text, diagport)) Then server.Disconnect MsgBox ("ECU is not running") Private server As CVcServer Private server As CVcServer Private ecu As CVcECU Private Sub Form_Load() Private Sub bConnect_Click() Private Sub bConnect_Click() 0))Then = server.Connect("localhost", If Not (STATUS_OK not connect to VRTA Server") MsgBox ("Did Exit Sub End If Server") MsgBox ("Connected to VRTA End Sub Connecting to the VECU

obtain the details needed to use such an object via via object an such to use needed details the obtain As you can see, As you can see, form loads. It gets released as the form unloads. unloads. form the as released gets It loads. form you canBefore use vrtaServer vrtaServer Add the ‘connect’ code to the button’s Click event: event: Click button’s the to code ‘connect’ Add the issuch no sowill VECU, you have to start further. much The first clause asks clause The first whosealias is the sameas the text in In the ‘Connect’ add:button event, The If you run the program at this point, then you should see the connection connection see the should thenat you this point, theIf program you run this on, point From succeed. for the declaration add to code your Modify VECUs on the local PC. the local VECUs on 13.3.3 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.3

206 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 206 13.3.4 The secondclause simply binds adding: adding: You can also initialize the sliders from the current values from the VECU by String should bepassed to ‘in’ this event. Thismustvalue. beempty onentry the because nodata VECUknowsthat bound itsgets to Value event. This shows that Now,the when They should be declared thus: and Speedometer devices. The next task is to create objects to linkto the VECU’s device Throttle, Brake Try it and see that it works as expected. diagnosticand port number. code below, toadded the bottom of the ‘Connect’ handler: the Speedometer ProgressBar initialize and

Initializing thedevices SetaThrottle=dThrottle.GetActionByName("Value") SetdThrottle=ecu.GetDeviceByName("Throttle") EndIf pSpeed.value=res IfECU_OK=eSpeed.Query(res)Then res="" SeteSpeed=dSpeed.GetEventByName("Value") SetdSpeed=ecu.GetDeviceByName("Speedometer") Private WithEventseBrakeAsCVcEvent Private aBrakeAsCVcAction Private dBrakeAsCVcDevice Private WithEventseThrottleAsCVcEvent Private aThrottleAsCVcAction Private dThrottleAsCVcDevice Private WithEventseSpeedAsCVcEvent Private aSpeedAsCVcAction Private dSpeedAsCVcDevice EndIf sBrake.value =res IfECU_OK=eBrake.Query(res) Then res="" SeteBrake=dBrake.GetEventByName("Value") SetaBrake=dBrake.GetActionByName("Value") SetdBrake=ecu.GetDeviceByName("Brake") EndIf sThrottle.value=res IfECU_OK=eThrottle.Query(res)Then res="" SeteThrottle=dThrottle.GetEventByName("Value") DimresAsString res . This. String can bepassed in directly to ProgressBar’sthe value. dSpeed ecu connects the application can read the current value of gets bound to the Speedometerdevice, the boundto gets and ecu eSpeed.Query() eSpeed.Query() totheVECUbyspecifying the PCname pSpeed takes an in/out String String in/out an takes . Thisisdonewiththe returns its result in the eSpeed

13.3

207 End Sub Private Sub eSpeed_OnEventChange(ByVal value As String) pSpeed.value = value End Sub As Private Sub eThrottle_OnEventChange(ByVal value String) sThrottle.value = value End Sub Set dBrake = ecu.GetDeviceByName("Brake") Set dBrake = ecu.GetDeviceByName("Brake") Set aBrake = dBrake.GetActionByName("Value") Set eBrake = dBrake.GetEventByName("Value") res = "" Then If ECU_OK = eBrake.Query(res) sBrake.value = res eBrake.Hook (1) End If String) sBrake.value = value If ECU_OK = eSpeed.Query(res) Then If ECU_OK = eSpeed.Query(res) pSpeed.value = res eSpeed.Hook (1) End If Set dThrottle = ecu.GetDeviceByName("Throttle") Set aThrottle = dThrottle.GetActionByName("Value") Set eThrottle = dThrottle.GetEventByName("Value") res = "" Then If ECU_OK = eThrottle.Query(res) res sThrottle.value = eThrottle.Hook (1) End If Dim res As String Dim res As Set dSpeed = ecu.GetDeviceByName("Speedometer") Set eSpeed = dSpeed.GetEventByName("Value") res = "" Private Sub eBrake_OnEventChange(ByVal value As Private Sub eBrake_OnEventChange(ByVal value As Reacting to events to events Reacting

Easy! The applicationEasy! The willautomatically now the update and sliders progress in the VECU. You can use change associated events the bar whenever Also add the handlers: event You have seen how to read the value of an event to initialize the control tocontrol initializeanevent the of the read value to how You have seen changes. for poll to timer a up set to step easy an is it so values, that…want do we to But don’t has an event that VECU the by informed be to efficient more clearly is It changed, so we simply enable the event hook mechanism and respond to ‘OnEventChange’. the hooks: enable above to code the Modify 13.3.5 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.3

208 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 208 13.3.6 13.3.7 will respond automatically. respond automatically. will vrtaMonitor to note are: Points this. than lot further goa to wish will you application ‘real’ in a Clearly The code islaughably simple: The final step links the sliders to the Brake and Throttle.

ƒ ƒ ƒ Sending actions Summary

End Sub aThrottle.Send(sThrottle.value) Private SubsThrottle_Change() End Sub aBrake.Send(sBrake.value) Private SubsBrake_Change() the server gets passedgets to one. You must remember that the name of the VECU executable that Youmaywishload to ECUrather an than simply attach to existing an Run-time error checking is necessary form of Strings. Multiple values are ‘\n’ separated. separated. ‘\n’ are values Multiple Strings. of form VECU actions/events and is in the your between sent Data application machine ‘b’. . You cannot specify a file on machine ‘a’ if server if ison onmachinethe Youcannot file specify . ‘a’ a to change to the Brake Throttleand values, your and application vrtaServer in LoadECU must be patha that is visible to 13.4

209 Description Description Input/Output Input/Output Description. Description Description Description of return value. value. return of Description Explanation of the functionality of the method.functionalitythe the Explanation of of Each interface method is described in a standard form as follows: follows: as form a standard in described is method interface Each method is provided. the A brief description of Interface IDL syntax. in Parameter Parameter Value Parameter Name Return values

Method Description

Description: Description: Return values: values: Return The title gives the name of the method. method. the of name the gives The title Method declaration: Parameters: 13.4 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.5

210 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 210 13.5 13.6 13.6.3 13.6.2 13.6.1

CVcServer ICVcServer ECU_SLAVE ECU_NOT_LOADED ECU_LOADED NO_ECU SERVER_COMMS SERVER_START STATUS_OK SLAVE AUTO GUI SILENT IVcServer_StartMode Name IVcServer_DisplayMode Name IVcServer_Status Name methods. This enumeration provides slavemode in started or auto-started providesThis enumeration values started with or without its embedded GUI visible. providesThis enumeration values This isthe interface to CVcServer instance. create neededto thea discover information and running / loaded are CVcServer vrtaServer A client must create one or more instances of the based on those in the Virtual ECU Server Library (VesLib).

Enum: IVcServer_Status Enum: IVcServer_StartMode Enum: IVcServer_DisplayMode

implements the interface ECUs what out find ECUs, Virtual load to capability the provides with which they wish to communicate. vrtaServer the return values for all for values return the . that determine whether a VECU is whetheraVECU is that determine whetheraVECU is that determine ICVcServer ICVcServer

CVcServer .

’s constants and API are constants and ’s object for each ICVcServer ICVcServer CVcECU

13.6

211 . vrtaServer Description Description Virtual ECU’s diagnostic interface. Virtual ECU’s diagnostic contains the port number of the virtual virtual the of number port the contains instance. instance. Input/Output Input Output Output alias. A Virtual ECU The TCP port by the number used value. The return diagport Description Description Success. Success. with communicate cannot If object the aliasexist.If the not does loaded. alias been If not the has vrtaServer Method: Connect() Method: AttachECU() Method: AttachECU()

HRESULT _stdcall Connect( [in, defaultvalue(“localhost”)] BSTR hostname, [in, defaultvalue(0)] long port, ) [out, retval] IVcServer_Status *status This method is used to connect to a Virtual ECU that has already been loaded. loaded. been already has that ECU a Virtual to connect to used is method This * return successful On Connect to a Attach to a loaded Virtual ECU. Virtual a loaded to Attach AttachECU( HRESULT _stdcall [in] BSTR alias, [out] int * diagport, ) status [out, retval] IVcServer_Status * ECU's diagnostic interface. interface. ECU's diagnostic Value Parameter Parameter ECU_ALIASED ECU_ALIASED STATUS_OK SERVER_COMMS NO_ECU ECU_NOT_LOADED alias diagport status NOT_LOADED 13.6.5 13.6.4 Method declaration: Method declaration: Description: Description: Method declaration: Method declaration: Parameters: Return values: values: Return RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.6

212 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 212 Return values: Parameters: Method declaration: Description: Parameters: 13.6.6

status alias app SERVER_COMMS SERVER_START STATUS_OK status port hostname Value Value Parameter Parameter object isobject connected. to methods instance of All subsequent the apply the object to check only the specified port. vrtaServer port hostname [out,retval]IVcServer_Status*status ) [out] BSTR*alias, [in]BSTRapp, HRESULT _stdcallCreateAlias( ECU. Virtual a for alias an Create This method connects to TCP port number

Method: CreateAlias() is normally set to zero, in which case the object will search for search object will case the in which tozero, set normally is can be a name (e.g. yok50123) or IP address (e.g. 127.0.0.1). in its default location. A non-zero value can be used to force beusedto can value Anon-zero location. default its in port If the objectIf cannot communicate with If Success. Description vrtaServer . vrtaServer upt Thereturn value. Anew the virtual for alias ECU. path PC (on Thefull the running Output Output Input Thereturn value. TheTCPport being used by Thehostname of PC the running Output Input Input Input/Output Input/Output Input/Output Input/Output cannot be started. on the PC onthe named executable. vrtaServer vrtaServer vrtaServer Description Description vrtaServer vrtaServer hostname ) of a virtual ECU . . to which the using . 13.6

213 . vrtaServer . This method should be method should be . This Description Description vrtaServer . . Input/Output

vrtaServer Description Description Description Description

Success. Success. with communicate cannot If object the exist. does not executable ECU Virtual If the vrtaServer contains a new alias for the virtual ECU. The reference count for the the for count reference The ECU. virtual the for alias a new contains Method: FindECUs() Method: Disconnect()

HRESULT Disconnect( void ) HRESULT Disconnect( void This a method creates new alias afor virtual ECU. On return, successful alias 1.to setalias will been have This method is used to disconnect from disconnect to This method is used called prior to termination of the application, or before connecting to a to connecting before or application, the of termination to prior called of instance different Find out what Virtual ECU executables are present. are present. ECU executables Virtual what Find out HRESULT _stdcall FindECUs( [in] BSTR srchpath, [out] BSTR * path, [out] BSTR * drives, [out] BSTR * subdirs, [out] BSTR * apps, ) [out, retval] IVcServer_Status * status, Disconnect from Value Parameter Parameter Value STATUS_OK SERVER_COMMS NO_ECU 13.6.8 13.6.7 Return values: values: Return Parameters: Parameters: Method declaration: Method declaration: Return values: values: Return Description: Description: Description: Description: Method declaration: Method declaration: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.6

214 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 214 Parameters: Method declaration: Description: Parameters: Return values: 13.6.9

status alias SERVER_COMMS STATUS_OK status apps subdirs drives path srchpath Value Value Parameter Parameter [out, retval]IVcServer_Status*status ) [in]BSTRalias, HRESULT _stdcallFreeAlias( ECU Virtual Free alias. a srchpath vrtaServer This method is used todiscover the virtual ECU executables on absolute path or patha relative to the directory containing

Method: FreeAlias() contains directory theof paththe searched to beeither - as an ’s PC. If the objectIf cannot communicate with Success. Description upt Thereturn value. ECU AVirtual alias. Output Input Thereturn value. Output Output the of Acomma-separated list Thecurrent absolute search path. Output of directory Thepath the be to Output Output Input Input/Output Input/Output Input/Output Input/Output A ‘ A ‘ drives that arereadable. executables. searched for Virtual ECU be Virtual ECUexecutables. in of files names ofsubdirectories ".." for".." a non-root directory. Description Description \n \n ’ separated list of the the of list separated ’ the of list separated ’ vrtaServer vrtaServer path path that could that , including, . .

13.6

215 will . ) of a virtual ECU ECU a virtual ) of vrtaServer vrtaServer ’ separated’ listall aliases of \n Description Description vrtaServer executable. A ‘ ECU Virtual the for exist that executable. ’ separated listallaliases of that \n contains a ‘ contains Input/Output Input Output running the The full(on PC path Output value. The return aliases Description Description Success. Success. with communicate cannot If object the aliasexist.If the not does terminates withoutfreeing then aliases terminates vrtaServer Method: GetAliases()

automatically decrement the reference counts of aliases appropriately.) aliases of counts reference the automatically decrement This method decrements the reference count of the specified virtual ECU alias. alias. ECU virtual specified the of count reference the decrements method This connection the (If zero. reaches count reference its when removed is alias An to exist for Virtual the ECU executable.alias If no existswill then be created. one 1. by incremented is returned alias each of count reference The This method gets a list of all aliases that have been created for a virtual ECU ECU a virtual for created been have that all a aliases of list gets This method executable. return successful On Get a list of the aliases that exist for a Virtual ECU executable. executable. ECU a Virtual for exist that aliases the of a list Get HRESULT _stdcall GetAliases( [in] BSTR app, [out] BSTR * aliases, ) status [out, retval] IVcServer_Status * Parameter Parameter Value app aliases status STATUS_OK SERVER_COMMS NO_ECU 13.6.10 Return values: values: Return Description: Description: Description: Description: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.6

216 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 216 Return values: Method declaration: Parameters: Method declaration: Description: Return values: 13.6.11 13.6.12

NO_ECU SERVER_COMMS STATUS_OK status info alias NO_ECU SERVER_COMMS STATUS_OK Value Value Parameter Value successful return, [out,retval] IVcServer_Status*status ) [out]BSTR* aliases, HRESULT _stdcallListAliases( exist. that aliases of all list a Get [out,retval]IVcServer_Status*status ) [out]BSTR*info, [in]BSTRalias, HRESULT _stdcallGetInfo( information version Get about ECU. a Virtual This function returns version information about the specified

Method: GetInfo() Method: List Aliases() info If the alias does not the If exist. alias the objectIf cannot communicate with Success. If the Virtual ECUexecutable doesnot exist. the objectIf cannot communicate with Success. Description Description contains a ‘ upt Thereturn value. ECU version information. Virtual ECU AVirtual alias. Output Output Input Input/Output Input/Output \n ’ separated list of "key=value" pairs. pairs. "key=value" of list separated ’ Description vrtaServer vrtaServer alias . On . . 13.6

217 . . vrtaServer vrtaServer ’ separated’ listall aliases of ’ separated list of the aliases aliases the of list ’ separated \n \n Description Description Description Description of allof Virtual loaded ECUs. A ‘ exist that A ‘ ’ separated list of the aliases. ’ separated list of the aliases. \n \n contains a ‘ contains contains a ‘ contains Input/Output Input/Output Output Output value. The return Output Output value. The return aliases aliases Description Description Description Description Success. Success. with communicate cannot If object the Success. Success. with communicate cannot If object the Method: ListLoadedAliases() Method: ListLoadedAliases()

This method gets a list of the aliases for all loaded Virtual ECUs. ECUs. Virtual all loaded for aliases the a of list gets method This return successful On Thisa listall gets method aliases of exist. that return successful On 1. by incremented is returned alias each of count reference The The reference count of each alias returned is incremented by 1. 1. by incremented is returned alias each of count reference The Get a list of the Virtual ECUs that have been loaded. loaded. been have that ECUs Virtual the of a list Get HRESULT _stdcall ListLoadedAliases( [out] BSTR * aliases, ) [out, retval] IVcServer_Status * status Value Parameter Parameter Value Parameter Parameter STATUS_OK SERVER_COMMS aliases status STATUS_OK SERVER_COMMS aliases status

13.6.13 Parameters: Parameters: Description: Description: Return values: values: Return Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.6

218 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 218 Parameters: Method declaration: Description: Return values: 13.6.14 ECU_LOADED NO_ECU SERVER_COMMS STATUS_OK status diagport command displaymode startmode alias Parameter Value Value [out,retval]IVcServer_Status*status ) [out]int*diagport, [in]BSTRcommand, [in]IVcServer_DisplayModedisplaymode, [in]IVcServer_StartModestartmode, [in]BSTRalias, HRESULT _stdcallLoadECU( Load a Virtual ECU. If If This method isused load to connect and to ECUa virtual by specified ECU’s diagnosticECU’s interface. On successful return * command If If If If If If

displaymode displaymode startmode startmode Method: LoadECU() specifies additional command line parameters for the Virtual ECU. is is SLAVE AUTO is is SILENT GUI If the alias has already been loaded. been loaded. has already the If alias does not the If exist. alias the objectIf cannot communicate with Success. Description then the isalias loaded in autostart mode. diagport then the isalias loaded in slave mode. then the alias is loaded in isloaded GUI mode. thenthe alias upt Thereturn value. used number bythe TheTCPport line Thecommand thefor Virtual Output Thedisplaymode for the Virtual Output the mode Virtual for Thestart Input ECU AVirtual alias. Input Input Input Input/Output Input/Output then the alias is loaded in silent mode. mode. insilent isloaded then the alias contains the port number of the Virtual Virtual ECU’sdiagnosticVirtual interface. ECU. ECU. ECU. Description vrtaServer alias . . 13.7

219 .

. methods. vrtaServer vrtaServer ICVcECU Description Description . ICVcECU the return values for all Input/Output Output value. The return Description Description Success. Success. with communicate cannot If object the object representsaa to connection Virtual ECU. Itbe can implements the interface interface the implements CVcECU Enum: IVcECU_Status Enum: IVcECU_Status Method: ServerStatus() ServerStatus() Method:

connected to (and disconnected from)(andand to remote connected local disconnected Virtual ECUs. It actions. and events devices, ECU’s Virtual the to access provides CVcECU This method is used to check if the object is (still) connected to (still) to is object if the connected to check isThis used method This enumeration provides This enumeration A ECU. a Virtual to interface the is This Check if the server is still connected. still server Check if the is HRESULT ServerStatus( ) *status retval] IVcServer_Status [out, IVcECU_Status Name Name IVcECU_Status Value Parameter Parameter ECU_OK ECU_DevErr ECU_IDErr ECU_ValErr ECU_ConErr STATUS_OK SERVER_COMMS status ICVcECU ICVcECU CVcECU

13.8.1 13.6.15 Return values: values: Return Description: Description: Method declaration: Method declaration: Parameters: 13.8 13.7 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.8

220 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 220 Parameters: Method declaration: Parameters: Method declaration: Return values: Description: 13.8.2 13.8.3 status ECU_ValErr ECU_OK status port hostname Value Value Parameter Parameter [out,retval]IVcECU_Status*status ) [in]longport, [in]BSTRhostname, HRESULT _stdcallConnect( ECU. Virtual a to Connect [out,retval]IVcECU_Status*status ) HRESULT _stdcallDisconnect( Virtual ECU. from a Disconnect This method causes the object disconnectto from existingany connection. hostname interface is using port isusing port interface This method causes the object to connect to Virtuala ECU whose diagnostic

Method: Connect() Method: Disconnect() Method: Disconnect() can be a name (e.g. yok50123) or IP address (e.g. 127.0.0.1). If the connectionIf cannot be made. Success. Description port upt Thereturn value. Output Thereturn value. ECU’s Virtual of the TheTCPport Thehostname of PC the running Output Input Input Input/Output Input/Output Input/Output Input/Output and that isloaded on the PCnamed diagnostic interface. interface. diagnostic ECU.the Virtual Description Description hostname . 13.8

221 become become . Only use dev GetEventxxx() Description Description and to the device with ID ID with device the to id Input/Output Input The action ID. action Input Input The Output ID. The device value. The return GetActionxxx() Description Description Description Description Success. Success. invalid.If is connection the If the device ID is invalid. Ifaction the ID is invalid. some. been is invalid. I.e. have should data If there sent the Success. Success. a Virtual ECU.to connected not is If object the , Method: DoAction()

invalid. This method disconnects This a from method disconnects Virtual ECU. All interfaces supplied via GetDevicexxx() This method sends the action withThis method action ID the sends this method where the action requires no data. data. no requires action the where method this Send a data-less action to a virtual device. device. a to virtual action a Send data-less HRESULT _stdcall DoAction( [in] long dev, [in] long id, ) [out, retval] IVcECU_Status * status Value Parameter Parameter Value ECU_OK ECU_ConErr ECU_DevErr ECU_IDErr ECU_ValErr dev id status

ECU_OK ECU_ValErr 13.8.4 Return values: values: Return Description: Description: Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.8

222 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 222 Parameters: Method declaration: Parameters: Method declaration: Description: Description: Return values: 13.8.5 13.8.6 device id device id Value Value Parameter Parameter [out, retval]ICVcDevice**device ) [in]BSTRid, HRESULT _stdcallGetDeviceByName( Get an interface to a virtual device by device name. [out,retval]ICVcDevice**device ) [in]longid, HRESULT _stdcallGetDeviceByID( Get an interface to a virtual device by device ID. This method returns an This method returns an with the specified device name. device has ID zero. device ID. specified the with

Method: GetDeviceByID() Method: GetD eviceByName() device. An Description ICVcDevice ICVcDevice ICVcDevice upt Thereturn value. Thedevice name. Output Input Thereturn value. Thedevice ID. Output Input Input/Output Input/Output Input/Output Input/Output NULL NULL is returned if the ID is invalid. The first The first invalid. IDis if the returned is is returned if the name is invalid. isinvalid. name ifthe isreturned interface corresponding to the corresponding to specified interface interface corresponding to the device corresponding the to interface interface corresponding to the device corresponding the to interface Description Description 13.8

223 Description Description interface specified to corresponding the rtualthe devices in Virtual ECU. Input/Output Output value. The return ICVcDevice Description Description Description Description The number of virtual devices in the Virtual ECU. ECU. the Virtual in devices virtual of The number An device. Method: Hook() Method: GetDeviceCount() Method: GetDeviceCount()

This method gets the number of vi of number the gets method This Hook or unhook an event. an event. unhook Hook or HRESULT _stdcall Hook( [in] long dev, [in] long id, [in] long value, ) [out, retval] IVcECU_Status * status Get the number of virtual devices. devices. virtual of number the Get HRESULT _stdcall GetDeviceCount( ) [out, retval] long * count Value Parameter Parameter Value count

13.8.8 13.8.7 Return values: values: Return Return values: values: Return Description: Description: Method declaration: Method declaration: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.8

224 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 224 Parameters: Method declaration: Return values: Description: Parameters: 13.8.9

status value id dev ECU_IDErr ECU_DevErr ECU_ConErr ECU_OK status value id dev Value Value Parameter Parameter [out,retval],IVcECU_Status*status ) [in,out]BSTR*value, [in]longid, [in]longdev, HRESULT _stdcallQueryEvent( event.of an Query (poll)thevalue zero zero the specified event is unhooked. By default eventsall unhooked. are ICVcECUEvents device raises the event a COMeven with ID This method controls whether the event with ID

Method: QueryEvent() dev is hooked or unhooked. If the event ishooked then when the ). If If the event ID is invalid. IDisinvalid. event the If invalid. IDis device the If the connection isIf invalid. Success. Description value upt Thereturn value. Theevent ID. Thedevice ID. the and oncall data input Event Output Input/Output Input Input Thereturn value. event or to hookan zero 1to Theevent ID. Thedevice ID. Output Input Input Input Input/Output Input/Output Input/Output Input/Output isonethe specified event ishooked, if t is fired(viasinkt theevent value of the event on return. event. unhook an Description Description id belonging to the device the belongingto value is is 13.8

225

is id id . On or value dev . . Description Description value belonging to the device with ID id . (Many events have no input data, so so no input have . data, events (Many . The return value is empty if value is empty return . The ReplyFormat() dev and Input/Output Input Input Output ID. The device ID. The event value. The return QueryEvent() Description Description Description Description The input data format string for the specified event. event. specified the for string format data The input Success. Success. invalid.If is connection the If the device ID is invalid. If the event ID is invalid. If the sent is data invalid. QueryFormat() . If the event requires input data then this is passed in this input then data requires .event Ifthe Method: QueryFormat() Method: QueryFormat()

this is often empty.) invalid. offormat thethat the data describes string format This data should be asprovided input to Thedata passed toandfrom the object isstring in form. It can be converted be can that specifiers format the to reference by values native the from/to obtained via successful return the value of the event is in in is event the of value the return successful dev belonging to the device withbelonging to ID the device This method queries the event with ID ID with event the queries method This This method returns the input data-format string for the event with ID with event the for string input data-format the This method returns Get the data format for an event’s input data. input an event’s for format data Get the HRESULT _stdcall QueryFormat( [in] long dev, [in] long id, ) [out, retval] BSTR * value Value Parameter Parameter Value dev id value ECU_IDErr ECU_ValErr ECU_OK ECU_ConErr ECU_DevErr 13.8.10 Return values: values: Return Return values: values: Return Description: Description: Description: Description: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.8

226 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 226 Parameters: Method declaration: Parameters: Method declaration: Description: Return values: 13.8.11 13.8.12 status value id dev value id dev Value Value Parameter Parameter [out,retval]BSTR*value ) [in]longid, [in]longdev, HRESULT _stdcallReplyFormat( Get the data format for an event’s value. [out, retval]IVcECU_Status*status ) [in]BSTRvalue, [in] longid, [in]longdev, HRESULT _stdcallSendAction( Send an containingaction data to a virtual device. id This method returns the data-format string for the the of event value IDwith returned by id

Method: ReplyFormat() Method: SendAction() belonging to the device with ID with device the belongingto is invalid. This data format string describes the format of the data that is QueryEvent() The data format string for the value of the specified event. Description upt Thereturn value. Thedevice ID. Output Action Input The Input Input data. action ID. Thereturn value. Theevent ID. Thedevice ID. Output Input Input Input/Output Input/Output Input/Output Input/Output . dev . Thereturn value isemptyif Description Description dev or or 13.8

227

id . The data . The data is invalid. dev id or dev Description Description to the device with ID ID with device the to id . This shows the format of the data that is data that of the format . This shows the dev Input/Output . return The valueempty is if Input The action ID. action Input InputThe Output ID. The device value. The return Description Description Description Description The data format string for the specified action. action. specified the for string format data The Success. Success. invalid.If is connection the If the device ID is invalid. Ifaction the ID is invalid. If the sent is data invalid. . SendAction() Method: SendFormat() Method: SendFormat()

passed to the object is in string form. It can be converted from the native thethe native is in stringconverted from object Itpassed to form. can be via obtained be can that specifier format the to reference by values SendFormat() This method sends the action with ID the This method sends belonging to the device with ID passed to to passed This method returns the data format string for the action with data the for string ID format the This methodreturns Get the data format for an action. action. an for format data the Get HRESULT _stdcall SendFormat( [in] long dev, [in] long id, ) [out, retval] BSTR * value Value Parameter Parameter Value dev Id value ECU_OK ECU_ConErr ECU_DevErr ECU_IDErr ECU_ValErr 13.8.13 Return values: values: Return Return values: values: Return Description: Description: Description: Description: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.9

228 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 228 13.9 Return values: Parameters: Method declaration: Description: 13.9.1

ICVcECUEvents value id dev Value Value Parameter QueryEvent() via [in]BSTRvalue ) [in]longid, [in]longdev, HRESULT OnEventChange( Event hook callback. been activatedvia virtualwhen deviceraisesa event.an clie by a implemented is interface This value iscalled This method when ahookedevent israised. The of dataformat inthe

Method: OnEventChange() ICVcDevice is the same asthe data returned by . or or ICVcECU.Hook()

Description ICVcEvent nu Theevent ID. Thedevice ID. The Input Input Input event’s value. Input/Output Input/Output does not affect . Hooking or event Hookingor same unhooking the . Note that the event hook must have nt that wishes toreceive COMevents Description ICVcECUEvents ICVcECU method . 13.10

229 method method . is This to CVcECU . Description Description CoCreateInstance() ICVcDevice Input/Output Output value. The return Description Description The ID of the device. device. the The ID of object representsa single objecta device A in Virtual ECU. . It cannot be created via via . be created cannot It object providesability the access to actions the eventsa and of object only be obtained the via must interface the implements CVcDevice CVcDevice Method: DoAction() Method: DeviceID()

This method returns the ID of the device. This is the number by which the the which by number the is This device. the of ID the returns method This zero. ID has device first The ECU. Virtual its within known is device Send a data-less action. Send a data-less This is the interface to a virtual device. device. virtual a to interface the is This ID. device’s the Get HRESULT _stdcall DeviceID( ) [out, retval] long * id A CVcDevice GetDevice() device. the and ECU Virtual the between link the maintain A specifica ECU. in Virtual device CVcDevice Value Parameter Parameter id ICVcDevice ICVcDevice CVcDevice

13.11.2 13.11.1 Return values: values: Return Description: Description: Method declaration: Method declaration: Parameters: 13.11 13.10 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.11

230 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 230 Parameters: Method declaration: Description: Description: Parameters: Method declaration: Return values: 13.11.3 action id ECU_ValErr ECU_IDErr ECU_ConErr ECU_OK status id Value Value Parameter Parameter [out,retval]ICVcAction**action ) [in]longid, HRESULT _stdcallGetActionByID( Getinterface an to an actionby action ID. 1. ID has action This method sends the action ID with withthe specified actionID. This method returns an [out,retval]IVcECU_Status*status ) [in]longid, HRESULT _stdcallDoAction( where the action requires nodata.

Method: GetA ctionByID() If the sent thereIf data shouldhave I.e. isinvalid. been some. IDisinvalid. the action If the connection isIf invalid. Success. Description ICVcAction upt Thereturn value. Output The Input action ID. Thereturn value. Output The Input action ID. Input/Output Input/Output Input/Output Input/Output NULL is returned if the ID is invalid. The first The first invalid. IDis if the returned is id interface corresponding to corresponding to interface the action to this device. Only use this method Description Description 13.11

231 Description Description Description Description interface corresponding to the action action the interface to corresponding interface specified to corresponding the interface specified to corresponding the is returned name if the is invalid. Input/Output Input/Output Output value. The return Input The action name. name. action Input The Output value. The return NULL ICVcAction ICVcAction ICVcAction Description Description Description Description An action. An action. ctionByName() ctionByName() Method: GetActionCount() Method: GetA

This method returns an returns method This with the specified name. name. specified the with Get the number of actions supported by the device. device. the by supported actions of number the Get HRESULT _stdcall GetActionCount( ) [out, retval] long * count Get an interface to an action by name. by name. action an to an interface Get HRESULT _stdcall GetActionByName( [in] BSTR id, ) [out, retval] ICVcAction ** action Parameter Parameter Value Parameter Parameter Value count id action

13.11.5 13.11.4 Return values: values: Return Description: Description: Return values: values: Return Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.11

232 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 232 Return values: Method declaration: Parameters: Method declaration: Description: Return values: Description: 13.11.6 13.11.7 event id Value Value Parameter Value has ID1. with the specified event ID. [out,retval] [out,retval]ICVcEvent**event ) [in]BSTRid, HRESULT _stdcallGetEventByName( Get an interface to an event by name. [out,retval]ICVcEvent**event ) [in]longid, HRESULT _stdcallGetEventByID( Get an interface to an event by event ID. This method returns an This method returns the number of actions supported by the device.

Method: GetE Method: GetE ventByID() ventByName() event. An The number of actions supported by the device. Description Description ICVcEvent ICVcEvent upt Thereturn value. Theevent ID. Output Input Input/Output Input/Output NULL is returned if the ID is invalid. event The first invalid. if IDis the returned is interface corresponding interface to the specified interface corresponding to the event Description 13.11

233 Description Description Description Description pported by the device. device. the by pported interface corresponding to the event event the to corresponding interface interface corresponding to the specified specified the to interface corresponding is returned name if the is invalid. Input/Output Input/Output Input Output name. The event value. The return Output value. The return ICVcEvent NULL ICVcEvent Description Description Description Description The number of events su events of The number An event. event. tEventCount() Method: Hook() Method: Ge

This method returns the number of events supported by the device. device. the by supported events of number the returns method This This method returns an returns method This Hook or unhook an event. an event. unhook Hook or Get the number of events supported by the device. device. the by supported events of number the Get HRESULT _stdcall GetEventCount( ) [out, retval] long * count with the specified name. name. specified the with Parameter Parameter Value Value Parameter Parameter count id event

13.11.9 13.11.8 Parameters: Parameters: Return values: values: Return Description: Description: Description: Description: Method declaration: Method declaration: Parameters: Return values: values: Return RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.11

234 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 234 Parameters: Method declaration: Return values: Description: Description: Parameters: Method declaration: 13.11.10 name ECU_IDErr ECU_ConErr ECU_OK status value id Value Value Parameter Parameter event ishooked, if [out,retval]BSTR*name ) HRESULT _stdcallName( Get the device’s name. all events all unhooked. are fired (viaevent the sink the event ishooked then when the device raises the event COMa event is controlsThis method whether event the ID with This method returns the name of the device. [out,retval]IVcECU_Status*status ) [in]longvalue, [in]longid, HRESULT _stdcallHook(

Method: Name() value If the event ID is invalid. IDisinvalid. event the If the connection isIf invalid. Success. Description ICVcDeviceEvents is zero iszero specified event isunhooked.the Bydefault upt Thereturn value. Output Thereturn value. event or to hookan zero 1to Theevent ID. Output Input Input Input/Output Input/Output Input/Output Input/Output ). If unhook an event. unhook an Description Description id value is hooked or unhooked. ishookedor If is one is the specified 13.11

235 . . If the event requires input requiresIf input . the event Description Description value of the event on return. return. on event the of value id ReplyFormat() . On successful return the value of the event event the of value the return successful . On and Input/Output value Input Input/Output Output Event input data on call and the ID. event The value. The return Description Description Description Description Success. Success. invalid.If is connection the If the event ID is invalid. If the sent is data invalid. The name of the device. device. the of The name QueryFormat() . Method: QueryFormat() Method: QueryFormat() Method: QueryEvent() QueryEvent() Method: value

data then this is passed in is in The data passed toandfrom the object isstring in form. It can be converted be can that specifiers format the to reference by values native the from/to obtained via This method queries (polls) the event with ID ID with event the (polls) queries method This Get the data format for an event’s input data. input an event’s for format data Get the Query (poll) the value an of event. HRESULT _stdcall QueryEvent( [in] long id, [in, out] BSTR * value, ) [out, retval] IVcECU_Status * status Value Parameter Parameter Value ECU_ConErr ECU_IDErr ECU_ValErr ECU_OK id value status

13.11.12 13.11.11 Return values: values: Return Return values: values: Return Description: Description: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.11

236 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 236 Parameters: Method declaration: Description: Description: Parameters: Method declaration: Return values: Return values: 13.11.13 value id value id Parameter Value Parameter Value Value [out,retval]BSTR*value ) [in]longid, HRESULT _stdcallReplyFormat( Get the data format for an event’s value. This method This method data-format the returns string input thefor event with ID id This method returns the data-format string for the the of event value IDwith [out,retval]BSTR*value ) [in]longid, HRESULT _stdcallQueryFormat( return value is empty if the format of the data that is returned by (Many events have no input data, so this is often empty.) of theformat data that shouldbeprovided as to input . Thereturn isempty value if

Method: ReplyFormat() The data format string for the value of the specified event. The input data format string for the specified event. Description Description id upt Thereturn value. Theevent ID. Output Input Thereturn value. Theevent ID. Output Input Input/Output Input/Output Input/Output Input/Output is invalid. This data format string describes describes the string data format This invalid. is id is invalid. This data format string describes format string This data invalid. is QueryEvent() Description Description . QueryEvent() id . The . 13.11

237 . SendFormat() Description Description Description Description to this device.The data passed to the id Input/Output Input/Output Input The action ID. action InputThe Output value. The return Input The action ID. action data. Input The Input Action Output value. The return Description Description Success. Success. invalid.If is connection the Ifaction the ID is invalid. If the sent is data invalid. Method: SendFormat() Method: SendFormat() Method: SendAction() SendAction() Method:

object is in string form. It can be converted from the native values by by values native the from converted can be It form. string in is object via obtained be can that specifier format the to reference This method sends the action ID with the sends This method Get the data format for an action. action. an for format data the Get HRESULT _stdcall SendFormat( [in] long id, ) [out, retval] BSTR * value Send an action containing data. SendAction( HRESULT _stdcall long id, [in] [in] BSTR value, ) * status [out, retval] IVcECU_Status Parameter Parameter Value Parameter Parameter id value ECU_OK ECU_ConErr ECU_IDErr ECU_ValErr id value status

13.11.15 13.11.14 Return values: values: Return Description: Description: Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.11

238 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 238 Description: Return values: Value Value value is empty if empty is value shows the format of the data that is passed to This method returns the data format string for the action with ID id is invalid. invalid. is The data format string for the specified action. Description SendAction() . Thereturn id . This 13.12

239 . method method ICVcDevice ICVcDeviceEvents Description Description . Hooking or the unhooking same nt that wishes to receive COM events COM events to receive wishes that nt Note that the event hook must have have must hook event the that Note does not affect does not Input/Output Input The event’s value. event’s Input InputThe ID. event The ICVcEvent ICVcEvent Description Description

ICVcDevice.Hook() or or . ICVcECU is the same as the data returned by by returned data as the same the is Method: OnEventChange() OnEventChange() Method:

QueryEvent() This method is called when a hooked event is raised. The format of the data in the in format data of The is raised. a hooked event when This method is called value been activated via via activated been via event This interface is implementeda by clie an event. araises device when virtual callback. hook Event HRESULT OnEventChange( [in] long id, ) [in] BSTR value Value Parameter Parameter id value ICVcDeviceEvents ICVcDeviceEvents

13.12.1 Return values: values: Return Description: Description: Method declaration: Method declaration: Parameters: 13.12 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.13

240 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 240 13.13 13.14 Parameters: Method declaration: Return values: Description: 13.14.1

CVcAction CVcAction ICVcAction ICVcAction id Parameter Value Value CVcAction A the action. CoCreateInstance() method method [out,retval]long*id ) HRESULT _stdcallActionID( Get the action’s ID. This is the interface to a virtual device action. A ECU. Virtual A action is known within its device. The first action has ID 1. This method returns the ID of the action. This is the number by which the

Method: ActionID() CVcAction CVcAction implements the interface GetActionxxx() object provides the ability to send Virtual to the ECU. an provides object a ability action CVcAction object represents a single action on a specific deviceina specific ona single action represents a object The IDof the action. Description . This is to maintain link the device between the and to maintain is This . upt Thereturn value. Output Input/Output Input/Output object must onlybeobtained must object via the . It cannot be created via cannot It becreated . ICVcAction Description . CVcDevice

13.14

241 Description Description Description Description Input/Output Input/Output Output value. The return Output value. The return Description Description Description Description The name of the action. action. the of name The Success. Success. invalid.If is connection the some. been is invalid. I.e. should have data If there sent the Method: Name() Method: Do()

This method returns the name of the action. action. the of the name returns method This This method the sends action. Only use this method where the action requires no data. Get the action’s name. name. action’s the Get HRESULT _stdcall Name( ) [out, retval] BSTR * name Send a data-less action. Send a data-less Do ( HRESULT _stdcall ) * status retval] IVcECU_Status [out, Parameter Parameter Value Value Parameter Parameter name ECU_OK ECU_ConErr ECU_ValErr status 13.14.3 13.14.2 Description: Description: Return values: values: Return Description: Description: values: Return Method declaration: Method declaration: Parameters: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.14

242 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 242 Parameters: Method declaration: Parameters: Method declaration: Description: Description: Return values: 13.14.4 13.14.5 value ECU_ValErr ECU_ConErr ECU_OK status value Value Value Parameter Parameter [out,retval]IVcECU_Status*status ) [in]BSTRvalue, HRESULT _stdcallSendAction( data. containing action Send an [out, retval]BSTR*value ) HRESULT _stdcallSendFormat( Getthedata format for an action. that canthat beobtained via It be can converted from the native values by reference to the format specifier sends passed form. the Thedata This method isinstring the to object action. format of the data that is passed to Thismethod returns thedata format string forthe action.This shows the

Method: Send() Method: SendFormat() If the sent data is invalid. invalid. data is sent the If the connection isIf invalid. Success. Description SendFormat() upt Thereturn value. Output Thereturn value. Output Action Input data. Input/Output Input/Output Input/Output Input/Output Send() . . Description Description 13.14

243 Description Description The data format string for the specified action. action. specified the for string format data The

Value

Return values: values: Return RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.15

244 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 244 13.15 13.16 Parameters: Method declaration: Description: Return values: 13.16.2 13.16.1

CVcEvent ICVcEvent id Parameter Value Value CVcEvent raised by virtual devices. disable and enable also It can event. A to maintain the linkbetween the device and the event. Hook or unhook the event. [out,retval]long*id ) HRESULT _stdcallEventID( Get the events’s ID. This is the interface to a virtual device event. GetEventxxx() A ECU. A event isknown within its devi returnsThis method the the IDof event. This is number the by thewhich

Method: Hook() Method: EventID() CVcEvent CVcEvent CVcEvent implements the interface object represents a single event on a specific device in a Virtual specific ondeviceina singleevent a a represents object object provides the ability to query the current value of anvalue current the to query the provides ability object . It cannot be created via via becreated cannot It . object must only be obtained via the the via onlybeobtained must object The IDof the event. Description upt Thereturn value. Output Input/Output Input/Output ce. The first event has ID 1. ICVcEvent the raising of COM events for events CoCreateInstance() Description . CVcDevice method . This is is This . 13.16

245 Description Description Description Description unhook the event. event. unhook the is one the event is hooked, if is hooked, the event is one the event a COM event is fired (via the the (via fired is COM event a event the value ). If ). If Input/Output Input/Output Output value. The return Input Output zero to or event 1 to hook the value. The return Description Description Description Description The name of the event. event. the of The name Success. Success. invalid.If is connection the ICVcEventEvents is zero the event is unhooked. By default all events are unhooked. all events default By unhooked. is event the is zero Method: Name()

HRESULT _stdcall Hook( HRESULT _stdcall [in] long value, ) * status retval] IVcECU_Status [out, This method returns the name of the event. event. the of name the returns method This This method controls whether the event is hooked or unhooked. hooked If is the the event whether event This method controls device raises the when is hooked then event sink Get the event’s name. name. event’s the Get HRESULT _stdcall Name( ) [out, retval] BSTR * name value Parameter Parameter Value Value Parameter Parameter name

ECU_OK ECU_ConErr value status 13.16.3 Parameters: Parameters: Method declaration: declaration: Method Description: Description: Return values: values: Return Description: Description: Method declaration: Method declaration: Parameters: Return values: values: Return RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.16

246 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 246 Return values: Parameters: Method declaration: Parameters: Method declaration: Description: 13.16.4 13.16.5 value ECU_ValErr ECU_ConErr ECU_OK status value Value Value Parameter Parameter from/to the native values by reference to the section on data format specifiers. converted be Itcan form. in string is object the from and to passed data The [out,retval]IVcECU_Status*status ) [in,out]BSTR*value, HRESULT _stdcallQueryEvent( event.of an Query thevalue [out,retval]BSTR*value ) HRESULT _stdcallQueryFormat( theGet data format for an event’s input data. passed in queriesThis method the event. If eventthe input requires data then this is

Method: Query() Method: QueryFormat() value . On successful return the value of the event is in If the sent data is invalid. invalid. data is sent the If the connection isIf invalid. Success. Description upt Thereturn value. Output Thereturn value. the and oncall data input Event Output Input/Output Input/Output Input/Output Input/Output Input/Output value of the event on return. Description Description value . 13.16

247 Description Description Input/Output Output value. The return Description Description Description Description The data format string for the value of the event. event. the of value the for string format data The The input data format string for the event. event. the for string format data input The . (Many events have no input data, so this is often empty.) this often empty.) is so data, no input have . (Many events . Query() Method: ReplyFormat() Method: ReplyFormat()

This method returns the input data-format string for the event. This data data This event. the for string input data-format the returns This method as be provided should formatthat the format data the of describes string input to This method returns the data-format string for the value of the event. This This event. the of value the for string data-format the returns method This by returned is that data the of format the describes string format data Query() Get the data format for an event’s value. value. event’s an for format data the Get HRESULT _stdcall ReplyFormat( ) [out, retval] BSTR * value Value Parameter Parameter Value value 13.16.6 Return values: values: Return Description: Description: values: Return Description: Description: Method declaration: Method declaration: Parameters: RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference and Tutorial Bridge COM

13.17

248 COM Bridge Tutorial and Reference RTA-OSEK for RTA-OSEK PCUser Guide COM Bridge Tutorial and Reference 248 13.17 Parameters: Method declaration: Description: Return values: 13.17.1

ICVcEventEvents value Value Value Parameter [in]BSTRvalue ) HRESULT OnEventChange( Event hook callback. event via been activated via virtualwhen deviceraisesa event.an clie by a implemented is interface This value iscalled This method when ahookedevent israised. The of dataformat inthe

Method: OnEventChange() is the same as the data returned by ICVcECU or ICVcEvent.Hook()

Description ICVcDevice Input The Input event’s value. Input/Output Input/Output does not affect Note that the event hook must have nt that wishes toreceive COMevents . Hooking or unhooking the same unhookingthe Hookingor . ICVcEvent Description ICVcEventEvents method method Query() . . 13.17

249 and a a and is always is long , a double int will work with a is provided. windows.h RTA-OSEK for PC . As an. As illustration, willa add we new to include details of the variant. variant. the of details include to are stored in memory in the order they they in the order in memory are stored are aligned on natural boundaries. i.e. a boundaries. i.e.aligned natural are on that that for a new variant consists of three steps: steps: three of consists variant a new for type is 64 bits. struct struct type is 16 bits.type is type is 32 bits. bits. 32 is type type is 8 bits.type is 8 type is 32 bits.type is 32 type is 32 bits. type is 32 char short int long float double toolinit.bat has been designed to work with almost any PC C/C++ C/C++ PC any almost with work to designed been has is always aligned on a 16 bit an boundary, is always aligned on a 32 bit and aboundary cannot guarantee cannot RTA-OSEK for PC for RTA-OSEK MinGW/gcc (tested with version 3.4.2) version 3.4.2) with (tested MinGW/gcc 5.0 C++ Visual Microsoft 2003 Studio Visual Microsoft 5 Builder C++ / Borland 5..5.1 C++ Borland 2006 Studio Developer Borland / Borland C++ 5.8.1 The C/C++ The C/C++ The C/C++ The C/C++ The C/C++ The C/C++ The C/C++ The C/C++ The C/C++ The C/C++ The compiler includes header files andheaderThe compiler files to includes libraries the support Windows API. e.g. the fileheader a C within Fields The C/C++ The C/C++ definition. structure the in occur a C Fields within short float boundary. a64 bit aligned on Modifying Creating initializationan RTA-OSEK for file the variant. wrappers.floating-point new Possibly creating

• • • • • • • • • • • • • • • • • RTA-OSEK for PC RTA-OSEK for compilers: following the with work to pre-configured is It compiler. LiveDevices LiveDevices compiler that above is in the not lista good chance therethat but is will it as following rules: the compiler obeys the long as Each different supported is called compiler by RTA-OSEK a “variant”. Configuring The first step is to think of a name for the new variant. This should be be This should the variant. new for a name of think to is step The first letters, contain can (i.e. rules identifier C follow should and short reasonably numbers and ‘_’ and is case sensitive) variant that is a variation of the standard MinGW/gcc variant that has has that variant MinGW/gcc standard the of a variation is that variant we variant is called “MinGW”; standard MinGW/gcc debugging enabled. The will call the new variant “MinGW_DBG”. Compiler Configuration Configuration Compiler

14 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Compiler Configuration

14.1

250 Compiler Configuration RTA-OSEK for RTA-OSEK PC User Guide Configuration Compiler 250 14.1

Modifying Toolinit.bat Toolinit.bat Modifying Further on in is “MinGW_DBG” specified. when variant the The lineinboldmakes example: toolinit.bat environment for specific a variant. The variant name is passed into These of Near thetop new variant. You need to will modify directories. containingpaths the to compiler, assembler,linker and compilerheader file The variable. Weneed to add an analogous rem locationofCcompiler set CBASE=c:\mingw rem toolsinstallationdirectory :MINGW rem ======MINGW======if @%VRTA%@==@MinGW_DBG@gotoMINGW_DBG if @%VRTA%@==@VS2003@gotoVS2003 if @%VRTA%@==@VisualC5@gotoVCPP5 if @%VRTA%@==@BDS2006@gotoBDS_2006 if @%VRTA%@==@BorlandC@gotoBCPP if @%VRTA%@==@MinGW@gotoMINGW if not@%1==@setVRTA=%1 if @%VRTA%@==@VS2003@gotoVS2003 if @%VRTA%@==@VisualC5@gotoVCPP5 if @%VRTA%@==@BDS2006@gotoBDS_2006 if @%VRTA%@==@BorlandC@gotoBCPP if @%VRTA%@==@MinGW@gotoMINGW if not@%1==@setVRTA=%1 set CBASE_INC=%CBASE%\include rem Setlocationof C includefiles set AR=%CBASE%\bin\ar.exe rem locationofArchiver/librarian set LNK=%CBASE%\bin\g++.exe rem locationoflinker set AS=%CBASE%\bin\gcc.exe rem locationofC++compiler set CC=%CBASE%\bin\gcc.exe toolinit.bat if statements branch tothe part of toolinit.bat toolinit.bat eitheronthecommand lineorinthe fileis used by RTA-OSEK to setup environment variables toolinit.bat you will see blocks of statements like: like: statements see blocks you of will you will see a block of statements like: like: blockofstatements see you will a toolinit.bat if branch to the label statement for our new variant. For toolinit.bat to add support for a support add to VRTA that sets up the environment MINGW_DBG

14.1

251

) AS _OBJ _LIBS winmm . the OSEK ). The ). in the line: in the ws2_32 osgen.cpp for examples. examples. for ) so we need to arrange arrange to we need ) so RTA-OSEK for PC RTA-OSEK for gcc.exe ) and RTA-OSEK uses the the uses RTA-OSEK and ) riable settingswill be the sameas osgen.cpp toolint.bat ould be self explanatory. The explanatory. self ould be looks like: osgen.asm devices and the winsock2 libraryand( the devices winsock2 toolinit.bat vrtaClock set AS=%CBASE%\bin\gcc.exe files rem Set location of C include set CBASE_INC=%CBASE%\include rem Default settings SET _LIBS=-lwinmm -lws2_32 SET _OBJ=o goto check rem tools installation directory rem tools installation directory set CBASE=C:\mingw rem location of C compiler set CC=%CBASE%\bin\gcc.exe rem location of C++ compiler set AS=%CBASE%\bin\gcc.exe rem location of linker set LNK=%CBASE%\bin\g++.exe librarian rem location of Archiver / set AR=%CBASE%\bin\ar.exe goto check ======rem ======MINGW Debugging :MINGW_DBG rem Default settings settings rem Default -lws2_32 SET _LIBS=-lwinmm SET _OBJ=o variable contains the object file suffix. suffix. file object the contains variable as assembler the set we that One slight is oddity configuration in a is generated C++ file ( for RTA-OSEK to use the C/C++ compiler to “assemble” “assemble” to compiler C/C++ the use to RTA-OSEK for needed by variable to find the assembler to assemble it. In In it. assemble to assembler the find to variable variable contains the default libraries need when a Virtual ECU executable is a is ECU executable the default need when Virtual libraries contains variable multi-medialinked.we HereWindows specified the have library ( This is because in a configurationtheThis is is in OSEK standard because port RTA-OSEK assemblygeneratedan file ( in up sh set variables The environment addAgainasection is to our for variant. we new Since our variant need new also MinGW/gcc using environment the va a for a variant adding were you if Obviously variant. MinGW standard the Have different. be would settings variable environment the compiler different in variants standard other the at a look sectionOur in new RTA-OSEK for PC User Guide PC User RTA-OSEKfor Compiler Configuration

14.2

252 Compiler Configuration RTA-OSEK for RTA-OSEK PC User Guide Configuration Compiler 252 14.2

Creating a new Variant anewVariant Creating “ our for file The initialization Guide “ variant called “ The next step is to create description a file for the new variant. The file for a vrta_MinGW_DBG.ini bin ; The"assembler"optiontosetaninclude a_insertopt=" -o%o%" ; objectfile. ; Insertan"assembler"commandtospecifythe osekdefsc_defopt="-c -g" ; Theoptionsusedtocompileosekdefs.c. c_defopt="-c -g" ; Thedefaultcompilationoptions. c_define="-D" ; Thecompileroptiontodefineamacro. c_include="-I" ; Thecompileroptiontosetanincludedirectory. c_insertopt=" -o%o%" ; file. ; Insertacompilercommandtospecifytheobject asm_env="c" ; fileratherthananassemblyfile. ; RememberthatinRTA-OSEKforPCosgenisaC++ ; nameoftheassemblyfiletobeassembled. ; theenvironmentvariable%c%shouldcontain ; TellRTA-OSEKthatwhentheassemblerisinvoked obj_env="o" ; nameoftheobjectfiletobecreated. ; theenvironmentvariable%o%shouldcontain ; TellRTA-OSEKthatwhenthecompilerisinvoked c_env="c" ; nameoftheCfiletobecompiled. ; theenvironmentvariable%c%shouldcontain ; TellRTA-OSEKthatwhenthecompilerisinvoked StackName0=Processor Stack numstacks=1 Target=Virtual [globals] ; The"assembly"file suffix.Rememberthatin extobj="o" ; Theobjectfilesuffix. osgen_defopt="%AOPTS% " ; settings. ; "assembly"optionsthatincludethe path ; %AOPTS%herebecausewewantthedefault ; Theoptionsusedto"assemble"osgen.cpp. Weuse a_defopt="-c -g" ; Thedefault"assembly"options. a_define="-D" ; The"assembler"optiontodefineamacro. a_include="-I" ; directory. ” directory. The “Target .ini files” chapter of the contains full details of how to write an initialization file. file. initialization ofhowto write an details full contains XXXX ” is called “ called ” is ” and look” like: and vrta_XXXX.ini new variant will be called becalled will new variant ”. This file should be in the the shouldbein Thisfile ”. RTA-OSEK Reference 14.2

253 RTA- to be be to osgen.cpp will contain the options to “assemble” a general a containto “assemble” general will options the AOPTS header files. These header files are needed to “assemble” are needed to “assemble” files header files. These header . An alternative would be to use the line: the use to would be alternative . An ”. osgen_defopt="-c –g -I. -I%APPL_INC% -I%RTA_INC% - I%CBASE_INC% " 0x16=23 0x17=24 0x18=25 0x19=26 0x1a=27 0x1b=28 0x1c=29 0x1d=30 0x1e=31 0x1f=32 0x8=9 0x9=10 0xa=11 0xb=12 0xc=13 0xd=14 0xe=15 0xf=16 0x10=17 0x11=18 0x12=19 0x13=20 0x14=21 0x15=22 ; The library file extension. ; The library extlib="a" the the interrupt vectors have ; Ensure that names here). (you can put descriptive ; correct names [vectors] 0x0=1 0x1=2 0x2=3 0x3=4 0x4=5 0x5=6 0x6=7 0x7=8 ; RTA-OSEK for PC osgen is a C++ file rather than file rather than is a C++ for PC osgen ; RTA-OSEK file. ; an assembly extasm="cpp" %AOPTS% also used tooptions “assemble” set theWe have “ assemblyand file will include directivesinclude pathstothe set up to OSEK for PC osgen.cpp RTA-OSEK for PC User Guide PC User RTA-OSEKfor Compiler Configuration

14.3

254 Compiler Configuration RTA-OSEK for RTA-OSEK PC User Guide Configuration Compiler 254 14.3

Floating-point Wrappers Wrappers Floating-point osfptgt.h needto modify will you wrappers floating-point wrappers floating-point for the standard variants. If you use to wish your own behavior. The default change the your provide own code save to the youneed registers if floating-point to code is Default provided in VMto do th use floating-point canand preempt other FP tasks ISRs. or RTA-OSEK saves the processor’s floating-point registers for tasks ISRsand that The files ishow done.this osfptgt.c for your new compiler. and osfptgt.h RTA-OSEK BindingManualPC RTA-OSEK contain examples of examples contain user-provided is. However, it ispossibleis. However, it you for to osfptgt.c has details on has and 15.1

255 ). ). is: is: mode. In

vecu.exe . to be used as the Virtual Virtual as the used be to it is normallyan assigned name vrtaMonitor of the Virtual ECU. Note that options options that Note ECU. Virtual the of ine but can be recovered by your code code your by be recovered ine but can option can be used; where be used; option can and vrtaServer . If you wish to run a Virtual ECU at a different aat different ECU a Virtual run to wish you . If causes the token vrtaServer option tells a to Virtual look in the ECU license file the Windows priority) –priority= option causes a Virtual ECU to be loaded in silent in loaded be to ECU a Virtual causes option Executables Executables Windows Priority Class Class Priority Windows for a valid for license. –alias=name –silent –lic= -silent (select silent or GUI mode) or silent (select -silent -priority= (set -alias=name (override the default alias) alias) the default -alias=name (override file) license a (select -lic=

silent mode the Virtual ECU does not display its own (embedded) GUI (it is (itown (embedded) GUI display its Virtualsilent does not the mode ECU Increasingthe priority aof Virtual will improve ECU closely how it approximates “real-time” behavior will but negatively affect the performance applicationsPC. of same in the other running The By default a Virtual ECU runs at the Window’s priority priority Window’s the at runs ECU a Virtual default By NORMAL_PRIORITY_CLASS the Windows priority other than those listed below may be used with a Virtual ECU executable and and executable ECU Virtual a with used be may below listed those than other Virtualwillthe they be ignored Mach by the ApplicationManager.by querying with registers ECU a Virtual When (e.g. executable ECU’s Virtual the of name the simply is that alias The This chapter provides a list of the command line options that are supported by by supported are that options line command the of a list provides chapter This executables, ECU Virtual ECU a Virtualwhen used can be listed line options below The command the behavior control is run to executable The option possible).alias (if ECU’s 3 ABOVE_NORMAL_PRIORITY_CLASS 4 HIGH_PRIORITY_CLASS 5 REALTIME_PRIORITY_CLASS 0 IDLE_PRIORITY_CLASS 1 BELOW_NORMAL_PRIORITY_CLASS 2 NORMAL_PRIORITY_CLASS Virtual ECU Command Line Option Reference Reference Option Line Command

15.1.4 15.1.3 15.1.2 15.1.1

15.1 15 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Option Line Command

15.1

256 Command Line Option Reference RTA-OSEK for RTA-OSEK PCUser Guide Command Line Option Reference 256 15.1.5 mode. In mode. the If Virtual ECU). assumed that The application thread returns from Inautostart mode the VirtualMachine terminates immediately after the vrtaStart() mode. In autostart mode the application thread starts immediately after the the If until a Terminate actionwaits is sent to the Application Manager. application threadreturns from slaveIn mode Virtual the Machine not does terminateimmediately after the thread.starting theapplication Machine waits until Start a action is sent to the Application Manager before vrtaStart() mode the application thread is not started immediately after the

-slave (select slave or autostart mode) –slave –silent –slave GUI optioncauses Virtual ECUtobeloadeda mode. Inslave inslave mode the Virtual ECU displays its own GUI. vrtaMonitor option is used ECU loads in option not then the Virtual autostart Virtual Machine API has been called. been APIhas called. Machine Virtual Virtual Machine API has been called. Instead the Virtual the Virtual APIhas been Instead Machine called. Virtual option is not used then the Virtual ECU is loaded inGUI ECUis used not option Virtual is then the or a similar program will be used to control the control beused programto will or similar a OS_MAIN() OS_MAIN() . . Instead the Virtual Machine Machine Virtual the Instead . 15.2

257

– to to –standalone vrtaServer to run as a standalone a standalone as run to to in the license file look . to install to itselfaas Windows option forces option can be a or can be hexadecimal decimal –p option the stops message confirmation vrtaServer vrtaServer –uninstall vrtaServer and option is also specified a confirmation message message a confirmation also option specified is –silent Server service) service) Server standalone mode) option tells for connections. for –install option causes causes option –silent is installed as service but has not been started then the the then started been not has but as service installed is option causes causes option rather than installinga service the use as then it searches a pre-defined set of TCP ports for an empty port on port empty an ports for TCP of set pre-defined a searches supports the command line options listed below. listed line options command the supports for a valid for license. option will causethe service started.You do not to normally be have –standalone -install –lic= prefix) number. number. prefix) vrtaServer -standalone (run in -start (start the vrta -silent (silent install or uninstall) uninstall) or install (silent -silent -install (install as a service) a service) as (install -install file) license a (select -lic= port) -p (specify the TCP 0x

option. being displayed. See being displayed. See Windows applicationaWindows rather as you want service. than If to run manually vrtaServer start to start service the yourself – a VECU or vrtaMonitor will start the serviceit if needs to. If Installation and as aun-installation Windows service a normally generates confirmation message. The The The vrtaServer The connections. for listenwhich to vrtaServer The listen on TCP port ( service. Unless the will be displayed. vrtaServer vrtaServer

15.2.6 15.2.5 15.2.4 15.2.3 15.2.2 15.2.1 15.2 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Option Line Command

15.2

258 Command Line Option Reference RTA-OSEK for RTA-OSEK PCUser Guide Command Line Option Reference 258 15.2.8 15.2.7 If If message will be displayed. bedisplayed. message will the If service. Windows The option will cause will theoption service to be stopped.

-uninstall (un-install as aservice) -stop (stop thevrtaServer service) vrtaServer -uninstall is installed as isinstalled serviceas and has been started then the option causes –silent option is not confirmation isnot option specified also a vrtaServer to uninstall itself as a itself uninstall to –stop

15.3

259

global on its . @ . . It doesmatter not in a command file.If to run until the file file the until run to vrtaMonitor –alias when auto-connection requested requested auto-connection when vrtaMonitor vrtaMonitor vrtaMonitor to terminate with a specific error level level error specific a with terminate to timeout. timeout. . –t –f must bea on separate line. vrtaServer vrtaMonitor options tells tells options supports two sets of command line options. The line options. The command of sets two supports encounters a statement of the formthe a of statement encounters options are processed in the order they appear on the the appear on they the order in are processed options appears and then to terminate. terminate. to then and appears Event Cannot connect toCannot connect line. command the from . Each option in in option . Each option causes causes option –f sequential –k -k (terminate with specific error level) level) error with specific -k (terminate -f (close when appears) appears) when (close -f Command Files Command Files

The The following options affect the overall operation of operation overall affectthe options The following The whencertain events occur. vrtaMonitor Command line options can be passed to options affect the overall operationaffectoverall options of the line. command in the appear options global where the The commandline. command line it will start processing line options command from file the vrtaMonitor Error level level Error 7 Failed to load. 3 to 4 5 6 ECU. Virtual a specified auto-load Cannot 7 Failed Closed as a result a of 8 Cannotscripting engine. load 9 Cannot run a script. Closed as a result of Failed an to send action an or event. receive 1 2 alias to an specified via attach Cannot vrtaMonitor Global Options vrtaMonitor vrtaMonitor

15.4.2 15.4.1 15.3.1 15.4 15.3 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Option Line Command

15.5

260 Command Line Option Reference RTA-OSEK for RTA-OSEK PCUser Guide Command Line Option Reference 260 15.5 15.4.4 15.4.3 15.5.3 15.5.2 15.5.1 15.4.6 15.4.5

vrtaMonitor Sequential Options Sequential Options vrtaMonitor The The The the not PC remote or dependingonwhether PCor a beontheexecutable local may command line it attempts to load the named Virtual ECU. The Virtual ECU If line. command onthe they appear processed order inthe are options The following terminate. The rtaScript.dll The The host vrtaMonitor alias the has that ECU Virtual (loaded) existing started. howVirtual the ECUis auto-loaded.

-log= (write to a logfile) -lic= (select a license file) -d (loadbutnotstart a Virtual ECU) -alias= (connecttoVECU) Virtual ECU Executable Name (auto-load) -t (closeafter seconds) -scripter= (select ascripting engine) vrtaMonitor –d –lic= –log= –alias= –t option option should be used. –scripter= options causes the next Virtual ECU auto-loaded to be loaded but not –host . options tells for a valid license. license. for a valid optionhas beenused. The assumes the Virtual ECU is on the local PC. If it not PC. the is If on ECUis the local Virtual the assumes encounters the name of ECUa Virtual executable on its options causes options option tells tells option option tells tells option vrtaMonitor . option option selects the scripting engine called vrtaMonitor vrtaMonitor vrtaMonitor to run for –d , -r , to try to connect to and an to log activity to the file to look in the license file license lookinthe to -n and and seconds and then seconds and –g options options affect . Bydefault. – 15.5

261 and and prefix) 0x –alias to monitor the the monitor to on a set of pre- ) or auto-loaded. auto-loaded. ) or is listening on port port is listening on in the Virtual ECU to to ECU Virtual the in to run the script in the the in script the run to -alias vrtaMonitor vrtaServer vrtaServer to terminate. terminate. to This is the default when auto-loading auto-loading when default the is This that that vrtaMonitor looks for for looks is the host name of the remote PC. PC. remote the of name host the is may be a may be decimal or ( hexadecimal options tells option selects the remote PC for the the for PC remote the selects option vrtaMonitor optioncauses vrtaMonitor from the device called called device the from has most recently attached ( attached recently most has vrtaMonitor . Please contact LiveDevices if you need information on monitor on monitor information you need if LiveDevices . Please contact option tells option option causes causes option options causes the next Virtual ECU auto-loaded to run with an an with run to auto-loaded ECU Virtual next the causes options options causes the next Virtual ECU auto-loaded to be loaded and loaded toauto-loaded be ECU next Virtual the causes options options causes the next Virtual ECU auto-loaded to run without an without run to auto-loaded Virtual next ECU the causes options vrtaMonitor –mon=. –g –r –n –host= –script= –p –quit . By default -script= -script= -quit (terminate) a VECU) –r (load and start -p (select TCP port) TCP port) (select -p -host= (select a remote PC) PC) remote a (select -host= event) (monitor -mon=. –n (load without a GUI) -g (load with a GUI)

defined TCP port numbers. number. embedded GUI (i.e.run in silent mode). ECU. a Virtual file scripts. The ECU. a Virtual auto-loading when default the is This started. The The The The The The The embedded GUI (i.e. run in GUI mode). in GUI GUI (i.e.run embedded auto-load options. event called which 15.5.11 15.5.10 15.5.9 15.5.8 15.5.7 15.5.6 15.5.5 15.5.4 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Reference Option Line Command

15.5

262 Command Line Option Reference RTA-OSEK for RTA-OSEK PCUser Guide Command Line Option Reference 262 15.5.13 15.5.12 15.5.15 15.5.14 which vrtaMonitor The string The milliseconds before processing themilliseconds next command line option. The The The called action thecalled action Application of Manager ECUtheApplication next Virtual auto-loaded.

-send=.() (send action) -send=. (send action) -wait= (wait) -start (startaVECU) –send=. –wait= –send=.() –start vrtaMonitor option tells has most recently attached ( option causes option is sent asactiondata. tothe device called hasmost recently attached ( to the device called options tells tells options vrtaMonitor vrtaMonitor options tells vrtaMonitor to sendStart a actiontothe -alias to wait for approximately in the Virtual ECU to which -alias ) or auto-loaded. auto-loaded. or ) vrtaMonitor in the Virtual ECU to to send the data-less ) or or auto-loaded. ) to send

16.1

263

calls. ndows PCs. For example, consider an consider For example, ndows PCs. you expect for timing reasons you can you can timing reasons for you expect r on a Windows PC it may only take 0.5 0.5 take only may PC it a Windows on r vrtaEnterUninterruptibleSection() tries very hard to simulate the behavior of a real a real of behavior the simulate to hard very tries command line options. command ). Few C/C++ runtime functions or Windows API Windows API or functions runtime). Few C/C++ etc.). The VECU first tries to load the VM DLL using the the using DLL VM the load to tries first VECU The etc.). OS_MAIN() )functiona Windows or API it mustmakecallthe in an RTA-OSEK for PC Shutdown other Windows applications moreso that of the processor’s ECU. Virtual the to dedicated be can time ECU – see the the Virtual priority of the process Increase -priority=

vrtaLeaveUninterruptibleSection() • • vrtaVMs.dll When a Virtual ECU is started it tries to load the appropriate VM DLL DLL VM appropriate the load to tries it started is ECU a Virtual When ( In order to simulate interrupts in a Virtual ECU, the Virtual Machine has to to has Machine Virtual the ECU, a Virtual in interrupts simulate to order In thread (the application thread the of stack the manipulate asynchronously that calls and Although applicationan aWhen real embedded runs ECU the on application is the only code using the ECU’s As athe processor. real-time is result behavior the anapplicationpredictable.to a share running ECU has However in Virtual processorapplications with other andWindowsitself. a result As it is not possible to completely predict the of behavior real-time applications running ECUs. Virtual in applications Despite this, that the whole on shown has our experience to is due real-timeto This behavior. close exhibit very running ECUs in Virtual Wi of speeds processor fast the very ECU,alongside ultimatelyWindows Virtual are other running ECUs under applications. This chapter contains aboutnotes relatedWindows that behavior find useful. may developers a input process fromtoandthen application readembedded needs that sensormilliseconds. everyreal 5 takealmosta ECU it mightmilliseconds On 5 Howeve activity. this out to carry milliseconds. if Windowsassigns Thusanother even to the processor applicationmillisecondsfor 3 the Virtualapplication ECU can still carrythe out millisecondsallowed. 5 in the processing necessary Ifapplication your is not behaving as try the following: following: the try functions can cope with the stack ifbeing Therefore asynchronously. changed the application thread to needs call a C/C++ runtime function (including printf() uninterruptible section.the See vrtaVMxxx.dll Location vrtaVMxxx.dll Calling theRuntime C/C++ Windows and Real-Time Behavior Windows Notes Notes Windows

16.3 16.2 16.1 16 RTA-OSEK for PC User Guide PC User RTA-OSEKfor Notes Windows

16.3

264 Windows Notes RTA-OSEK for RTA-OSEK PCUser Guide Windows Notes 264 ways of ensuring that VECUs can find VM DLLs: installed have Ifyou be VMDLL. find the appropriate to able a VECU always will location) if have installed Therefore, you directory If the VECU fails to find the VM DLL then by default it tries to load it from the order: specified inthe locations the following searches it is, That search rules. DLL normal • • • 5. 4. 3. 2. 1.

option. option. define the when DLLs Define the \bin DLL_SEARCH file the Edit Where Add the directory directory Add the The directories listed in listed the The directories The Windows directory. The 32-bit Windows system directory. The current directory. VECU. thedirectory containing The c:\rta\bin RTA-OSEK forPC DLL_SEARCH vrtaCore.cpp DLL_SEARCH ). #define to to directory #define containingbe the VMDLLs the (i.e. is the directory. RTA-OSEK installation . \vrta\inc\vrtaCore.cpp \bin in differenta location then there are three be VM to directory the macro the containing RTA-OSEK for PC macro using a compiler command line or or PATH osgen.cpp to the environment variable. PATH iscompiled. Forexample, in environment variable. c:\rta and setthe and (the default (the Glossary

Glossary

Action An action is a command sent to a virtual device. ApplicationManager The virtual device that controls aspects of the (AM) application thread. Application thread This is the Windows thread that runs the Virtual ECU application code – including OSEK tasks. The application thread is created when the vrtaStart()API is called. The application thread’s entry point is the function called OS_MAIN(). AUTOSAR AUTOSAR is a partnership that is seeking to establish an open standard for automotive E/E architecture. See http://www.autosar.org Autostart mode In autostart mode the application thread starts immediately after the vrtaStart() Virtual Machine API has been called and the Virtual Machine terminates automatically after the application thread returns from OS_MAIN(). Diagnostic interface A Virtual ECU has a diagnostic interface that can be used by external applications to monitor and manage the Virtual ECU. This diagnostic interface uses TCP/IP. The vrtaServer application keeps track of the port numbers used by Virtual ECUs on its local PC. ECU Electronic Control Unit Event An event is a signal generated (raised) by a virtual device to inform interested parties that something has happened. Events may or may not contain data. GUI mode In GUI mode the Virtual ECU displays its own GUI. Interrupt Control The virtual device that controls aspects of the Unit (ICU) application’s virtual interrupts. OSEKTM OSEK is a registered trademark of Siemens AG. It was founded in May 1993 as a joint project in the German . Its aims are to provide an “industry standard for an open- ended architecture for distributed control units in vehicles.” OSEK is an abbreviation for "Offene Systeme und deren Schnittstellen für die Elektronik im Kraftfahrzeug", which translates as Open Systems and the Corresponding Interfaces for Automotive Electronics.

RTA-OSEK for PC User Guide Glossary 265

Glossary

266 Glossary RTA-OSEK for RTA-OSEK PCUser Guide Glossary 266 RA Virtual RTA-OSEK : shorta form used for the VRTA vrtaMonitor vrtaServer (VM) Virtual Machine (VECU) Virtual devices are software components within Virtual ECU Virtual devices Slave mode In slave mode the application thread isnot the thread mode application Inslave Insilent Virtualmode the ECUdoes not display Slave mode Silent mode See RTA-OSEK for PC RTA-OSEK for PC toremote be monitored managed. and allows Virtual ECUs running on the sameor a suppliedwith application The Virtual Machine DLL at runtime. DLL.a Virtual ECU start-up code links to the is supplied as TheMachine Virtual applications. manages communication with external and thread the application devices, manages Machine simulates interrupts, manages virtual OSEK forPC isthe Machine component of The Virtual on arealECU. OSEK for PC RTA-OSEKan kernel. AVirtual ECUisthe Machine, Virtual devicesthe virtual and possibly of ECUiscomposed application, an A Virtual CANcontrollers. and sensors, actuators Virtual devices include: clocks, counters, Virtual ECUs that simulate hardware devices. sent to the Device Manager. is action Terminate untila waits Machine Virtual thread returnsfrom terminate immediately after the application In application thread. to the Device Manager before starting the sent is action Start untila waits Machine Virtual the Instead been called. APIhas Machine Virtual started immediately after the own GUI. its normal application or as a Windows service. Windows service. or asa application normal manages access to Virtual ECU. It runs as a suppliedwith application The slave http://www.osek-vdx.org/ vrtaMonitor vrtaServer mode the Virtual Machine does not that simulates ECU.Thean Virtual analog of an application running anof application analog product. ( .exe ( OS_MAIN() .exe RTA-OSEK forPC RTA-OSEK forPC ) program isan program ) ) program is an

vrtaStart() . Instead the the Instead . RTA- RTA- that that

Index Index

Index

//RTAOILCFG ADDRESS...... 81 //RTAOILCFG PRIORITY ...... 81 //RTAOILCFG TYPE...... 80 _Parent event ...... 67 ‘SYSTEM’ account ...... 71 action callback function...... 65, 113 ActionID()...... 240 Actions...... 24, 64, 75, 113, 219, 229, 240, 265 Actuators ...... 42 additional command line parameters...... 218 alias...... 71, 184, 186, 187, 189, 192, 195, 211, 213, 215, 216, 255, 260 aliases ...... 185, 190, 193, 194, 215, 217 AM...... 127 APP_AOPT...... 39 Application Manager...... 26, 127 application thread ...... 31, 54, 96, 265 AsyncGetState...... 65 AttachECU() ...... 211 AUTOSAR...... 265 autostart mode...... 97, 118, 195, 218, 256, 265 Borland C++ 5..5.1 / Borland C++ Builder 5 ...... 249 Borland C++ 5.8.1 / Borland Developer Studio 2006 ...... 249 C / C++ interface function...... 46 C++ name mangling ...... 86 Clear ...... 125 clock source ...... 40 clock tick interval...... 134 Clocks ...... 40 COM Bridge ...... 198 command file ...... 78, 259 command line ...... 129, 130, 196, 255 command-line option ...... 128 command-line parameter ...... 128 compare devices...... 40 Compiler ...... 32, 249 Connect() ...... 211, 220 constraint ...... 94 counters ...... 40 CreateAlias()...... 212 Ctrl+A ...... 76 Ctrl+Alt+R...... 76 Ctrl+Alt+S ...... 75

RTA-OSEK for PC User Guide Index 267

Index

268 Index RTA-OSEK for RTA-OSEK PCUser Guide Index 268 ECUThreadP ECU_ValErr...... ECU_OK ...... ECU_IDErr ECU_DevErr...... ECU_ConErr ECU...... 221, DoAction()...... Do()...... DM...... 19 Server...... DLL COM 213,2 ...... Disconnect() events ...... 24, 64, 76, 112, 219, 229, 244, 265 265 244, 229, 219, 112, 76, 24,64, ...... events EventRegister...... EventID()...... handler event 32 ...... variables environment EnabledVecs...... GUI...... Embedded Con Electronic diagnostic Interface Diagnostic 38,44, devices.cpp...... devices ...... DeviceManager ...... DeviceList ...... DeviceInfo DeviceID()...... DeviceEvents DeviceActions...... 24,121 ...... Manager Device ...... debugger ...... Strings format Data ...... -d 198, CVcServer...... 202, CVcEvent...... 200,2 ...... CVcECU 202,2 ...... CVcDevice 202,2 ...... CVcAction ...... devices Custom 124, IPL...... current Ctrl+S...... Ctrl+R 37,49 ...... Ctrl+M Ctrl+L...... ln ...... 28 ...... link irt ...... riority ...... 98, 100, 102 98,100, ...... trol Un trol ...... 24, 65, 70, 186, 196, 211, 218, 220, 265 220, 218, 211, 196, 186, 70, 24,65, ...... t...... 2 ...... it ....260 ...... 241 ...... 20 ...... 121 ...... 75 ...... 74 ...... 244 ...... 219 ..... 76 ...... 122 .... 229 .... . 123 ... .219 .. 219 .. 219 .. .121 .. ..22 .... 219 . 126 . 123 . 122 . 126 , 29 , 29 , 57 , 57 219 229 210 244 43 . 96 26 84 20 24 93 19 29 40 8 0

Index Index

-f...... 259 FindECUs()...... 213 firewall ...... 73 Flash memory...... 57 Floating-point Wrappers...... 254 FreeAlias()...... 214 -g ...... 261 GetActionByID()...... 230 GetActionByName()...... 231 GetActionCount()...... 231 GetAliases() ...... 215 GetDeviceActions ...... 122 GetDeviceByID()...... 222 GetDeviceByName()...... 222 GetDeviceCount()...... 223 GetDeviceEvents...... 122 GetDeviceInfo...... 122 GetEventByID() ...... 232 GetEventByName() ...... 232 GetEventCount() ...... 233 GetInfo...... 128, 216 GetIPL ...... 125 GetMatch()...... 177 GetMax()...... 152, 158, 162, 168, 172 GetPending ...... 125 GetValue ...... 183 GetValue()...... 181 GetValues...... 182, 183 GUI mode...... 195, 218, 256, 265 Hardware drivers ...... 81 high-performance counter...... 60 high-performance timer ...... 111 Hook() ...... 223, 233, 244 HookEvents ...... 121 -host ...... 261 ICU...... 25, 103, 124 ICVcAction ...... 240 ICVcDevice ...... 229 ICVcDeviceEvents ...... 239 ICVcECU...... 219 ICVcECUEvents...... 228 ICVcEvent...... 244 ICVcEventEvents...... 248 ICVcServer...... 210 IncrementMatch()...... 178

RTA-OSEK for PC User Guide Index 269

Index

270 Index RTA-OSEK for RTA-OSEK PCUser Guide Index 270 ListLoadedAl ...... ListAll ListAliases()...... hand interrupt Un Control Interrupt ...... -install license file license 32, ...... license ...... –lic ...... -k Java...... IVcServer_Status...... 210 ...... IVcServer_StartMode 210 ...... IVcServer_DisplayMode IVcECU_Status...... ISRs 25,12 ...... IPL 13 ...... Interval 82 ...... interrupts 124 104, 25,103, ...... vector interrupt 80, source...... interrupt 25,12 ...... level priority interrupt ...... priorities interrupt 1 number...... Interrupt InitializeDevices Initializ ...... Info ...... Index mn...... -mon 143,15 ...... Minimum 249 39, 22,32, ...... MinGW 13 ...... Min() ...... migration 249 2003...... Studio Visual Microsoft 249 5.0...... C++ Visual Microsoft 175 174, 171, 170, 165, 164, 161, 160, 155, 154, 150, Maximum...... 143, 13 Max()...... Match masks...... 25, ...... masked ...... Mask main()...... device...... Logger ...... -log ...... LoadECU() ation...... 255, 257, 255,257, 2 ...... iases( e ...... 104,124 ...... ler () ...... 38, 41, 47, 54, 96, 118 118 96, 54, 47, 38,41, ...... () ...... 2 ...... ) it...... 25, 80, 82, 124 124 82, 25, 80, it...... 255, 257, 257, 26 255, ....259 ...... 255, 257 ... 122 ...... 257 ...... 79 ...... 28,82 ... 129 ...... 260 ...... 267 ...... 103 ...... 216 ...... 82 ...... 261 ..... 125 ..... 125 ...... 179 .... 4, 126 6, 137 9, 146 9, 146 .. 80 ...... 218 .. , 124 , 124 . 25 ... . 46 ... 124 124 210 219 82 60 24 17 0 4 0

Index Index

monitoring an event...... 77 MTA...... 198 multi-media library ...... 251 multi-media timer...... 134 multi-threaded apartment ...... 198 –n ...... 261 Name() ...... 234, 241, 245 nonvolatile memory...... 57 OIL file...... 80 OnAction...... 65 OnEventChange() ...... 228, 239, 248 Option...... 129 OptionText ...... 130 OS_MAIN() ...... 96, 118 OS_OVERRIDE_vrtaTraceDevice ...... 85 OSEK thread...... 54 osekdefs...... 39 OSEKTM...... 265 osfptgt.c...... 254 osfptgt.h ...... 254 osgen ...... 39, 251 osTraceCommDataReady()...... 83, 85 osTraceCommInitTarget() ...... 83, 85 -p ...... 257, 261 ParamText ...... 130 Pause ...... 127 Paused ...... 129 Pending...... 126 pending flag...... 124, 125 pending interrupts...... 126 Pentium...... 22 PersistThroughReset() ...... 47 plug-in ...... 79 Position ...... 157 printf()...... 31, 46 priorities ...... 80 priority ...... 124, 255 –priority...... 255 processes...... 28 ProcessPriority ...... 84 Query() ...... 246 QueryEvent()...... 224, 235 QueryFormat() ...... 225, 235, 246 -quit ...... 261 –r ...... 261

RTA-OSEK for PC User Guide Index 271

Index

272 Index RTA-OSEK for RTA-OSEK PCUser Guide Index 272 eIL...... SetIPL ...... SetInterval() 15 150, 144, 143, ...... Set ...... service ...... ServerStatus() Sensors...... 227,237, 242 SendFormat()...... 226,2 SendAction()...... Send()...... -send...... engine...... scripting ...... scripting -scripter...... -script...... 134, factor...... scaling ...... Scale ...... Running Ruby...... 8 ...... RTVECUErr_VAL 88 ...... RTVECUErr_NONE ...... RTVECUErr_ID RTVECUErr_Dev...... 89 ...... RTVECUErr_Conn ...... rtkbuild.bat 35 rtcVRTAlink.dll...... 84 ...... driver communications RTA-TRACE 83 59, 30,35, ...... RTA-TRACE 8 RTAOSEK-VRTA...... RTA-OSEK v5 RTA-OSEK 32 CD...... target PC for RTA-OSEK Restarted...... Restart...... 115,128, ...... Reset 143 ...... Report 226,236, 247 ...... ReplyFormat() 28 PC...... remote 1 ...... counts reference 217 215, 213, 194, 191, 187, count...... reference 2 ...... behavior real-time hardware...... real ...... ReadParam ...... ReadOption RaiseInterrupt()...... RaiseEvent()...... Raise tools tools D...... 32 ...... CD ... 261 ...... 125 ...... 71 ...... 242 ...... 262 ...... 260 ...... 137 ...... 79 ...... 127 ...... 124 ...... 42 ...... 78 ...... 134 ...... 129 .... . 137 ... 39 ...... 66 ...... 219 .. ..67 .... , 150 260 . . 80 ... 128 . 128 . , 84 , 84 129 129 , 70 135 88 . 88 89 63 37 1 8 4

Index Index

SetMatch()...... 177 SetMax()...... 141, 148, 153, 159, 163, 169, 173 SetMin() ...... 140, 147 SetScale()...... 135 SetVal()...... 141, 148, 154, 157, 160, 164, 167, 170, 174 SetValue()...... 180 SetValues ...... 181 SetVector() ...... 178 ShutdownHook() ...... 31 ShutdownOS()...... 97 -silent ...... 255, 257 Silent mode...... 195, 218, 255, 266 –slave ...... 256 Slave mode...... 97, 118, 195, 218, 256, 266 SpawnThread() ...... 69 StackFaultHook() ...... 31 -standalone ...... 257 -start ...... 257, 262 Start ...... 126, 127, 137, 143, 150 Start() ...... 135, 142, 149 Started ...... 128 StartOS()...... 97 Startup and Shutdown hooks...... 36 State ...... 130 state callback function...... 65, 114 status bar ...... 46 -stop ...... 258 Stop ...... 126, 137, 143, 150 Stop() ...... 136, 142, 149 system-tray application...... 71 -t...... 260 target hardware ...... 80 target type ...... 80 target variant...... 80 tasks...... 28, 81 TCP/IP...... 121, 198 Terminate...... 127 Terminated...... 129 TestOption ...... 128 Threads ...... 54, 69 toolinit.bat ...... 32, 249 TraceCommInit()...... 83, 85 -uninstall ...... 258 Unmask...... 54, 125 unmasked ...... 25

RTA-OSEK for PC User Guide Index 273

Index

274 Index RTA-OSEK for RTA-OSEK PCUser Guide Index 274 vrtaActuatorMultiCol 166 42,162, ...... vrtaActuatorLight vrtaActuatorDimmable 42, vrtaActuator...... vrtaActionID 11 ...... vrtaActionCallback 116 113, 64,90, ...... vrtaAction vrtaActEvID...... VesLibCreate 186 VesLibAttachToECU()...... VESLIB_DLL...... veslib.h...... veslib.dll ...... veslib.cpp 20 ...... VECU ...... Vector 24 variant...... 182 ...... Values 173 169, 166, 163, 159, 156, 153, 146, Value()...... 140, 183 182, 175, 174, 171, 170, 167, 165, 164, 161, 160, 155, Value...... 154, 83,85 UploadTraceData()...... unmasks...... vrta_XXXX. VRTA...... vResetType VM...... Basic...... Visual 2 DLLs...... Machine Virtual 266 103, 20,23, Machine...... Virtual 210 184, Library...... Server ECU Virtual 219, 20,28, ECU...... Virtual 266 64,111, ...... Device Virtual 1 VesLibSelectServer()...... 19 ...... VesLibLoadECU() 194 ...... VesLibListLoadedECUs() VesLibListAliases()...... VesLibInitialize()...... VesLibGetInfo()...... 1 ...... VesLibGetAliases() 190 ...... VesLibFreeMemory() VesLibFreeAlias()...... 1 VesLibFindECUs()...... VesLibExit()...... 18 VesLibEcuInfoType...... 185 ...... VesLibEcuAliasType n ...... ini Alias( ...... 1 )...... orLight...... 42, 162, 172 42,162, orLight...... Light...... 42, 162, 168 42,162, Light...... 229, 255,266 229, 240, 244, ...184 ...... 184 ...... 20, 266 20, 266 .. 179 ...... 21, 32 21,32 . ..184 ...... 198 .... 187 .... 9, 252 .. 88 ..... 125 ... . 192 ... ..88 .... 184 .. .114 .. , 266 , 266 , 183 252 . 193 . 192 . 189 . 162 162 96 90 88 87 3 7 5 5

Index Index

vrtaBoolean ...... 89 vrtaByte...... 89 vrtaClientSupport.cpp ...... 184 vrtaClock...... 40, 134, 138, 145 vrtaCompare ...... 41, 176 vrtaCore.h ...... 86, 120 vrtaDataLen...... 89 vrtaDataLenMax ...... 89 vrtaDevice ...... 40, 64, 65, 66, 67, 131 vrtaDevice.h ...... 40, 64, 131 vrtaDevID ...... 88 vrtaDevResetInfo ...... 113 vrtaDownCounter ...... 145 vrtaEmbed...... 89 vrtaEnterUninterruptibleSection()...... 98, 263 vrtaErrType...... 88 vrtaEvent...... 64, 91, 111, 115 vrtaEventCallback...... 99 vrtaEventID...... 88 vrtaEventRegister()...... 98 vrtaEventUnregister() ...... 100 vrtaFlash...... 57 vrtaGetState()...... 65, 100 vrtaHookEvent()...... 102 vrtaInitialize()...... 103 vrtaInitializeOS()...... 105 vrtaIntPriority...... 88 vrtaIO ...... 43, 180 vrtaIsAppFinished() ...... 55, 97, 105, 117 vrtaIsAppThread() ...... 106 vrtaIsIdle()...... 55, 107 vrtaISRID...... 88 vrtaLeaveUninterruptibleSection() ...... 107, 263 vrtaLoadVM()...... 103, 108 vrtamillisecond ...... 89 vrtaMonitor...... 29, 46, 70, 74, 259, 266 vrtaMSCOM.dll...... 198 vrtaNoneUserThread()...... 109 vrtaOptStringlistPtr ...... 92 vrtaOSGetIPL() ...... 109 vrtaOSSetIPL()...... 110 vrtaRaiseEvent() ...... 66, 110 vrtaReadHPTime() ...... 111 vrtaRegisterVirtualDevice() ...... 64, 111 vrtaReset() ...... 115

RTA-OSEK for PC User Guide Index 275

Index

276 Index RTA-OSEK for RTA-OSEK PCUser Guide Index 276 Windows servic Windows 71 Viewer...... Event Windows ...... -wait vrtaVMtt.dll...... vrtaVMts.dll...... vrtaVMte.dll ...... vrtaVMt.dll vrtaVMs.dl...... vrtaVMe.dll...... vrtaVMatt.dll vrtaVMate.dll...... vrtaVM.h ...... vrtaVM.dll ...... vrtaVectorTable 1 ...... vrtaUpCounter 8 vrtaTypes.h...... vrtaTimestamp...... vrtaTextPtr...... 118,11 vrtaTerminate()...... vrtaStringlistPtr...... vrtaStdDevices.h...... 1 ...... vrtaStateCallback 119 118, 64,103, ...... vrtaStart() 117 ...... vrtaSpawnThread() 266 257, 210, 184, 28,70, vrtaServer...... 156 42,152, ...... vrtaSensorToggleSwitch 1 vrtaSensorToggle...... 158 42,152, vrtaSensorMultiwaySwitch...... 158 vrtaSensorMultiway...... 42, ...... vrtaSensor 65,11 vrtaSendAction()...... 40,131 vrtaSampleDevices.h...... 40,131 ...... vrtaSampleDevices.cpp

...... 257,258 ...... e ...262 ...... 92 ...... 27 ..... 27 ..... 27 ..... 27 ..... 27 ..... 86 ..... 27 ..... 92 ...... 27 .... 27 .... 27 .... 6, 88 6, 88 152 152 .89 .. 103 120 38 14 56 9 6