实例介绍
Programming In CAPL introduces the basic concepts of the Vector CAN Access Programming Language (CAPL), the programming language foundation of Vector CANoe and CANalyzer – two of Vector's most popular development tools. CAPL is a rich, robust tool used to extend the power of CANoe and CANalyzer beyo
Programming With CAPL December 14.2004 First printing vector Vector cantech. Inc Suite 550 39500 Orchard hill Place Nov,M|48375 USA http://www.vector-cantech.com 2004 2005 Vector cantech. Inc Novi, Michigan 48375 USA The authors and publishers have used their best efforts in preparing this book. These efforts include development, research, and testing of the theories, principles, and programming sample code so as to determine their effectiveness The authors and/or publishers make no warranty, expressed or implied, with regard to the sample code or to any other documentation contained in this book. The authors and/or publishers shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of the sample code or any of the contents of this book All rights reserved No part of this book may be reproduced in any form or by any means, without express permission in writing from Vector cantech Inc Table of contents Preface About this book Organization 面1面1国丽面面国 Acknowledgments… X Tell Us what you think! 1 Introduction to capl 1.1 Evaluation Capability 2 Simulation Capability 1.3 Prerequisites for Using CAPL 1.4 Learning steps 1.5 CAPL-Event-Driven Software 6 CAPL Program Organization 1.7 Using the CAPL Browser for Program Development 1.8 Program Development Uses the Database Tool-CANdb++ 1.9 CAPL Programming Knowledge.…… 333344 1.10 CAN Communication Knowledge 1.11 THE WARNING-Welcome to the Jungle 1画 1.12 Responsibility. 2 CANalyzer and Canoe 2. 1 One Key Difference- Level of Node Control 2.2 Graphic Panels- The Other Major Difference 3 a Brief Introduction to canalyzer 445667999 3.1 Value of the downloadable demo 3.2 First-Time Considerations 3.3 How to Start and Stop CANalyzer 34 The architecture of CaNalyzer…… 3.5 Measurement Setup Window 3.5.1 Trace Window 3.5.2 Statistics Window 3.5.3 Bus Statistics Window 3.5.4 Data Window 13 3.5.5 Graphics Window 13 3.5.6 Write window 3.6 Duplicating Analysis Blocks 13 3.7 Controlling data Flow 3 3. 8 Function blocks 3.8.1 Filtering Blocks 14 3.8.2 Message blocks 15 39 Using CAPL Program Blocks in CANalyzer……… 17 3.9.1 CANalyzer Program Blocks for Transmission 18 39.2 Program blocks for Analysis…… 19 3. 10 CANalyzer- CAPL Programming Environment 4a Brief introduction to canoe 21 4.1 Value of the downloadable demo 21 42 First-Time Considerations 21 4.3 Learning from the Demo 22 4.4 Tool Architecture of canoe 4.5 Using CaPl program blocks in CaNoe 24 4. 5. 1 CANoe Program Blocks for Simulation 24 4.5.2 CANoe Program blocks for Analysis 4.6 CANoe -CAPL Programming Environment 25 5 Using Databases with CAPL 5. 1 Why Use a database with CAPl? 26 5.1.1 Additional Uses of the database 5.2 Database Association with CAPl 5.3 Database objects accessible by CaPl 5.3.1 Attributes 28 5.3.2 Value tables 5.3.3 Network nodes 28 5.3.4 Messages 28 5.3.5 Signals 28 5.3.6 Environment variables .28 6 Using Panels with CAPL(CANoe only) 翻1国面面音面1面面 29 7 The capl Browser 30 7.1 Starting the CAPL Browser 30 7.2 Browser Organization .31 7.3 Using the Right Mouse Button 32 7.4 The Events window 7.4.1 Creating an Event Procedure 32 75 The global variables window 32 7. 6 The event procedure window 7.7 Colorized cAPL Syntax 33 7.8 Compiling code 33 7. 9 Fixing Compilation Errors 34 7.10 Debugging Run-Time Errors 34 7.1 Using Other Text Editors .35 7.12 CAPL Source File format ...8888... 35 8 CAPL Syntax and Semantics 面面 37 8.1 Major caPl differences from c 37 8.2 CAPL Equivalents to C Functions 38 8.3 Notation ………………38 8.4 Comments .38 8.5 Naming Conventions 39 8.6 CAPL is Case Sensitive .39 8.7 CAPL Keywords……… ● 8.8 Data Type 8.9 Declarati 41 8.9.1 Local variables are static 41 8.9.2 nitialization 42 8.10 Type Casting…… 42 8. 11 Arrays …42 8.12 Constants 43 8 .12.1 Integer Constants 43 8. 12.2 Floating Point Constants 44 8. 12.3 Character Constants 44 8. 12.4 String Constants 45 8.12.5 Symbolic Constants 45 8.13 Operators 46 8. 13.1 Arithmetic Operators 46 8.13.2 Assignment Operators 47 8.13.3 Boolean Operators 48 8.13.4 Relational Operators 面国B1面1BB翻 49 8. 13.5 Bitwise Operators 50 8. 13.6 Miscellaneous Operators 50 8. 13.7 Unsupported Operators 8. 14 Control statements 8.14.1 Branching Statements…… 51 8. 14.2 If Statement 52 8. 14.3 f-EIse statement 52 8. 14.4 Switch Statement 8. 15 Loops 54 8. 15.1 While statement 54 8. 15.2 Do-While Statement 8. 15.3 For statement 55 8.15.4 Unconditional Branching .56 8. 15.5 Return statement 57 8. 16 The this Keyword 57 9 CAPL Functions aiding dl .59 9.1 User-defined functions 59 9.2 Function Overloading is Allowed 59 Table of contents 9.3 Function Naming Conventions………..… 60 9. 4 CAPL Function Categories .60 9.4.1 Mathematical Functions 翻面面国面国国面面面面面面面1国面B,面 60 9.4.2 User interface functions 61 9.43 Time functions 62 9.4.4 Message handling functions 53 9.4.5 Database functions …64 9.4.6 Byte Ordering Functions 9. 4.7 Logging Functions 9.4.8 String Handling Functions .II.8.... 9.49 Measurement control functions 66 9. 4.10 Statistics function 9.411 CAN Protocol functions 9.4.12 Port Functions .69 9.4.13 Replay block Functions 69 9. 4.14 Environment Variable and Panel Functions(CANoe only 70 9. 4.15 Miscellaneous functions 71 9.5 CAPL Function Compatibilities 10 CAPL Events and event procedures 10 Creating an Event procedure 10.2 Event Procedure Requirements 74 10.3 Some Event Procedures Use the Keyword" this 75 10. 4 The symbol 10.5 Event priorit 11 Using messages 78 11.1 Messages in CAPL............... 78 11.1.1 Declaring Messages in CAPL with a Database 78 11.1.2 Declaring Messages in CAPL Without a Database 79 11.1.3 Message Selectors 79 112 Accessing Data.… 81 11.2.1 Using Signals(Only Available with a Database) 82 1.2.2 Physical values and the phys"Attribute 1.2.3 Round-Off Error in Symbolic signal Access Message Transmission Message Reception 83 1.5 Error frames 11.5.1 Error frame event 12 Using Keyboard Events 87 12.1 Keyboard Events and Procedures……… 87 12.2 Using the Keyword this"with the Wildcard Symbol 87 13 Using System Events 13.1 Types of System Events...... 89 13.2 What Happens When a System Event Occurs? 89 14 USing Timers 91 14.1 Declaring a Timer 91 14.2 Starting a Timer 91 14.3 Expiration of a Timer 14.4 Resetting a timer 92 14.5 Periodic clock 14.6 Stopping a Timer Before It Expires 14.7 Common Timer mistake 15 Using CAN Protocol Controller Events ∴94 CAN Controller states 94 15.2 CAN Controller events 16 Using Environment Variables 16.1 Environment Variable Types 16.2 Environment variable initialization 4 97 16.3 Declaring an Environment Variable Event aiding dl 97 16.4 Event Execution 98 16.5 The putvalue( and getValue( Functions 98 16.6 The this"Keyword 98 17 Using File Input/Output Functions 100 17.1 File Input/ 17.1.1 Set-Up for File Input/Output Functions 100 17.1.2 Set-Up for Sequential File Access Functions 101 18 sing the serial and Parellel Port.…… 103 18.1 Installation of rs232VC dlL 103 18.2 RS232 CAPL Functions 103 18.2.1 RS232Setcomm state 03 18.2.2 RS232Byte Callback 104 18.2.3 RS232Write Byte 104 18.2.4 RS232 Write Block 104 18.2.5 RS232Escape CommFunc 面画 105 18.2.6 RS232CloseHandle 105 Constructing CAPL Programs…… 106 19.1 CAPL Program Organization 106 19.1.1 Creating Network Nodes 106 19.1.2 P Block Placement and Message Pass-Through 107 20 CAPL Program EXamples 108 20.1 The Write( Function 108 20.2 Sending a Periodic Message 108 20.3 Sending a Conditionally Periodic Message 110 20.4 Reading data in a received message …111 20.5 Responding to a Message After a delay 112 20.6 Sending an Error Frame 113 20.7 Using Panels 113 20. 8 Bus Off Condition 114 20.9 Using a CAPL Program to Control Logging 115 20.10 Data files and capl 116 20.10.1 Set 1: file l /o Functions 117 20.10.2 Set 2: ProFile functions .119 21 Basic Steps in Creating Your First CANoe Application 121 21.1 CANoe Development-Five Step Process 121 21.1.1 Create a new directory .122 21.1.2 Creating a new caNoe configuration 122 21.13 Bus Parameters… 123 21.1.4 Set Up Analysis Functions 124 21.1.5 Working with the Analysis Windows ,, 125 Jsing CANdb++ to Create a Database 126 22.1 CANdb++ Database Development 126 22.2 Starting the CANdb++ Program 127 22.3 Defining Attributes : 127 22.4 Defining Value Tables 128 22. 5 Defining Nodes 128 22.6 Defining Messages .128 227 Defining Signals…… 129 22.8 Establishing Object Associations .130 22.9 Defining Environment Variables 130 22.10 Saving the Database 22. 11 Associating a database 131 23 Using the Panel editor to Create Panels ∴132 23.1 What are Panels? 132 23.2 Advantages of Using Panels 133 23.3 Requirements.......... 133 233.1 Database association 33 23.3.2 Environment variables 133 23.4 Creating a new pane 134 23. 4.1 Properties of the Panel 面面面 134 23. 4.2 Using elements 135 23.5 Configuring elements 135 Table of contents 23.5.1 Associating Elements 135 23.52 Alarms 136 23.6 Using Bitmaps 11面面 1画国面1面面面音面D .138 23.6. 1 Creating a Dynamic Bitmap 23.7 Associating Panels to Canoe 139 24 Introduction To CAPl dlls 翻面丽 140 24.1 DLL -Dynamic Link Library 140 24.2 CAPL DLLS 140 24.3 Performance 140 24.3.1 Using Microsoft Visual C++ to Implement a CAPL DLL 141 24.4 CAPL EXport Table 142 24.5 Project Configuration 143 24.5. 1 Compiling the DLL 143 24.6 Linking the CAPL DLL 143 246.1 CANini Fille 144 24.6.2 DLL Search Sequence 144 246.3 Demo dll and source code 145 24.6.4C++Code 翻E面面面画 16 24.6.5 Troubleshooting CAPL DLL Errors in the CAPL Browser. ..150 24.6.6 CAPL DLL Questions and Answers 150 25 Introduction to com …151 25.1 COM-Component Object Model 151 25. 2 CANoe/CANalyzer as a COM server 151 25.3 COM Server Registration 151 25.4 Using microsoft Visual Basic to Access the COM server 151 25. 4.1 Project Configuration 152 25.5 Controlling a measurement 153 25.6 Accessing Communication Data 153 25.7 Accessing Environment Variables(CANoe only) 155 25.8 Reacting to CANoe/CANalyzer events 156 25.9 Calling CAPL Functions ∴157 25 10 Transmitting CAN Messages 159 25 11 COM Server Example in Microsoft Visual Basic 160 25.11.1 VB Source Code 161 26 Appendix A: Introduction to CAN Communications 26. 1 The Distributed application 166 26.2 Distributed functions 16 26.2.1 A Common Example of a Distributed Function 168 26.3 Partitioning Requires Addressing………………… 168 26.4 Distributed Functions Require a Transfer Dialog 26.5 A Distributed Function May require file transfer Capabi 170 26.6 The Distributed Application and the oSI Seven-Layer Model 酯1B面面国 ….171 26.6.1 Physical Layer…… 172 26.6.2 Data link layer-data transfer structure 172 26.6.3 Network Layer-Address Structure 173 26.6.4 Transport Layer-Message Transfer Structure 173 26.6.5 Session Layer-Conversation Structure 173 26.6.6 Presentation Layer-Data Structure 173 26.6.7 Application Layer-Application-to-Network Interface Structure 173 26.7 Distributed Applications Require Data Structures 173 26.8 Understanding the can Protocol .174 26.8. 1 Key Attributes 174 26.8.2 Understanding the Basic Elements of the CAN Message 177 26.83 The can error frame 179 26.8.4 CAN Error Counting 179 26.8.5 The Can Receive State Machine 179 26.86 The can transmit state machine 180 26.8.7 CAN Implementation Ingredients- CAN Controller, Software, Physical Layer………… 181 26.8.8 Can Physical layer 182 26.8.9 Physical Layer choices .182 Preface 26.8. 10 Basic CAN Physical Layer Principles 182 26.8.11 CAN Controller- Dominant/Recessive Logic Levels .183 26.8.12 Common Dominant/Recessive Logic Implementations 184 26.8.13 The Common High-Speed, Two-Wire Differential Transceiver 185 26.8.14 The common can transfer medium - wire 185 26.9 First-Time CAN Steps 188 26.9.1 Step One- Wiring First.….… 188 26.9. 2 Step Two- Add Modules Incrementally 188 26.9.3 Notes on Building your Own CAN-Based Module 189 27 Appendix B: Abbreviations/Acronyms 190 28 Appendix C: Glossary 191 29 Index 195 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论