LabVIEW Tutorial: Calling CANoe for Automotive Applications

Each has its strengths, knowing how to assign roles, dedicated to the application and promotion of LabVIEW in the automotive industry.

Currently, Vector remains the strongest player in the global automotive bus communication field, with powerful product performance, a complete range of products, comprehensive functions, rich documentation, and standardized APIs… it is undoubtedly the industry benchmark!
LabVIEW Tutorial: Calling CANoe for Automotive Applications
You will be surprised to find that almost all business in the automotive communication field can be done by it, staying ahead of users and leading the industry.
The “33 Lectures on Buses” caused a “bloodbath” due to a textbook.
At the testing exhibition, the mighty Vector has arrived!
Vector is like the treasure of the industry, the heavy weapon of a great power, the ultimate trump card. When we can’t find various alternatives, we ultimately find that Vector supports the face of this field, as it basically has ready-made products, technologies, and solutions.
LabVIEW Tutorial: Calling CANoe for Automotive Applications
With many people in the Vector community, it has accumulated an almost unshakable position in the industry, and there are no signs of decline. Everyone can take a look at the gossip below:
Indeed, the mighty Vector is impressive, but…

Disadvantages

LabVIEW Tutorial: Calling CANoe for Automotive Applications
The biggest disadvantage of Vector products is that they are expensive.
This leads to the fact that in almost all enterprises, purchasing Vector products requires a high-level review meeting and financial evaluation.
LabVIEW Tutorial: Calling CANoe for Automotive Applications
When the products arrive, it usually takes a year, which is too slow.
With increasing competition in the automotive industry and shorter development cycles, such lengthy processes significantly weaken the product competitiveness of car manufacturers, and this issue needs serious consideration.

CANoe is indeed useful, but relying entirely on CANoe, equipped with Vector all over, seems to expose our inertia of complacency, ignorance, and arrogance, sometimes even leading to unnecessary expenses and delays.

Fully leveraging the value of engineers, designing appropriate, low-cost, high-value testing solutions based on actual applications is the mission of R&D personnel, and it is imperative!

Not conducive to technical communication, review, and discussion
CAPL programming language, as a coding language, is obscure, tedious, and boring.
This leads to the fact that for most enterprises, only a small number of people are willing to write programs, making it difficult to form an atmosphere of “widespread discussion and collaborative development” within the team. Over time, the code becomes unmaintained, and no one understands it, turning it into a mess.

Purpose of This Article

LabVIEW Tutorial: Calling CANoe for Automotive Applications
Given this, why does this article focus on explaining the knowledge of LabVIEW calling CAPL?
Because LabVIEW is simple, intuitive, and convenient, while CAPL is powerful.
There are several specific reasons:
  • 1. For some functional testing, Vector tools are a must, and there are no alternatives, such as CANstress interference.

  • 2. Integrators from the Vector faction will almost inevitably provide users with CAPL programming solutions, delivering CAPL programming functions and scripts.

    When I deliver, it runs; whether you subsequently upgrade and maintain the CAPL is your business.

    The CAPL functions or scripts delivered by the supplier are part of the existing resources and industry knowledge assets, and we need to find ways to utilize them.

  • 3. For some functions, you may have previously implemented them, but not using CAPL programming, but LabVIEW. Now that you need to integrate Vector devices, it is necessary to apply LabVIEW to call CAPL technology.

  • 4. For some functions, using CAPL is very inconvenient, such as reading and writing Excel, project management, web interface calls, etc.

  • 5. Thanks to V Emperor, the most important thing is Vector’s open spirit, which is the premise of everything; its CAPL functions can be called externally, and the APIs are quite standardized.

LabVIEW Tutorial: Calling CANoe for Automotive Applications

Method Overview

LabVIEW Tutorial: Calling CANoe for Automotive Applications
1. Start the CANoe COM server.
2. Get a reference to the application.
3. Get a reference to the measurement.
4. Get a reference to CAPL.
The above four steps are very simple; as long as you have a basic concept of ActiveX applications, you can easily implement them.

LabVIEW Tutorial: Calling CANoe for Automotive Applications

If you forget how to use ActiveX, you can check out the following article on vehicle technology:
HIL33 Lecture: Introduction to Software Calling Software Principles_v
So far, we have obtained a reference to the CAPL object. Next, we need to instantiate it and obtain a reference to the CAPL function. Please continue reading:
5. In the OnInit phase, initialize the CAPL function callback and obtain a reference to the CAPL function (if there are multiple CAPL functions, obtain all at once).

LabVIEW Tutorial: Calling CANoe for Automotive Applications

The CANoe HELP documentation clearly states that the initialization of CAPL functions should be done in the OnInit function, and we must adhere to its rules.
How to initialize the CAPL function in the callback function? As shown in the figure below, this is the program structure inside the above callback function:

LabVIEW Tutorial: Calling CANoe for Automotive Applications

After this, you will have obtained all references to the available CAPL functions, and you can happily call them later.
6. Call the CAPL function, passing parameters and receiving return values from CAPL.
When calling, first “start” it, similar to clicking on CANoe’s RUN.
Then, check the CAPL collection to see if there is a CAPL function named test_jia; if so, call it.
How is this CAPL collection created? It is created by defining a control earlier, then passing the control’s reference into the callback function, using the OnInit function to assign values, and then using it here through local variables.

LabVIEW Tutorial: Calling CANoe for Automotive Applications

The CAPL function defined in CANoe is as follows:
int test_jia(int para1,int para2)  {  return para1+para2;  }
Add it to the ECU node of the Measurement module and add this function to the CAPL file of the ECU node.
Open CANoe (it can run or not), run this VI, and the following results will appear (results are for demonstration only):

LabVIEW Tutorial: Calling CANoe for Automotive Applications

Significance

LabVIEW Tutorial: Calling CANoe for Automotive Applications

If you casually open a CAPL file, you will find that all actions in CAPL can be encapsulated into CAPL functions; CAPL script actions are essentially CAPL functions.

In principle, CAPL functions can achieve almost all the functionalities of CANoe.

By encapsulating some standard actions into CAPL functions, you effectively create a series of CAPL drivers, and then use LabVIEW to build complex logic, achieving impressive and powerful functionalities.

Complex and professional tasks should be handled by CANoe, while tedious, frequently changing, and low-cost tasks can be handled by LabVIEW.

This gives us a broad space for development, expanding almost limitless possibilities.

LabVIEW Tutorial: Calling CANoe for Automotive Applications

The maintest() function can be deleted from now on because we choose to call from the outside.

Precautions

These insights were discovered after spending nearly a hundred months and encountering many pitfalls; they are key points. If you can’t figure this out, it is almost impossible to succeed.

1. OnInit

You must assign values to CAPL functions during the OnInit process.

2. Synchronizing initialization of multiple CAPL functions

Don’t worry about the OnInit phase not having enough time; in fact, it can initialize countless CAPL functions, and time will not run out.

We need to create a structure array, each structure containing at least a function name and a function reference, so that later when calling a function name, we can look up the reference by “name”.

Prerequisites

Of course, it is important to note that this requires the CAPL functions delivered by the supplier to be standardized, and it is better if there are no global variables inside the functions; otherwise, who knows what backdoors might exist…

Function black-box encapsulation is irrelevant; this is the supplier’s intellectual property, and it is understandable that they do not provide the source code. As users, our focus is not on the CAPL source code. Whether it is the functions provided by Vector or those developed by suppliers, as long as they can be called, it is fine.

If suppliers want to bind CAPL functions to Vector devices, it is also acceptable; just clarify it, as everyone needs to make money, and profit drives industry progress.

LabVIEW Tutorial: Calling CANoe for Automotive Applications

However, using global variables as backdoors in functions is the most detestable! Especially when the controlling party is also a non-standard, opaque, and wild software.

Countermeasures

Regarding this, everyone can create a CAPL TEST node during acceptance, using maintest() to individually test and combine test these functions to identify their authenticity.

If conditions permit, change to a new computer and start from the installation software to see which hardware and files are bound, so you can clarify.

For more knowledge on LabVIEW development and applications, feel free to contact us.

If you have previously struggled with this solution but have not succeeded, then after reading this article’s explanation of several difficulties, you should be able to handle it.

If after reading this article, you still cannot figure it out, it means you haven’t tried before. Even the best teachers can’t explain this matter more simply; you can purchase a video and follow the tutorial step by step, which will definitely work.

The detailed explanation of this tutorial is included in the “Vehicle Technology LabVIEW” course, and you are welcome to inquire.

LabVIEW Tutorial: Calling CANoe for Automotive Applications

【Recommended】

Lecture 10 on Buses: The Best Excel2DBC Tool in the Eastern Hemisphere, Always Free to Offer

LabVIEW Tutorial: Calling CANoe for Automotive Applications

LabVIEW Tutorial: Calling CANoe for Automotive Applications

Leave a Comment