Ediabas Best Guide

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 161

EDIABAS BEST Developer's Guide Page 1 of 161

EDIABAS BEST Developer's Guide


· BEST User Manual

· BEST/2 Language Description

· BEST/2 Function Primer

EDIABAS BEST Developer's Guide

BEST User Manual


More:

1. Revision history

2. Introduction

3. General Information

4. Tutorial

5. BEST Tools

A. Limits and restrictions

B. REFERENCES

EDIABAS BEST Developer's Guide > BEST User Manual

1. Revision history
Version 3.0 First release

Version 4.1 Revised for EDIABAS V4.1.0


Version 5 Revised for EDIABAS V5.1.0
Version 5a Extended for EDIABAS V5.5.0
Version 5b Extended by appendix "Limits and restrictions"
Version 6 Extension for EDIABAS V6.0.0
Version 6a Extension of appendix “Limits and restrictions”
Version 6d Revised for EDIABAS V6.4.4
Version 7a Extension for EDIABAS V7.1.0
BEST2 for Win32
No more BestView/BestBoard support for Win16
Higher numbers of string/array variables for EDIABAS 7.1.0
Version 7b Revised for EDIABAS V7.2.0
Version 7c Revised for EDIABAS V7.2.0
Version 7d Revised for EDIABAS V7.2.0
Version 7e Correction of appendix “Limits and restrictions”
Version 7f Extension for EDIABAS V7.3.0
BEST2WIN for Win32
Extension of appendix "Limits and restrictions"

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 2 of 161

EDIABAS BEST Developer's Guide > BEST User Manual

2. Introduction
More:

2.1. About this Manual

2.2. Conventions

2.3. Special features, definitions, acronyms

2.4. Trademarks

EDIABAS BEST Developer's Guide > BEST User Manual > 2. Introduction

2.1. About this Manual

This manual sets out the principles for creating control unit description files and describes the use and options of the development
support programs. This manual does not go into any great depth about BEST/1 language. As a general rule all control unit
description files can be formulated in BEST/2 notation which is easier to read. You will find a detailed description of the BEST/1
language in [3]. General information about EDIABAS and control unit description files is given in Reference [4].

EDIABAS BEST Developer's Guide > BEST User Manual > 2. Introduction

2.2. Conventions

The following typographical conventions are used in this manual:

Example Description
SAMPLE.B2V Upper case characters are used for filenames, registers and
operating system commands.
job, string, while Bold type is used for key words and operators of the
BEST/2 and BEST/1 languages and for API functions. In
syntax descriptions these words must be written as shown.

expression Italics designate placeholders for values to be entered by


the programmer; e.g., file names.
[option] Words enclosed in square brackets may be optionally
specified.
{ result | Curvy braces and vertical strokes characterize entries from
argument } which only one must be selected, except when in square
brackets.
[constant...] job... An ellipsis (three dots) which directly follows an
expression indicates that several expressions of the same
type can follow.
hallo="Test"; This syntax designates examples, user entries, program
outputs and error messages.
while() { A column or a row comprising three dots indicates that a
section of an example was intentionally omitted.
.

.}

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 3 of 161

[1] Reference to a document in References.

EDIABAS BEST Developer's Guide > BEST User Manual > 2. Introduction

2.3. Special features, definitions, acronyms

The abbreviations used in this and all other EDIABAS documents are explained in the "GLOSSARY" section of the "EDIABAS
User Manual".

EDIABAS BEST Developer's Guide > BEST User Manual > 2. Introduction

2.4. Trademarks

Microsoft, MS, MS-DOS, Windows and WIN32 are registered trademarks of the Microsoft Corporation.

EDIABAS BEST Developer's Guide > BEST User Manual

3. General Information
More:

3.1. Job concept

3.2. ECU description files

3.3. Standard jobs

3.4. Variant identification

3.5. Filenames

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information

3.1. Job concept

Control unit description files - SGBDs for short - contain methods for reading control unit specific data from the control unit and
compiling it into an abstract and generally readable form.

In EDIABAS, these methods are called jobs and are usually written in BEST/2. BEST/2 syntax is based on C language but is
matched to the specific needs of control unit description. You will find a detailed description of BEST/2 syntax in [5]. In particular,
the jobs have had to be incorporated as a special type of function. The use of fields has also been streamlined to simplify the handling
of complex telegram data. Unlike C, the user cannot define his own functions, but there is a runtime library (see [1]) that has been
optimized for diagnostic tasks and it provides functions for all problems.

A job can be called independently of other jobs at any time so jobs are not allowed to be dependent on one other in time terms.
BEST/2 prevents this by not having any constructs that allow jobs to exchange data. Only constants may be global.

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information

3.2. ECU description files

There are three types of ECU description files: 1) Variant, 2) Basic and 3) Group. An explanation of the terms "ECU variant" and
"ECU group" can be found in [4]).

EDIABAS expects all ECU description files in the ECU directory (configuration element EcuPath in EDIABAS.INI).

More:

3.2.1. Group description files

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 4 of 161

3.2.2. Variant description files

3.2.3. Basic description file

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information > 3.2. ECU description files

3.2.1. Group description files

In addition to the jobs INITIALISIERUNG and ENDE (optional), the group description file only contains the job
IDENTIFIKATION which determines the variant currently installed in the vehicle. Jobs in a group description file cannot be
called with an API job.

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information > 3.2. ECU description files

3.2.2. Variant description files

In addition to the jobs INITIALISIERUNG and ENDE (optional), the variant description files contain the actual jobs for
determining data from the ECU.

A variant description file can access one or more basic description files. Jobs in the basic description files are treated like the jobs
from the variant description file when jobs are processed.. Standard jobs in the basic description file are ignored.

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information > 3.2. ECU description files

3.2.3. Basic description file

Jobs which are the same for several ECUs are stored in commonly used basic ECU description files (SGBDs). ECU-specific jobs,
in contrast, are stored in the respective "variant" ECU description file.

In order not to limit the alternative search to the single basic ECU description file, alternative basic ECU description files can be
specified within the ECU description file.

More:

3.2.3.1. Access to jobs in a basic ECU description file

3.2.3.2. "Overloading" a job from the basic ECU description file

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information > 3.2. ECU description files > 3.2.3. Basic
description file

3.2.3.1. Access to jobs in a basic ECU description file

Which basic ECU description file or alternative ECU description files are to be applied whenever the job in the ECU description
file is not found can be specified in the header of a variant ECU description file. For this purpose, the new entry uses is defined in
the header followed by the name(s) (without extension) of the alternative basic ECU description files (PRG files), separated by one
or more blanks and/or comma. The line must end with a semicolon.

Example:

The example below shows the header of a variant ECU description file designated VARIANTE.PRG. Jobs which are not found in
this ECU description file should be searched in the basic ECU description files BASIS1, BASIS2 and BASIS3. This is defined in
the line uses.

/////////////////////////////////////////////////////////////

// H E A D E R

/////////////////////////////////////////////////////////////

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 5 of 161

ecu : Demo ECU VARIANTE.PRG;

origin : softing.BG5.Ma;

revision: 1.0;

author : softing.BG5.Ma;

language: German;

uses    : BASIS1, BASIS2, BASIS3;

comment : Example for using basic ECU description files (SGBDs);

/////////////////////////////////////////////////////////////

EDIABAS first checks whether the job specified in the apiJob call can be found in VARIANTE.PRG. If this is the case, the job is
executed. If the job does not exist in VARIANTE.PRG, search is continued in the first alternative basic ECU description file
specified in the header from VARIANTE.PRG following uses, here BASIS1.PRG. Search is continued accordingly until the job is
found. If the job is also not found in the last ECU description file (here BASIS.PRG), EDIABAS issues the error message "SYS-
0008: JOB NOT FOUND" .

In another example, assumption is made that the application in the apiJob call specifies the name of a group ECU description file
(here D XY) beside the job name. The ECU variant is determined in the job identification of the group ECU description file
D_XY.GRP , and the associated name of the variant ECU description file is entered in the result VARIANTE: In this case, XY_1
or XY_2 or XY_3. EDIABAS searches the job in the corresponding ECU description file. Jobs which are not found there are
searched in the basic ECU description file (here BASIS.PRG or BASIS2.PRG). The reference to the basic ECU description file
must always be entered in the variant ECU description files.

A variant ECU description file must exist for each ECU variant which, in the extreme case, only consists of the header and the jobs
INITIALISIERUNG and ENDE (optional). When a basic ECU description file is accessed, the standard jobs INITIALISIERUNG
and ENDE of the basic ECU description file are not called (the standard jobs INITIALISIERUNG and ENDE are not required in a
basic ECU description file).

Access to basic ECU description file

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information > 3.2. ECU description files > 3.2.3. Basic
description file

3.2.3.2. "Overloading" a job from the basic ECU description file

If a job is to be an ECU-specific variant and not to be called from the basic ECU description file, this job is to be appropriately
defined in the variant ECU description file. For this purpose, the corresponding job is stored in the variant ECU description file of
the ECU under the same name and implemented ECU specifically. Since EDIABAS already finds the job in the variant ECU
description file, this is executed instead of the job with the same name from the basic ECU description file.

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information

3.3. Standard jobs

Standard jobs have a special meaning for EDIABAS. These jobs are automatically called by the runtime system under certain
conditions in addition to the job specified. These jobs can receive parameters.

The result of standard jobs is stored in defined standard results which EDIABAS automatically interrogates.

A job which is issued via a variant is processed as shown below:

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 6 of 161

Application program EDIABAS EDIABAS

Calls Selects SGBD: Processes jobs:


apiInit()
apiJob(SGBD1,JOB1,...)
SGBD1.PRG INITIALISIERUNG

JOB1
apiJob(SGBD1,JOB1,...)
SGBD1.PRG JOB1
apiJob(SGBD1,JOB1,...)
SGBD1.PRG JOB1 (error occured)
apiJob(SGBD1,JOB1,...)
SGBD1.PRG INITIALISIERUNG

JOB1
apiJob(SGBD2,JOB1,...)
SGBD1.PRG ENDE
SGBD2.PRG INITIALISIERUNG

JOB1
apiInit()
apiJob(SGBD3,JOB1,...)
SGBD2.PRG ENDE
SGBD3.PRG INITIALISIERUNG

JOB1

A job which is issued via a group is processed as shown below:

Application program EDIABAS EDIABAS

Calls Selects SGBD: Processes jobs:


apiInit()
apiJob(GROUP,JOB1,...)
GROUP.GRP INITIALISIERUNG

IDENTIFIKATION (of
the variant)

ENDE
VARIANT.PRG INITIALISIERUNG

JOB1
apiJob(GROUP,JOB1,...)
VARIANT.PRG ENDE
GROUP.GRP INITIALISIERUNG

IDENTIFIKATION (of
the variant)

ENDE
VARIANT.PRG INITIALISIERUNG

JOB1
apiInit()
apiJob(GROUP,JOB1,...)

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 7 of 161

GROUP.GRP INITIALISIERUNG

IDENTIFIKATION (of
the variant)

ENDE
VARIANT.PRG INITIALISIERUNG

JOB1

More:

3.3.1. Standard job INITIALISIERUNG

3.3.2. Standard job IDENTIFIKATION

3.3.3. Standard job ENDE

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information > 3.3. Standard jobs

3.3.1. Standard job INITIALISIERUNG

The standard job INITIALISIERUNG must exist in every group and variant description file. It is automatically called:

• After previous initialization of API (apiInit()/apiInitExt)

• After previous device switch (apiSwitchDevice())


• After previous occurrence of an error
• For a job with pre-specified variant (only after changing the ECU variant)
• For a job whose variant is unknown

Successful initialization is to be displayed with the standard result DONE (result type int or unsigned int):

• Result DONE <> 0 Successful initialization

• Result DONE = 0 Erroneous initialization


• Result DONE does not exist Erroneous initialization

Except for the result DONE, the standard job INITIALISIERUNG must not return any other results .

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information > 3.3. Standard jobs

3.3.2. Standard job IDENTIFIKATION

The standard job IDENTIFIKATION is called to determine the installed ECU variant whenever a group description file has been
specified in the job.

The standard job IDENTIFIKATION must exist in every group description file.

An identified ECU variant is to be displayed in the first result record with the standard result VARIANTE (string from result type
string):

• Result VARIANTE = String (at least 1 character) Successful identification, the result represents the name of the ECU variant

• Result VARIANTE = Blank string Erroneous identification


• Result VARIANTE Does not exist Erroneous identification

Except for VARIANTE, the standard job IDENTIFIKATION must not delivery any other results.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 8 of 161

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information > 3.3. Standard jobs

3.3.3. Standard job ENDE

The optional standard job ENDE is called when the description file is varied:

• Before changing the description file

• Before a job with unknown variant

The standard job ENDE can exist in each group and variant description file.

The standard job ENDE must not return results.

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information

3.4. Variant identification

The variant is identified by the job IDENTIFIKATION which is mandatory in the group description file. This job must return the
result VARIANTE which is then used to identify the variant description file.

A job which is executed on a group has the following sequence:

Application program EDIABAS

calls selects SGBD: executes job:


apiInit()
apiJob(GROUP,JOB1,...)
GROUP.GRP INITIALISIERUNG

IDENTIFIKATION (of
the variant)

ENDE
VARIANT.PRG INITIALISIERUNG

JOB1

EDIABAS BEST Developer's Guide > BEST User Manual > 3. General Information

3.5. Filenames

Files that are used by EDIABAS have defined filename extensions which are mandatory and are different for group and variant
description files.

File type Variant Group


SGBD object file *.PRG *.GRP
BEST/2 source file *.B2V *.B2G
BEST/2 preprocessor file *.P2V *.P2G
BEST/1 source file *.B1V *.B1G
BEST info file *.BIV *.BIG
BEST/1 map file *.M1V *.M1G

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 9 of 161

EDIABAS BEST Developer's Guide > BEST User Manual

4. Tutorial
This tutorial uses a realistic example to show you how to create a BEST/2 description file. We have tried to cover as many aspects of
programming as possible. The use of the development tools is also explained at a number of points.

You can work through this tutorial in two ways:

1. You can either use the files supplied by the BEST DEVELOPMENT KIT, or

2. You can edit the files as you go, starting from the DEMO0.B2V file in section 4.2.

With the first method you are prompted what file to load for the section. With the second method all the changes in this manual are
listed and shown like this:

ð // This line must be added to the previous version.

ï // This line must be removed from the previous version.

ó // This line must be changed in the previous version.

You will find a detailed description of the BEST/2 functions used in this tutorial in [1] which fully describes all BEST/2 library
functions with their call parameters and an example.

More:

4.1. Preconditions

4.2. Getting started

4.3. Step 1: The frame

4.4. Step 2: Minimum version

4.5. Step 3: Control unit parameters

4.6. Step 4: Control unit communication

4.7. Step 5: String and Data functions

4.8. Step 6: Result sets

4.9. Schritt 7: Step 7: Table processing

4.10. Step 8: Real processing and result request

4.11. Step 8: Job parameter

4.12. Binary parameters and binary results

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.1. Preconditions

For this tutorial a development of ECU description files under MS-WINDOWS is provided. The development environment
BestBoard and the Source Code Debugger BestView is only available for MS-WINDOWS.

In order to walk-through the sequences shown in this tutorial, the EDIABAS-RUNTIME-SYSTEM and the BEST-
DEVELOPMENT-KIT must be installed.

The following settings have to be done in the EDIABAS configuration file EDIABAS.INI:

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 10 of 161

EcuPath = C:\EDIABAS\TUTORIAL

TracePath = C:\EDIABAS\TUTORIAL

SimulationPath = C:\EDIABAS\TUTORIAL

Simulation = 1

Assumption is made that EDIABAS has been installed in directory C:\EDIABAS. If this is not the case, the EDIABAS
configuration file EDIABAS.INI must be adapted. The configuration setting C:\EDIABAS\TUTORIAL is to be replaced by
<EDIABAS path>\TUTORIAL for the configuration elements EcuPath, TracePath and SimulationPath. Moreover, this must be
replaced by the path of the EDIABAS directory everywhere where C:\EDIABAS can be read in this description.

In addition, the following settings are to be kept:

The environment variable PATH should contain C:\EDIABAS\BIN.

The directory C:\EDIABAS\TUTORIAL must not be write-protected.

The tutorial describes how to program ECU communication. In order to enable this independent of the hardware used and the
available ECUs, the ECU Simulator contained in EDIABAS is used. Refer to [2] for a detailed functional description concerning
this. Files DEMO*.SIM and EDIC.SIM are necessary for this purpose.

The individual development phases are represented by prepared description files in directory C:\EDIABAS\TUTORIAL. A total of
9 steps are involved and the corresponding files DEMO0.B2V to DEMO8.B2V.

In order to continue with the next step, now start MS-WINDOWS.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.2. Getting started

To begin developing our SGBD, first start the BestBoard routine BESTBD32.EXE in the directory \EDIABAS\BIN respectively.
Provided your settings are correct you will see the dialogue box "Notify Test Environment" which shows that the control unit
simulator is activated in the selected ECU directory. The simulation file directory and the simulated interface are displayed, also
whether the traces of API and IFH are active.

Acknowledge this message and you will see the BestBoard main window. All the actions needed to create and test an SGBD can be
controlled from this program.

To open the raw version of our SGBD, select the FILE/OPEN menu or press the appropriate key (second from left, see also
BestBoard description).

Continue with the next point by selecting the C:\EDIABAS\TUTORIAL\DEMO0.B2V file.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.3. Step 1: The frame

Opening the file automatically calls the text editor NOTEPAD.EXE. This displays the selected file - in this case DEMO0.B2V (The
copyright message contained in this file is not reproduced in this manual). The file contains a frame for an SGBD that is blank but
which already has comments:

//////////////////////////////////////////////////////////////////////

// H E A D E R

//////////////////////////////////////////////////////////////////////

ecu :;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 11 of 161

origin : ;

revision: ;

author : ;

comment : ;

//////////////////////////////////////////////////////////////////////

// C O N S T A N T S

//////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////

// J O B S

//////////////////////////////////////////////////////////////////////

job(name : INITIALISIERUNG;

comment : Initializing;

comment : This job is automatically called by EDIABAS when;

comment : first accessing an SGBD. It is not called with;

comment : subsequent accessing of the same SGBD. In;

comment : INITIALISIERUNG all functions are called which are:

comment : only needed once, before communication with a CU.;

result : DONE;

type : int;

defrslt : ;

comment : Values: 0 = initializing failed;

comment : Values: 1 = initializing successful;

DONE = 1;

//////////////////////////////////////////////////////////////////////

job(name : ENDE;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 12 of 161

comment : De-initializing;

comment : This job is automatically called by EDIABAS after;

comment : the last access to the SGBD. It is used to;

comment : de-initialize the interface hardware if required;

//////////////////////////////////////////////////////////////////////

The file contains a header (that must be filled out) and two jobs. These are the standard jobs INITIALISIERUNG and ENDE and are
called automatically by the runtime system when a description file is loaded (INITIALISIERUNG) or unloaded (ENDE).

You will see that a job's header contains its name and at least one comment line. It also lists and comments all the parameters and
results of the job. During compiling, these headers are incorporated in the objects and can be read out with the XTRACT tool. The
header consists of n entries in the form: "keyword: data;". Here is a description of these keywords:

• name Name of the job. The name with which the application program addresses the job.

• comment Comment line. Contains any desired comment (at least 1 line).
• result Beginning of the result block. Must be followed by the keywords type, defrslt (optional) and comment(s). data
gives the name of the result. The application program and the job can access the result with this name.
• argument Beginning of a parameter block. Must be followed by the keywords type and comment(s). data gives the name of
the parameter. The application program and the job can access the parameter with this name. Only the parameter
sequence is important for the application program.
• type Type of parameter or result, the following values of data are allowed:
• [unsigned] char byte or character (8 bit)
• [unsigned] int word or integer (16 bit)
• [unsigned] long double word or long integer (32 bit)
• string zero-terminating text string (1024 bytes max.)
• real double value
• data byte field (1024 bytes max.)
• defrslt Optional default value for a result.

In the INITIALISIERUNG job, the result DONE is assigned the value 1. This result must be present in this job as it tells the runtime
system whether the job was executed successfully or not.

Continue with the next point by selecting the C:\EDIABAS\TUTORIAL\DEMO1.B2V file.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.4. Step 2: Minimum version

The file now opened can already be compiled. It attempts to communicate with the interface. To do this the following lines must be
inserted or changed:

//////////////////////////////////////////////////////////////////////

// HEADER

//////////////////////////////////////////////////////////////////////

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 13 of 161

ó ecu : EDIABAS BEST/2 Demo control unit;

ó origin : softing.SAG.HD;

ó revision: 1.1;

ó author : softing.SAG.HD;

ó comment : demonstration file for EDIABAS BEST/2;

...

job(..name : INITIALISIERUNG;

comment : Initializing;

comment : This job is automatically called by EDIABAS when;

comment : first accessing an SGBD. It is not called with;

comment : subsequent accessing of the same SGBD. In;

comment : INITIALISIERUNG all functions are called which;

comment : are only needed once, before communication with;

comment : a CU.;

result : DONE;

type : int;

defrslt :;

comment : Values: 0 = initializing failed;

comment : Values: 1 = initializing successful;

ð open_communication(); // make connection to interface

DONE = 1;

//////////////////////////////////////////////////////////////////////

job(..name : ENDE;

comment : De-initializing;

comment : This job is automatically called by EDIABAS;

comment : after the last access to the SGBD. It is used to;

comment : de-initialize the interface hardware if required;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 14 of 161

ð open_communication(); // make connection to interface

The header now contains the following information:

• ecu: explicit meaning and function of this description file

• origin: name of first creator


• revision: version code (RevMajor, RevMinor)
• author: author of the last revision (more than 63 characters are ignored)
• comment: any desired comment (n line comment: ...;)

These entries are incorporated in the object when compiled.

Since this SGBD wants to communicate with a control unit (actually with the interface in between) the function
open_communication must be called in the INITIALISIERUNG and ENDE jobs. This function attempts to open a communication
channel to the interface. No special error handling is needed. If an error occurs during this function call, the job routine is aborted at
this point and an appropriate error message is sent to the application program. This applies to all communication functions.

To compile the created file, start the compiler BEST2WIN in the PROJECT/COMPILE menu. The compiler's icon can be seen on
the Windows screen background while it is working. Any errors that occur during compiling are subsequently shown in the
application area of BestBoard and the Editor is loaded with the appropriate file. All errors can be shown in sequence using the
PROJECT/NEXT ERROR or PROJECT/PREVIOUS ERROR menu (optional also with the 6th and 7th toolbar keys) and corrected
in the Editor. An audible signal and a blank application area indicate that the last error has been processed and you may now restart
the compiler. When the compiler shows no further error messages a runnable SGBD object file has been generated.

Continue with the next point by opening the C:\EDIABAS\TUTORIAL\DEMO2.B2V file.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.5. Step 3: Control unit parameters

The filed now opened will also prepare the hardware interface for communication with the control unit. First the constants for the
parameters and telegrams are defined:

//////////////////////////////////////////////////////////////////////

// CONSTANTS

//////////////////////////////////////////////////////////////////////

ð // *** SG - PARAMETERS ***

ð //

ð // Concept 1

ð // Baudrate 9600

ð // Wakeup address 0xaa

ð // Wakeup time 0 ms

ð // Idle time 0 ms

ð // Timeout time 2000 ms

ð // Regeneration time 500 ms

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 15 of 161

ð // Answer length -2 (2nd byte in answer telegram)

ð // Control byte 3 (3rd byte in answer telegram)

ð // 0x80: 3rd byte in send telegram must be combined

ð // with it to represent a valid third answer byte

ð //

ð int PARAMETER[] = {1,9600,0xaa,0,0,2000,500};

ð int AWLEN[] = {-2,0};

ð int CTRLPOS = 3;

ð int CTRLOR = 0X80;

ð // *** SG - TELEGRAMS ***

ð //

ð char TEL_ID_READ[] = { 0xAA,0x00,0x04,0x01 };

ð char TEL_TC_READ[] = { 0xAA,0x00,0x04,0x02 };

ð char TEL_TC_CLEAR[] = { 0xAA,0x00,0x04,0x03 };

ð char TEL_RPM_READ[] = { 0xAA,0x00,0x05,0x04,0x01 };

ð char TEL_TEMP_READ[] = { 0xAA,0x00,0x05,0x04,0x02 };

ð char TEL_VOLT_READ[] = { 0xAA,0x00,0x05,0x04,0x03 };

ð char TEL_PARAM_SET[] = { 0xAA,0x00,0x05,0x05,0xFF };

ð char TEL_END_DIAG[] = { 0xAA,0x00,0x04,0x0F };

The parameters define how the interface will process the telegrams on the diagnostic bus. The individual parameters are explained in
the comment before the definition of the parameter fields.

CTRLPOS and CTRLOR are constants which are needed again and again in this SGBD and so they are defined at the beginning of
the file to make the file easier to read.

The telegrams are diagnostic jobs defined in the control unit specification.

In the INITIALISIERUNG job the communication parameters are sent to the interface:

//////////////////////////////////////////////////////////////////////

open_communication(); //make connection to interface

ð set_repeat_counter(2); // set repeat counter

ð set_communication_pars9PARAMETER); // set communication

ð set_answer_length(AWLEN); // parameters

DONE = 1;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 16 of 161

The function set_repeat_counter ensures that each failed control unit communication is repeated twice. The functions
set_communication_pars and set_answer_length use the predefined constants to load the communication parameters to the
interface. These functions and their parameters are described fully in [1].

Continue with the next point by opening the C:\EDIABAS\TUTORIAL\DEMO3.B2V file.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.6. Step 4: Control unit communication

The file DEMO3.B2V can already communicate with the control unit. To do this properly, two jobs are appended at the end of the
SGBD:

ð ///////////////////////////////////////////////////////////////////

ðjob( name : READ_IDENT;

ð comment : read out identification data;

ð result : IDENT_STRING;

ð type : string;

ð defrslt : ;

ð comment : string that identifies the control unit;

ð result : IDENT_VERSION;

ð type : string;

ð defrslt : ;

ð comment : control unit version number (1.1);

ð )

ð{

ð unsigned char answer[];

ð IDENT_STRING="*****";

ð IDENT_VERSION="*****";

ð send_and_receive(answer,TEL_ID_READ);

ð}

ð ///////////////////////////////////////////////////////////////////

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 17 of 161

ðjob( name : CLEAR_TC;

ð comment : clear fault memory;

ð result : STATUS;

ð type : string;

ð defrslt : ;

ð comment : Text: "Fault memory (NOT) cleared";

ð )

ð{

ð unsigned char answer[];

ð unsigned char statusText[];

ð send_and_receive(answer,TEL_TC_CLEAR);

ð}

ð ///////////////////////////////////////////////////////////////////

The job READ_IDENT is used to read the identification data, supplying it as two text results, IDENT_STRING and
IDENT_VERSION, to the calling application program. The results are pre-assigned the values "****" in the job. the buffer answer[]
is defined to receive the control unit answer. A length is not given: in BEST/2 all fields are up to 65536 bytes long (depending on the
string register size in the description file). Calling the function send_and_receive sends the predefined TEL_ID_READ to the
control unit and the answer is expected in the answer field.

The job CLEAR_TC6 clears the control unit's fault memory by sending the telegram TEL_TC_CLEAR to the control unit. The
answer is expected in the locally defined buffer answer. The field statusText is also defined - this is where the result text for the
result STATUS will be generated.

The job ENDE is expanded by sending the diagnostic end telegram TEL_END_DIAG:

ð unsigned char answer[];

ð open_communication(); //make connection to interface

ð send_and_receive(answer,TEL_END_DIAG);

Here again, the answer is expected in the answer field.

To test the changes made so far, we will now compile the SGBD. You can ignore the 2 warnings. They just say that the variable
statusText and the result STATUS were not used in the CLEAR_TC job. Provided the compile run is OK the description file
can be tested with the debugger. To do this, start the BestView debugger with the PROJECT/DEBUG menu or the 5th key from
left.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 18 of 161

Having started the debugger you are asked to select the job. Select READ_IDENT for the first attempt and press OK to confirm your
choice. You will see the SGBD source code in the window. Scroll down and position the cursor on line 109. Use F9
(DEBUG/TOGGLE BREAKPOINT to set a breakpoint in this line, i.e. job processing will be interrupted at that point. Hit F5
(RUN/GO) to start the selected job. A window with a counter shows the number of processed internal working cycles. When the run
reaches line 109 it stops and the current line is marked. This line has not been processed yet. You can now continue processing line
by line by pressing F8 (RUN/STEP). The debugger allows you to display variables and result contents during line-by-line processing
or when a breakpoint is reached. You will find further details in BestView's online help (HELP/CONTENTS).

To run the job to the end without stopping just hit F5 again (RUN/GO). When the job has finished you should see a window with the
results identified by the job. In this case it should contain the following:

VARIANTE = DEMO3.PRG

OBJECT = DEMO3

SETS =1

UBATTCURRENT = UNKNOWN UBATTHISTORY = UNKNOWN

IGNITIONCURRENT = UNKNOWN IGNITIONHISTORY = UNKNOWN

JOB STATUS =

SET 1: RESULT 1: [ TEXT ] IDENT_STRING = "*****"

RESULT 2: [ TEXT ] IDENT_VERSION = "*****"

The operation described above can be repeated as often as you like with this or any other job.

Continue with the next point by opening the C:\EDIABAS\TUTORIAL\DEMO4.B2V file.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.7. Step 5: String and Data functions

This version evaluates the answer telegrams sent by the control unit. For this purpose the job READ_IDENT is added to the SGBD as
follows:

ð unsigned char answer[];

ð unsigned char idString[];

ð unsigned char verString[];

IDENT_STRING="*****";

IDENT_VERSION="*****";

ð send_and_receive(answer,TEL_ID_READ);

ð // valid answer ?

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 19 of 161

ð if (answer[CTRLPOS]==TEL_ID_READ[CTRLPOS] | CTRLOR) {

ð // Make IDENT_STRING

ð datacopy(idString,answer,4,13);

ð strrevers(idString);

ð IDENT_STRING=idString;

ð // Make IDENT_VERSION

ð dataclear(idString);

ð bcd2ascii(verString,answer,17,1);

ð strcopy(idString,verString);

ð strcat(idString,".");

ð bcd2ascii(verString,answer,18,1);

ð strcat(idString,verString);

ð IDENT_VERSION=idString;

ð }

To compute the text results the buffers idString and verString are defined. After checking the control byte in the answer
telegram, 13 characters are copied from the telegram from the 4th position. The string must also be reversed with the
strrevers function so that the result is shown correctly.

The control unit version is a 4-digit BCD number in the telegram from address 17. The first BCD number is read in (bcd2ascii) and
copied to the idString buffer. A full-stop is appended to separate the version number and then the second BCD number is appended.

In the TC_CLEAR job the test result Status should be assigned the string "fault memory cleared" or "fault memory NOT cleared"
irrespective of the returned control byte:

unsigned char answer[];

unsigned char statusText[];

ð statusText="fault memory ";

send_and_receive(answer,TEL_TC_CLEAR);

ð // valid answer ?

ð if (answer[CTRLPOS]!=TEL_TC_CLEAR[CTRLPOS] | CTRLOR))

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 20 of 161

ð strcat(statusText,"NOT");

ð strcat(statusText, "cleared");

ð STATUS=statusText;

If you now compile the file created, starting the debugger as described in the previous section, you will see the following output in
the Results window when the READ_IDENT job is finished:

VARIANTE = DEMO4.PRG

OBJECT = DEMO4

SETS =1

UBATTCURRENT = UNKNOWN UBATTHISTORY = UNKNOWN

IGNITIONCURRENT = UNKNOWN IGNITIONHISTORY = UNKNOWN

JOB STATUS =

SET 1: RESULT 1: [ TEXT ] IDENT_STRING = "ICH BIN SG AA"

RESULT 2: [ TEXT ] IDENT_VERSION = "18.29"

Continue with the next point by opening the C:\EDIABAS\TUTORIAL\DEMO5.B2V file.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.8. Step 6: Result sets

This version will read out and evaluate the control unit fault memory. For this purpose the job READ_TC is added to the SGBD:

ð job( name : READ_TC;

ð comment : read out fault memory;

ð result : TC_NR;

ð type : int;

ð defrslt : ;

ð comment : fault number;

ð )

ð {

ð unsigned char answer[];

ð int count;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 21 of 161

ð send_and_receive(answer,TEL_TC_READ);

ð // valid answer ?

ð if (answer[CTRLPOS]==TEL_TC_READ[CTRLPOS] | CTRLOR) {

ð count=256*answer[1]+answer[2]-4; // compute number of faults

ð while(count--) { // for all faults

ð TC_NR=answer[4+count]; // assign fault number to result

ð new_set_of_results(); // start new result set

ð }

ð }

ð}

This job returns the result TC_NR which simply displays the stored fault code for all faults reported by the control unit. This is done
by storing the same result in a number of result sets. In the loop that runs across all faults the start of a new set is marked after the
result value is assigned. All results that are assigned subsequently are stored in this new set, and results in previous sets are not
changed.

This job returns the following results when it has been processes in the debugger as described above:

VARIANTE = DEMO5.PRG

OBJECT = DEMO5

SETS =5

UBATTCURRENT = UNKNOWN UBATTHISTORY = UNKNOWN

IGNITIONCURRENT = UNKNOWN IGNITIONHISTORY = UNKNOWN

JOB STATUS =

SET 1: RESULT 1: [ INTEGER ] TC_NR = +5

SET 2: RESULT 1: [ INTEGER ] TC_NR = +48

SET 3: RESULT 1: [ INTEGER ] TC_NR = +2

SET 4: RESULT 1: [ INTEGER ] TC_NR = +16

SET 5: RESULT 1: [ INTEGER ] TC_NR = +1

Five result sets are created, all containing the same result but with different values.

Continue with the next point by opening the C:\EDIABAS\TUTORIAL\DEMO6.B2V file.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 22 of 161

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.9. Schritt 7: Step 7: Table processing

As well as the above results in the READ_TC job, file DEMO6.B2V returns not only the fault code but also the corresponding fault
text. These fault texts are stored in a table:

char TEL_END_DIAG[] = { 0xAA,0x00,0x04,0x0f };

ð // *** SG - TABLES ***

ð //

ð // Table of fault location texts

ð table TCText[2] []=

ð {

ð {"NR", "TEXT" },

ð {"0x01", "Rear left speed sensor failed" },

ð {"0x02", "Rear right speed sensor failed" },

ð {"0x03", "Front right speed sensor failed"},

ð {"0x04", "Front left speed sensor failed" },

ð {"0x05", "Rear left ABS valve failed" },

ð {"0x06", "Rear right ABS valve failed" },

ð {"0x07", "Front right ABS valve failed" },

ð {"0x08", "Front left ABS valve failed" },

ð {"0x10", "Internal fault" },

ð {"0xFF", "undefined fault" }

ð };

This table has 2 columns and as many lines as required. The first column "NR" gives the fault code in hexadecimal format. The
second column "TEXT" gives the corresponding fault text for the fault number. The last line is the default telegram that is used when
the fault code is not found.

The READ_TC job must be changed as follows:

comment : Fault no;

ð result : TC_TEXT;

ð type : string;

ð defrslt : ;

ð comment : fault text;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 23 of 161

ð )

ð {

ð unsigned char answer[];

ð char tableText[];

int count;

send_and_receive(answer,TEL_TC_READ);

// valid answer ?

if (answer[CTRLPOS]==TEL_TC_READ[CTRLPOS] | CTRLOR) {

count=256*answer[1]+answer[2]-4; // compute number of faults

ð tabset("TCTEXT"); // initialize table processing

while(count--) { // for all faults

ð tab_suche_index(Nr",answer[4+count]); // search for fault

// number

ð tabget(tableText,"Text")); // read corresponding

// fault text

TC_NR=answer[4+count]; // assign fault number to result

ð TC_TEXT=tableText; // assign fault text to result

new_set_of_results(); // start new result set

The command tabset initializes table processing and all subsequent table processing commands affect the "TCText" table. The
command tab_suche_index changes the second argument it receives into a string with the format "0x##". This string is searched in
the "NR" column of the table. The search stops when the value is found. The command tabget now reads out the corresponding text
on the same line in the "TEXT" column. If the search text is not found it reads the text from the last line.

The results of this job look like this:

VARIANTE = DEMO6.PRG
OBJECT = DEMO6

SETS =5

UBATTCURRENT = UNKNOWN UBATTHISTORY = UNKNOWN

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 24 of 161

IGNITIONCURRENT = UNKNOWN IGNITIONHISTORY = UNKNOWN

JOB STATUS =

SET 1: RESULT 1: [ INTEGER ] TC_NR = +5

RESULT 2: [ TEXT ] TC_TEXT = "Rear left ABS valve failed"

SET 2: RESULT 1: [ INTEGER ] TC_NR = +48

RESULT 2: [ TEXT ] TC_TEXT = "undefined fault"

SET 3: RESULT 1: [ INTEGER ] TC_NR = +2

RESULT 2: [ TEXT ] TC_TEXT = "Rear right speed sensor failed"

SET 4: RESULT 1: [ INTEGER ] TC_NR = +16

RESULT 2: [ TEXT ] TC_TEXT = "Internal fault"

SET 5: RESULT 1: [ INTEGER ] TC_NR = +1

RESULT 2: [ TEXT ] TC_TEXT = "Rear left speed sensor failed"

Each result set contains 2 results, the fault number and the fault text.

Continue with the next point by opening the C:\EDIABAS\TUTORIAL\DEMO7.B2V file.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.10. Step 8: Real processing and result request

In this version of our SGBD a job is added that reads out three status values from the control unit. The application program can
determine which results are to be computed and which are not. This can speed up the job run when only one result is required. The
new job is appended to the end of the SGBD:

ð ///////////////////////////////////////////////////////////////////

ð job( name : READ_STATES;

ð comment : read out various statuses;

ð result : ENGINESPEED;

ð type : unsigned int;

ð defrslt : ;

ð comment : speed in RPM;

ð result : TEMPERATURE;

ð type : real;

ð defrslt : ;

ð comment : temperature in degrees C;

ð result : VOLTAGE;

ð type : real;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 25 of 161

ð defrslt : ;

ð comment : supply voltage in Volts;

ð )

ð unsigned char answer[]; // buffer for CU answer

ð unsigned int tmp; // aux variable

ð real a; // aux variable

ð real b; // aux variable

ð if(ENGINESPEED) { // result requested ?

ð send_and_receive(answer,TEL_RPM_READ);

ð if (answer[CTRLPOS]==TEL_RPM_READ[CTRLPOS] | CTRLOR) {

ð tmp=256*answer[4]+answer[5];

ð tmp/=4; // adc16/4

ð ENGINESPEED=tmp;

ð }

ð }

ð if(TEMPERATURE) { // result TEMPERATURE requested ?

ð send_and_receive(answer,TEL_TEMP_READ);

ð if (answer[CTRLPOS]==TEL_TEMP_READ[CTRLPOS] | CTRLOR) {

ð tmp=256*answer[4]+answer[5];

ð itor(a,tmp);

ð ator(b,"100.0"); // adc16/100-40

ð realdiv(a,b);

ð ator(b,"40.0");

ð realsub(a,b);

ð TEMPERATURE=a;

ð }

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 26 of 161

ð }

ð if(VOLTAGE) { // result VOLTAGE requested ?

ð send_and_receive(answer,TEL_VOLT_READ);

ð if (answer[CTRLPOS]==TEL_VOLT_READ[CTRLPOS] | CTRLOR) {

ð tmp=256*answer[4]+answer[5];

ð itor(a,tmp);

ð ator(b,"1.238"); // 1.238*adc16100/4000

ð realmul(a,b);

ð ator(b,"4000.0");

ð realdiv(a,b);

ð VOLTAGE=a;

ð }

ð }

ð }

The construct if(ENGINESPEED) does not read the value of the result ENGINESPEED, it decides whether this result was requested
by the application program (the way in which the application program requests these results is described in [6]). ENGINESPEED
returns TRUE if the result must be computed, otherwise FALSE. You can also test this in BestView: the RUN/JOB dialogue contains
a field in which the requested results can be entered. If nothing is entered, then all the results are returned. To request the VOLTAGE
and ENGINESPEED results enter "Results you want to see:" in the field.

voltage;enginespeed

The instructions in the block if(TEMPERATURE) { ... } are not processed. If nothing is entered then all results are reckoned to have
been requested.

If nothing is entered, all results are returned.

When computing the temperature (TEMPERATURE) and supply voltage (VOLTAGE) an integer is read out of the answer telegram
(tmp) and changed to a real number by the itor function. This real number is then handled by functions because BEST/2 has not
operators to process real numbers with.

Continue with the next point by opening the C:\EDIABAS\TUTORIAL\DEMO8.B2V file.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.11. Step 8: Job parameter

In this final version a job is added to the description file that sends a parameter defined by the application program to the control unit.
This parameter is a byte that is inserted into the telegram to the control unit. When the parameter is sent its value is overwritten on the
5th byte in the telegram to the control unit. If no parameter is set the predefined telegram is used:

/////////////////////////////////////////////////////////////////

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 27 of 161

ð job( name : SET_PARAM;

ð comment : set a parameter in the control unit;

ð argument : PARAMETER;

ð type : int;

ð comment : value of parameter to be set;

ð result : STATUS;

ð type : string;

ð defrslt : ;

ð comment : Text: "Parameter (NOT) set";

ð )

ð {

ð unsigned char answer[]; // buffer for CU answer

ð unsigned char request[]; // buffer for CU_Request

ð unsigned char statusText[]; // buffer for resulttext

ð request=TEL_PARAM_SET; // generate request

ð if(exist(PARAMETER)) { // if parameter exists

ð request[4]=PARAMETER; // change request

ð }

ð send_and_receive(answer,request);

ð statusText="Parameter"; // pre-assign statusText

ð // valid answer ?

ð if (answer[CTRLPOS]!=TEL_PARAM_SET[CTRLPOS] | CTRLOR))

ð strcat(statusText,"NOT");

ð strcat(statusText, "set");

ð STATUS=statusText;

ð }

The exist operator checks whether the parameter PARAMETER has been supplied to the job. the application program must send the
parameters in the sequence as defined in the job header. There is no check. The application program supplies the parameters as a
cohesive string, with parameters separated by a ;. A parameter ;; is reckoned not to be sent. In BestView you can also send arguments

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 28 of 161

to the job. To do this you edit the field "Parameters to be supplied to job:" (sic) field in the RUN/JOB dialogue.

Examples:

;;TEST
Only supplies TEST as the third argument to a job.

0x0005;0x0001
Sends two parameters to a job.

The parameters must be provided with data types, then conversion is automatic. If the first parameter in the above example is a string
type and the second an int type, then the first is seen as a field and the second as a number.

EDIABAS BEST Developer's Guide > BEST User Manual > 4. Tutorial

4.12. Binary parameters and binary results

A job can also receive and return binary parameters and results.

Only one binary parameter of the data type can be defined. This contains a binary field that contains either the complete parameter
string or a special data field. API has special functions (apiJobData/apiJobExt, see [6]) for supplying a binary data field.

More than one result of the data type can be defined on the other hand, and these can be assigned array variables in binary format,
e.g. telegrams.

Example:

job( name : READ_2_TELEGRAMS;

comment : set a parameter in the control unit;

argument : SEND_TEL;

type : data;

comment : telegram to be sent;

result : RECV_TEL_1;

type : data;

defrslt : ;

comment : 1st receive telegram

result : RECV_TEL_2;

type : data;

defrslt : ;

comment : 2nd receive telegram

unsigned char answer1[]; // buffer for CU answer

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 29 of 161

unsigned char answer2[]; // buffer for CU answer

unsigned char request[]; // buffer for CU request

request=SEND_TEL; // generate request

send_and_receive(answer1,request); // CU communication

send_and_receive(answer2,request);

RECV_TEL_1=answer1; // results

RECV_TEL_2=answer2;

EDIABAS BEST Developer's Guide > BEST User Manual

5. BEST Tools
This section describes tools for creating description files.

More:

5.1. BEST2(WIN)

5.2. BestBoard

5.3. BestView

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools

5.1. BEST2(WIN)

BEST2 and BEST2WIN are used to compile ECU description files written in BEST/2 into an object which can be interpreted by
EDIABAS.

BEST2 is a Win32 program called BEST2.EXE is consequently started from the explorer. We recommend, however, that BEST2
be included in a program group.

BEST2WIN is a Win32 program called BEST2WIN.EXE and is consequently started from the explorer. We recommend, however,
that BEST2WIN be included in a program group. An on-line help is available in menu "Help" under option "Contents" which
extensively explains all operating procedures as well as the BEST2WIN call parameters.

BEST2(WIN) have to be assigned parameters via the command line:

BEST2 [-C commandfile] [-B] [-A] [-I] [-S] [-L libfile] [-Z includedir]

[-R revMAJ.revMIN username] [-O errorlogfile]


[-P passwordlabel|@passwordlabellist ] sourcefile [outdir]
[-Q]

BEST2WIN [-C commandfile] [-B] [-A] [-I] [-S] [-L libfile] [-Z includedir]

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 30 of 161

[-R revMAJ.revMIN username] [-O errorlogfile]


[-P passwordlabel|@passwordlabellist ] sourcefile [outdir]

Compiler option -L enables specification of an alternative BEST/2 runtime library. If this option is not used, BEST/2 uses the
default file B2RUNTIM.LIB. Search is made in the directory where BEST2(WIN).EXE resides.

BEST2(WIN) support the use of Include files. These files are first searched in the directory of the BEST/2 source file. With the
option –Z, the search can be extended to another directory. If several Include directories are indicated, they are searched from left
to right, where each directory is labelled with the option –Z (-Z incldir1 –Z incldir2 ... –Z incldirN). This option is disregarded if
the BEST/2 source file already contained information on the path of the Include file.

The option -S leads to the additional output of the BEST/2 preprocessor file with the ending .p2v for variant description files
or .p2g for group description files, respectively. The BEST/2 preprocessor file contains the entire BEST/2 source code including
the content of the BEST/2 Include files.

If compiler option -A or -I are also specified, either an assembler output (*.b1) or an Infofile with the extension .bix for variant
description files (or .big for group descriptions files (or both)) are output in additional to the object file. All mandatory comments
from the BES/2 source file are listed in the Infofile.

Compiler option -R and its parameters enables a certain revision number and an author to be stored in the object file, overwriting
the specifications in the BEST/2 header.

The option –O stores an error log file. This file has the extension .out. If compiler option -O is not specified, an error log file with
the name best2err.out is then automatically created in case of an error.

Compiler option -P and its parameters enables certain passwords to be stored in the object file. Either a single label to a password
can be specified in a file, or an entire list of label. The parameter is characterized by a prefix "@" as file name. Only password
labels can be used which were previously made known to the system.

The parameter sourcefile describes one or more BEST/2 source files. The optional parameter outdir determines the directory where
BEST2 is to store the output files.

BEST2(WIN) command line parameters can be stored in separate text files and made known by the command line parameter -C
<command line parameter file>.

Compiler option –Q suppresses in BEST2 die acknowledgement of the end of program. Option –B also automatically sets option –
Q.

Example:

BEST2 demo.b2v

BEST2 -R 1.0 Otto *.b2g

BEST2 -A -I -S -Z c:\test\ecu\include test.b2v c:\test\ecu

BEST2 -L c:\test\ecu\mylib.lib -I test.b2v c:\test\ecu

BEST2 -P GEHEIM test.b2v c:\test\ecu

The minimum version required by EDIABAS is output for each source files which compiled without errors:

<source file>: 0 error(s) [ EDIABAS <minimum version> ]

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools

5.2. BestBoard

More:

5.2.1. General Information

5.2.2. Menu overview

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 31 of 161

5.2.3. Toolbar

5.2.4. Application programs

5.2.5. Developing a description file with BestBoard

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.2. BestBoard

5.2.1. General Information

BestBoard combines the creation of description files in a single program and controls the Editor, the Compiler and the Debugger. It
also lets you run your own application programs for test purposes.

BestBoard is available for WIN32 (BESTBD32.EXE). BestBoard is started from the Explorer. However we recommend that you
put BestBoard in a program group.

After calling BestBoard, you must first enter 2 directories:

• ECU Directory:
Menu: Options ECU directory
The SGBDs in object format are in this directory, or they should be stored there.
When the program is started, the EDIABAS configuration element EcuPath is considered and, if available, assumed.

• EDIABAS Directory:
Menu: Options EDIABAS directory
This directory contains the installed EDIABAS version with the sub-directories BIN, ECU, API etc.
When the program is started, the current EDIABAS directory is assumed.

The Editor to be used should also be entered:

The name of the editor must be entered in the Tools/Editor menu with the exact command line. A working directory of the Editor can
also be entered optionally. The "Notepad" editor that is generally available under Windows is used as a default.

If the control unit simulator or an EDIABAS trace is activated while starting or stopping BestBoard, you will see a warning together
with the set parameters.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.2. BestBoard

5.2.2. Menu overview

File

New Creates a new description file (BEST/2 source file)

Open Opens a description file (as source file or object file)

The File menu also lists the last 4 description files, the desired description file is opened by selecting a
name

Exit Quit program

Project

Edit Calls the Editor with the BEST source file

Compile Compiles the BEST source file by calling BEST2(WIN)

Debug Calls the BEST debugger BestView with the BEST source file and BEST object file

Next Error Displays the next compiler error

Previous Error Displays the previous compiler error

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 32 of 161

Run Application Calls the active application program (see also the section on application programs)

Tools

Applications Menu for application program management: activates, clears, adds, changes and calls application
programs

Editor Identifies the Editor to be used

API-Trace Turns API Trace On/Off

IFH-Trace Turns IFH Trace On/Off

ECU Simulation Turns IFH control unit simulator On/Off

Options

ECU Directory Identifies the ECU directory


N.B.: The environment variable ECU is not changed!

EDIABAS-Dir. Identifies the EDIABAS directory


N.B.: The environment variable EDIABAS is not changed!

Auto Editor Act. Automatic activation of the editor when opening the BEST source file.

Save Configur. Stores the current BestBoard configuration when you quit BestBoard (file BESTBD.INI or
BESTBRD.INI in the Windows directory)

Window

Default Sets the default position and size of the BestBoard main window

Always On Top Turns on/off the option of always positioning BestBoard in the desktop foreground

Toolbar Turns Toolbar On/Off

Status Bar Turns status display On/Off

Help

About Displays BestBoard version

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.2. BestBoard

5.2.3. Toolbar

The Toolbar is intended to simplify the selection of the main menu options. Hitting a button in the Toolbar selects only the
corresponding menu.

"Pressed" buttons indicate that an action has started (e.g. Compiler running).

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.2. BestBoard

5.2.4. Application programs

In BestBoard it is possible to integrate any desired programs that you need to develop or test description files. BestBoard can manage
several application programs simultaneously. BestBoard always starts the active application program. The active application program
is the application program selected in the TOOLS/APPLICATIONS menu.

The name and the command line must be entered for each application program. If you wish you can also specify the working
directory in which the application program is started.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 33 of 161

Various replacements can be entered on the command line (e.g. current object file, current ECU directory etc.).

In BESTBD32.EXE you can specify only WIN32 programs.

N.B.:

Application programs can only be called when a description file is opened/generated in BestBoard.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.2. BestBoard

5.2.5. Developing a description file with BestBoard

1. Creating BEST source file:

• If source file does not yet exist: File/New menu or Toolbar button

• If source file already exists: File/Open menu or Toolbar button

• Enter source file in Editor (is started automatically)

2. Compiling BEST source file:

• Project/Compile menu or Toolbar button

• If compile errors occur:

Correct source file in the Editor (is started automatically), the relevant line number and the error message are output in the
BestBoard working area. You can switch to the other error messages with the Project/Next Error and Project/Previous
Error menus. An audible warning tone and an empty working area signal the end of the error list.

• After correcting the description file in the Editor: Repeat 2.

3. Testing description file with Debugger

• Project/Debug menu or Toolbar button

• With logic errors:

Start Editor with Project/Edit or Toolbar button and edit source file, then repeat 2.

4. Testing description file with one or more application programs

• Select application program from Tools/Applications menu

• Start application program with Project/Run Application menu or Toolbar button

• With logic errors proceed as in 3.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools

5.3. BestView

More:

5.3.1. General Information

5.3.2. User Interface

5.3.3. Selecting a Description File

5.3.4. Updating a Description File

5.3.5. Selecting a Job

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 34 of 161

5.3.6. Setting Breakpoints

5.3.7. Display and Alteration of Variables

5.3.8. Execution of a Job

5.3.9. Menus

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView

5.3.1. General Information

BestView is a Source Level Debugger for testing SGBD's written in BEST/2. These files must exist both as source code and as object
files. Alternatively, object or BEST/1 files can be tested but without the source code debugging facility.

BestView is available for WIN32 (BESTVW32.EXE).

With BestView you can run jobs line by line and view variables and analyze the job results during the run.

You can get detailed explanations of all the user operations and the BestView call parameters by selecting the "Contents" option from
the "Help" menu.

In the following chapters BESTView is described in detail.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView

5.3.2. User Interface

BestView for WIN32 has a new user interface different from the WIN16 version with new and altered workspaces:

More:

5.3.2.1. Toolbar

5.3.2.2. Status Bar

5.3.2.3. Project Window

5.3.2.4. Source Code Window

5.3.2.5. Watch Window

5.3.2.6. Results Window

5.3.2.7. IFH Trace Window

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.2. User Interface

5.3.2.1. Toolbar

BestView now has a toolbar with buttons for the following functions:

· choosing SGBD

· choosing job

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 35 of 161

· starting/continuing job

· continuing job by 1 instruction

· setting or deleting breakpoint

· opening variable, parameter, or result dialog

· opening watch variable dialog

· displaying IFH trace file

· deleting IFH trace file

· opening text search dialog

· repeating text search

· online help

The toolbar is implemented as a docking window and can also be positioned outside the BestView workspace.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.2. User Interface

5.3.2.2. Status Bar

In the status bar, BestView displays additional information. On the right side, an active simulation and/or IFH trace is indicated.

If the source, IFH and result windows are active, the current position within the window (row, column) is also displayed in the
status bar.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.2. User Interface

5.3.2.3. Project Window

The Project Window provides information on the content of the currently loaded description file. The folder "Source Files" lists all
source files involved in the compilation process (B2V file + Include files). The "Jobs" folder contains all jobs available in the
description file (except virtual jobs and jobs in basic files).

By clicking once on an entry in the Project Window, it is possible to display the corresponding source file or the first instruction of
the corresponding job in the Source Window, respectively.

A double-click on a job within the Project Window will open the job selection dialog, unless this job is one of the jobs last started
(see chapter Menu Run-Job). In this case, a double-click will start the job immediately.

The Project Window can be used as a miniature window or as a docking window (see fig.). As a miniature window, it can also be
positioned outside the BestView workspace without changing it. As a docking window, it can dock with the left, right, top or
bottom part of the BestView workspace; the size of the BestView workspace decreases accordingly. It is possible to switch
between miniature and docking window representation by double-clicking on the frame of the Project Window. A new docking
position can be selected by simply drawing the Project Window to the desired position on the BestView frame.

The width and height of a "docked" Project Window are determined by the size of the Project Window in miniature window
representation. For changing the size of the "docked" Project Window, you have to change to the miniature window display, alter
the window size and then change back to the docking display.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.2. User Interface

5.3.2.4. Source Code Window

In the Source Code Window, the source code of the SGBD is displayed. Here, breakpoints (with brown background) can be set.
The line to be executed during the next program step has a yellow background.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 36 of 161

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.2. User Interface

5.3.2.5. Watch Window

In the Watch Window, the content of variables is displayed.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.2. User Interface

5.3.2.6. Results Window

In the Results Window, the content of the job results is displayed.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.2. User Interface

5.3.2.7. IFH Trace Window

In the IFH Trace Window, the content of the IFH trace file is displayed. After each job execution and each job interruption (e.g.
after Run-Step), the Trace Window is automatically updated.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView

5.3.3. Selecting a Description File

Description files can be selected with the ”File Open“ menu. BEST/2 source files (with the ending .B2V or .B2G) can be opened
as well as BEST/1 source files (with the ending .B1V or .B1G) and executable object files (with the ending .PRG or .GRP). A
description file can also be opened by drag&drop; the file must be dragged from the Explorer to the workspace of BestView.

Debugging is possible only if a BEST/2 source file is opened. With a BEST/1 source file or an object file, the jobs can only be
executed.

If a source file is selected, BestView searches the corresponding object file in the directory selected with ”ECU-Directory“. If you
do not want this, you can set the ”ECU-Directory“ option to '.' In this case, BestView searches the object file in the directory of
the source file. Changing the ECU directory is only possible if no description file is loaded in BestView.

If an object file is selected, BestView behaves like the normal EDIABAS runtime system. If a group is selected, the job
IDENTIFIKATION in the group file is executed automatically; then the selected job in the variant file determined in this manner
is executed. In case of source file selection, a group description file behaves in the same way as a variant description file, i.e. the
IDENTIFIKATION job has no particular significance and can be examined at any time.

When a description file is opened, it is displayed in a Source Window; if, on the other hand, an object file is selected, only a
minimized Object Window is displayed. A description file can be based on several BEST/2 source files (modules). With the ”File
View“ menu, it is possible to switch between the different modules.

BestView permits automatic opening of a Project Window displaying all jobs and BEST/2 source files (modules) of the loaded
description file. The Project Window can be used as a miniature or a docking window. With the miniature display, the Project
Window can be positioned in any part of the window desktop without influencing the workspace of BestView. With the docking
window display, the workspace of BestView is automatically reduced in size depending on the docking position (left, right, top or
bottom). By double-clicking on the Project Window frame, it is possible to switch between the miniature and the docking display.
With the ”Window Project“ menu, the Project Window display can be switched on or off.

The linkage of the debugger with a description file is maintained until the file is closed with the ”File Close“ menu, the
Description File Window is closed or a new description file is selected.

If a description file consists of several modules (the B2V file opened with File Open + Include files), the same search algorithm is
used for the Include file search as with the BEST/2 Compiler:

For #include instructions with absolute or relative paths, BestView only searches the indicated paths for the relevant
Include file. In case of relative paths, the path always refers to the directory of the B2V file opened with “File
Open“ (source directory).

In case of #include instructions without indication of path, BestView first searches the directory of the B2V file opened

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 37 of 161

with ”File Open“ for the corresponding Include file. With the ”Options Include-Path“ menu, the search can be extended to other
directories.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView

5.3.4. Updating a Description File

Changing a description file without leaving the debugger makes it necessary to update the description file.
This is done easily by again selecting the loaded description file with the “File Open“ menu.
Choose the file already indicated by default.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView

5.3.5. Selecting a Job

Selection of a job is performed by the ”Run Job“ menu. All jobs of the selected description file are displayed. The job
INITIALISIERUNG can be selected as well. In group description files, selection of the job IDENTIFIKATION is also possible.
If a group description file is opened as object file, the entered job name refers to the variant file and not to the group file.
The job to be executed can be configured by the following entries:

Job Parameters
The data entered here will later be passed to the job to be executed. With the ”String“ setting, the job parameters are
passed to the job unchanged. With the ”Data“ setting, the job parameters are converted into a binary data stream before job
execution and then passed to the job.
Binary data entry requires the following syntax:
hex,hex,hex,...
As an alternative to the direct entry of binary data, the job can also be provided with binary data specified in a separate text
file. If @<text file name> is indicated, the text file will be read in during job execution, converted into a binary data stream
and then be passed to the job. For this purpose, the text file must have the following format:
hex,hex,hex,hex,hex,hex,hex,hex

hex,hex,...

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 38 of 161

Standard Job Parameters


The data entered here will later be passed to the standard jobs automatically processed by BestView.
The possibilities of entry are identical with those of the other job parameters.

Job Results
Here, the results to be generated by the job can be selected. This functionality must be supported by the description file.
If nothing is entered in this input field, all results are generated.

Initialization of the Description File


This entry makes it possible to automatically execute the INITIALISIERUNG job directly before execution of the selected
job. After the loading of a description file, occurrence of an error or in case of job abort, the INITIALISIERUNG job must
always be carried through.
BestView saves the last 8 job names including all job configurations. By means of the drop-down list, a job carried out
previously can be selected with the corresponding job configurations.
With ”Go“, the job can be started directly from this dialog box.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView

5.3.6. Setting Breakpoints

Breakpoints are set in the Source Window. For this purpose, the cursor is placed on the line in the Source Window in which the
breakpoint is supposed to appear.

With the F9 key, the breakpoint in this line is activated. The line color changes. By pressing F9 again, the breakpoint is
deactivated.

Breakpoints can also be set and deleted with the mouse. To do this, place the mouse pointer on the desired line. A double-click
with the left mouse button will activate or deactivate the breakpoint in this line, respectively.

With the menu item ”Debug Clear Breakpoints“, all breakpoints are deleted.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView

5.3.7. Display and Alteration of Variables

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 39 of 161

Variables, results and parameters can be displayed with the menu item ”Debug Show Data“.

A dialog box appears in which the kind of data to be displayed can be selected. For the results, the desired set must be selected in
addition to the name.

All data are displayed as values and as binary data. The display format of the value can be adapted according to the requirements.

If the displayed value is a variable, it can be changed from the dialog box by a click on the Modify button or by means of the menu
item ”Debug Modify Variable“ in a separate dialog box.

During debugging, a variable can be continuously monitored in a separate window. For this purpose, it must be included in the
watch list with the menu item ”Debug Watch Variable“. It can also be removed from there.

If the mouse points to a variable or a parameter in the Source Window, the variable and parameter are automatically displayed.
Data variables are shown in hexadecimal form; the display is limited to max. 32 bytes.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView

5.3.8. Execution of a Job

Before the execution of a job, the description file is initialized if this was defined during job selection. For this purpose, the
EDIABAS runtime system is initialized and the INITIALISIERUNG job runs.

There are three ways of job processing:

Go

The job runs until either a breakpoint or the end of the job are reached.

Step

The next line in the job is executed.

Continue to Cursor

The job is executed down to the line where the cursor is located. If a breakpoint is set before the highlighted line, the job is
only executed to this breakpoint. It runs until either a breakpoint or the end of the job are reached.
In addition, it is possible to start a job by double-clicking on the corresponding job name in the Project Window. In case of an
unknown job configuration, the job selection dialog is displayed instead.

The line being currently processed is highlighted in color.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView

5.3.9. Menus

More:

5.3.9.1. Menu File

5.3.9.2. Edit Menu

5.3.9.3. Run Menu

5.3.9.4. Debug Menu

5.3.9.5 Options Menu

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 40 of 161

5.3.9.6. Window Menu

5.3.9.7. Help Menu

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.9. Menus

5.3.9.1. Menu File

Open

Opens a description file. Both source files and object files can be opened. Debugging is possible only if a BEST/2 source file is
opened. With a BEST/1 source file or an object file, the jobs can only be executed.

If a source file is selected, the object file is searched according to the configured ECU directory. If this directory is supposed to be
always identical with the source file directory, the directory in the Options menu must be set to '.' If ”Use EDIABAS
Configuration“ is selected, the ECU directory from the EDIABAS configuration file (EDIABAS.INI) is used.

Close

Closing the loaded description file. The linkage of the debugger with the loaded description file is cleared.

As long as a description file is loaded, it may not be changed in an Editor. Opening a new description file and leaving BestView
will automatically close the currently loaded description file.

View

Selection of the module to be displayed. If a description file consists of several BEST/2 source files (modules), another module of
the description file can be displayed in this manner.

The module to be displayed can also be selected via the Project Window.

Exit

Leaving BestView.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.9. Menus

5.3.9.2. Edit Menu

Copy

Copying a text selected in the active window to the clipboard.

Select All

Selecting the entire text of the active window.

Find

Searching a text in the active window. If the option ”Match Uppercase/Lowercase“ is activated, the case of character of the
searched text must be matched precisely.

The text search starts at the current cursor position.

Find Next

Text search is continued at the current cursor position.

Goto Line

Goes to a specific text line. By entering the desired line number, it is possible to go to the corresponding text line in the source
file.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 41 of 161

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.9. Menus

5.3.9.3. Run Menu

Job

Selection of the job to be executed. All jobs within the description file can be selected. In addition, the job parameters and desired
results can be indicated. With the ”Go“ button, the jobs can be started immediately.

Go

Start or restart of job processing. The job is executed until either a breakpoint or the end of the job is reached.

Continue to Cursor

Start or restart of job processing. The job is executed down to the line where the cursor is located. If a breakpoint is set before the
highlighted line, the job is only executed to this breakpoint. It runs until either a breakpoint or the end of the job is reached.

Step

Start or restart of job processing. The next code line is executed.

Restart

Restarts the selected job if it has not been finished yet.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.9. Menus

5.3.9.4. Debug Menu

Toggle Breakpoint

Setting or deleting a breakpoint. If no breakpoint is set in the current line, it is set now; otherwise, it is deleted.

The same can be achieved by double-clicking with the left mouse button on the corresponding line.

If it is not possible to set a breakpoint, an acoustic signal is given.

Clear Breakpoints

Deletes all breakpoints.

Show Data

Display of a variable, a parameter or a result. A dialog box is displayed where the values of all currently valid variables,
parameters or results and their binary representation can be displayed.

In this dialog box, the variable values can also be changed.

Modify Variable

Display and modification of a variable. All variables which are currently valid can be displayed and changed. A dialog box
appears which contains the variable value and its binary representation.

The value of single variables (no arrays) can be displayed in decimal, hexadecimal or ASCII representation.

The variable value can be changed in all three kinds of representation. By pressing the Update key, the binary display is updated.

The variable can also be changed in binary representation; the display format, however, must be observed.

After ”OK“ or ”Return“, the altered variable value is stored.

After ”Cancel“ or ”ESC“, the process is terminated without variable alteration.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 42 of 161

Watch Variable

Monitoring of a variable. The values of selected variables are displayed in a separate Watch window and updated continuously, i.e.
after each step.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.9. Menus

5.3.9.5 Options Menu

ECU Directory

Here, the directory can be set where the debugger searches the object files. If the debugger is to search the Source Directory, ”.“
must be entered.

If the option ”Use EDIABAS Configuration“ is activated, the ECU Directory selected via the EDIABAS configuration file
EDIABAS.INI is used.

Include Path

Here, additional directories can be indicated where BestView searches Include files. Directories must be separated by ”:“. The
search always begins in the directory of the BEST/2 source file opened with “File Open”. Subsequently, the Include path is
searched from left to right.

For #include instructions with absolute or relative paths, the Include path is not taken into account.

Device

Here, the communication device for EDIABAS can be set.

ECU Simulation

Here, the ECU simulation can be switched on or off; the EDIABAS configuration file EDIABAS.INI remains unchanged. In the
status bar, an active ECU simulation is indicated.

IFH Trace

Here, the IFH trace level can be entered and the IFH trace switched on or off, accordingly. The EDIABAS configuration file
EDIABAS.INI remains unchanged. In the status bar, an active IFH trace is indicated.

The IFH trace can be displayed via the menu ”Window IFH Trace“.

With the ”Delete File“ button, the IFH trace file can be deleted.

Auto Job Selection

If this option is active, the “Run Job” menu will automatically be executed after opening of a description file.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.9. Menus

5.3.9.6. Window Menu

Project

Opens or closes Project Window.

Watch

Opens or closes Watch Window.

IFH Trace

Opens or closes IFH Trace Window.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 43 of 161

Cascade

Arrangement of the windows in cascade form.

Tile Horizontally

Symmetrical horizontal arrangement of all windows with the exception of minimized windows.

Tile Vertically

Symmetrical vertical arrangement of all windows with the exception of minimized windows.

Arrange Icons

Uniform display of all minimized windows on the lower left margin.

EDIABAS BEST Developer's Guide > BEST User Manual > 5. BEST Tools > 5.3. BestView > 5.3.9. Menus

5.3.9.7. Help Menu

Contents

Calls the help text with its contents.

Index

Calls the help text with its search dialog.

About

Display of the version information for BestView and EDIABAS.

EDIABAS BEST Developer's Guide > BEST User Manual

A. Limits and restrictions


ECU description files are subject to the following technical limitations and restrictions:

· Maximum length of a BEST/2 source file = 65535 characters

· Maximum line length of a BEST/2 source file = 5199 characters

· Maximum length BEST/2 source file name (without ext.) = 8 characters

· Maximum length of a basic file name (without extension) = 8 characters

· Maximum length of an origin name = 63 characters

(additional characters are ignored)

· Maximum length of the author name = 63 characters

(additional characters are ignored)

· Maximum length of a BEST/2 names = 32 characters

(additional characters are ignored)

· Maximum length of a job name in the job header = 63 characters

· Maximum length of a argument name in the job header = 63 characters

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 44 of 161

· Maximum length of a result name in the job header = 63 characters

· Maximum lenght of a comment in the job header = 999 characters

· Maximum number of result records for a job = 65535

· Maximum number of results in a result record = 65535

· Maximum number of string and array variables in a job = 14

(up to EDIABAS 7.0.0 a maximum 6 string/array variables are supported)

· Maximum number of real variables in a job = 6

· Maximum size of a char arrays = 1023 .. 65535 characters

(depending on the string register size of the description file)

· Maximum size of an (unsigned) int array = 1023 bytes (511 values)

· Maximum size of a (unsigned) long array = 1023 bytes (255 values)

· Maximum length of a string result = 1023 characters

· Maximum size of a data result = 1023 .. 65535 bytes

(depending on the string register size of the description file)

· Maximum size of the global data memory = 1023 characters

· Maximum length of a global data memory ID = 32 characters

· Maximum number of passwords = 10

· Maximum length of a password label = 10 characters

· Maximum length of a password = 10 characters

· Maximum number of nested Include files = 8

· Maximum length of a result name = 63

· The nesting depth of statements is limited

EDIABAS BEST Developer's Guide > BEST User Manual

B. REFERENCES
[1] EDIABAS: BEST/2 Function Primer

[2] EDIABAS: ECU simulator

[3] EDIABAS: BEST/1 - Language and Interpreter

[4] EDIABAS: user manual and installation guide

[5] EDIABAS: BEST/2 - Language Description

[6] EDIABAS: API User Manual

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 45 of 161

EDIABAS BEST Developer's Guide

BEST/2 Language Description


More:

1. Introduction to BEST/2

2. Text conventions

3. Conversions

4. Expressions

5. Declarations

6. Statements

7. Global declarations

8. Areas of application

9. Runtime library

EDIABAS BEST Developer's Guide > BEST/2 Language Description

1. Introduction to BEST/2
BEST is the acronym for 'BEschreibungssprache für STeuergeräte' (description language for control units). In EDIABAS this
description language is used to meet the requirement for an application-independent description facility. During the program
runtime the system loads and interprets description files in which information about the control units such as addresses and
conversions is hidden (encapsuling). BEST/2 description language therefore provides the means to convert data stored in the
control units into control unit independent values such as engine speed or control unit number. Only data actually required by the
application is downloaded (information hiding).

A language with a syntax based on assembler language, BEST/1, already exists for this purpose. However although BEST/1 is
good for test purposes and simple programming it is difficult to read and understand.

The more readable BEST/2 language was developed based on C language to resolve these problems. C was chosen because it is in
widespread use, is structured and contains only a few language elements that are easy to learn.

BEST/2 is a problem-oriented language, with special functions that are called by library functions. The only exception to this rule
is the result manager which is a fundamental part of the language definition.

There are no storage definitions because the virtual processor used with BEST/2 has no memory apart from the stack that is
already available in the processor.

EDIABAS BEST Developer's Guide > BEST/2 Language Description

2. Text conventions
There are seven classes of word: names, reserved words, constants, strings, lists, operator and other separators. Blanks, tabs, line
separators and comments are classed as spaces and ignored apart from the fact that they are needed to separate adjacent names,
constants and reserved words.

More:

2.1. Comments

2.2. Names

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 46 of 161

2.3. Reserved words

2.4. Constants

2.5. Sizes

2.6. Syntax notation

2.7. What does a name mean

2.8. Objects and L values

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions

2.1. Comments

A comment starts with the characters /* and ends with the characters */. Comments that start with the characters // end at the end
of the line. Comments by /* */ cannot be nested.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions

2.2. Names

A name consists of a sequence of letters and digits; the first character must be a letter. The underscore character _ counts as a
letter. There is case sensitivity. The first 32 characters are used to distinguish names, but they may also be longer.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions

2.3. Reserved words

The following words are reserved and can only be used with their predefined meaning:

argument author break case char


comment const continue data default
defrslt do ecu else exist

if int job language long

name origin range real result


return revision sizeof string switch
type unsigned uses while #asm
#define #endasm #include #pragma #undef

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions

2.4. Constants

There is a whole range of constants and they are described in this section. Section 2.5 describes the properties of the virtual
processor that affects the size of the constants. All constants are Long Constants.

More:

2.4.1. Integer constants

2.4.2. Char constants

2.4.3. String constants

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 47 of 161

2.4.4. Lists (Data) constants

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions > 2.4. Constants

2.4.1. Integer constants

An integer constant consists of a string of digits. Its type is int and it is usually interpreted decimally.

If the string starts with the sequence 0x or 0X it is interpreted hexadecimally, i.e. in base 16, and the letters a (or A) to f (or F)
count as hexadecimal digits with the decimal values 10 to 15.

If the string starts with the sequence 0y or 0Y it is interpreted binary, i.e. in base 2, and only digits 1 and 0 are used.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions > 2.4. Constants

2.4.2. Char constants

A character in single quotes, e.g. 'x', is a char constant and its value is the value of the character in the ASCII character set.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions > 2.4. Constants

2.4.3. String constants

A string is a sequence of characters in double quotes, i.e. "...". A string ends with the character 0.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions > 2.4. Constants

2.4.4. Lists (Data) constants

A list is a sequence of other constants (not lists) separated by , and enclosed in { and }. Strings in lists do not end with 0. The
length of the list carried over.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions

2.5. Sizes

char 8 Bit ASCII

int 16 Bit
long 32 Bit
real 64 Bit
char[] max. 1023 bis 65535 Byte, default = max. 1023 bytes
int[] max. 1023 bytes
long[] max. 1023 bytes

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions

2.6. Syntax notation

The following rules apply when describing the grammar: "I" separates alternatives, "[" and "]" enclose optional parts, "{" and "}"
enclose optional parts that can be specified more than once, and ";" terminates a rule.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions

2.7. What does a name mean

A name is an object known to the compiler by its type and memory location.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 48 of 161

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 2. Text conventions

2.8. Objects and L values

An object is a storage area that can be modified. An L value is an expression that describes an object. A name is a simple example
of an L value expression. The term L value recalls the assignment E1=E2 in which the left operand must be an L value expression.

EDIABAS BEST Developer's Guide > BEST/2 Language Description

3. Conversions
More:

3.1. Characters and integers

3.2. Unsigned integers

3.3. Arithmetic conversions

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 3. Conversions

3.1. Characters and integers

char, int and long can be used wherever an integer object is needed. The values are converted to integer values. A char, int or
long value has a sign that is retained when converted to longer integer values.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 3. Conversions

3.2. Unsigned integers

When an unsigned value and a regular value are combined the regular value is converted to an unsigned value and the result is also
unsigned. A short unsigned value is converted into a regular value by adding zero bits as the most significant bits.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 3. Conversions

3.3. Arithmetic conversions

First char values are changed into long values.

If one of the operands is unsigned then the other is also changed to unsigned, and this then also becomes the type of the result.

Otherwise, both operands are long values and the result is also a long value.

EDIABAS BEST Developer's Guide > BEST/2 Language Description

4. Expressions
This section describes the operators for expressions. For simple expressions and unary operations the manual states whether they
return L values. The other operators do not return L values.

The following sections are arranged in descending order of priority of the operators; all the operators in a section have equal
priority. The associativity of the operators is given in each section (invisible bracketing).

Apart from priority, the processing sequence is undefined.

NOTE: Operators cannot be used with real values since this will lead to undefined results! Real values can only be
processed with the corresponding BEST/2 functions.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 49 of 161

More:

4.1. Simple expressions

4.2. Unary operators

4.3. Multiplication and division

4.4. Addition and subtraction

4.5. Shift operations

4.6. Comparisons

4.7. Equality comparisons

4.8. AND gating of bits

4.9. Exclusive OR gating of bits

4.10. OR gating of bits

4.11. Logic AND gating

4.12. Logic OR gating

4.13. Assignments

4.14. Lists of expressions

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.1. Simple expressions

Simple expressions are references to objects and constants, the index operation and function calls. These operations are left-
associative.

primary:
identifier
| constant integer
| constant array
| (expression )
| primary ( [argument-list] )
| primary [ expression ]
;

argument-list:
assignment { , assignment }
;

A name is a simple expression provided it has been suitably declared. Most names are L values. The name type is usually given by
the declaration. A constant is an L value. Constant arrays always return 1. Identifiers return their value. Arrays always returns the
value 1 unless they are assigned to arrays. Names of job results return 1 if the result was requested, otherwise 0. Names of job
parameters return 1 if they were specified, otherwise 0.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.2. Unary operators

Unary operators are right associative.

unary:

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 50 of 161

primary
| primary ++
| primary --
| - primary
| ! primary
| ~ primary
| ++ primary
| -- primary
| exist identifier
| sizeof unary
| sizeof (type-specifikation)
;

The unary - operator produces the negative value of its operand.

The ! operator for logic negation returns 1 for an operand with the value 0 and 0 for all other operands. The result is the long type.

The ~ operator complements the individual bits in its operand.

The ++ and -- operands (sic) modify their operands by adding or subtracting 1. The operand must be an L value. The result is not
an L value.

The expression ++E is equivalent to E+=1, so the result is the new value of the operand after 1 is added.

The expression --E is equivalent to E-=1, so the result is the new value of the operand after 1 is subtracted.

The expression E++ returns the same value of operand E, i.e. the original value of the object that the L value E describes. 1 is
added to the object itself.

The expression E-- returns the same value of operand E, i.e. the original value of the object that the L value E describes. 1 is
subtracted from the object itself.

The sizeof operator returns the size of its operand measured in bytes.

The exist operator returns <>0 (TRUE) or 0 (FALSE) depending on whether the specified identifier is available or not. This is
always TRUE for all variables, constants and result names but only for job arguments when they were defined when the job was
called.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.3. Multiplication and division

The operators *,/ and % for multiplication and division are left associative. The usual arithmetic conversions are used.

multiplication:
unary
| multiplication * unary
| multiplication / unary
| multiplication % unary
;

The binary operator * designates multiplication. It is commutative and associative.

The binary operator / designates division. When positive values are divided it breaks off towards 0. Otherwise it breaks off towards
the most negative number.

The binary operator % returns the remainder after dividing its two operators.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.4. Addition and subtraction

The operators + and - for multiplication and division are left associative. The usual arithmetic conversions are used.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 51 of 161

addition:
multiplication
| addition + multiplication
| addition - mutliplication
;

The + operator returns the sum of its operands. It is commutative and associative.

The - operator returns the difference of its operands.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.5. Shift operations

The shift operators << and >> are left associative. The usual arithmetic conversions are used. The right operand is converted into
an unsigned value.

shift:
addition
| shift << addition
| shift >> addition
;

The value of E1<<E2 is the bit pattern of E1 shifted E2 bits to the left.

The value of E1>>E2 is the bit pattern of E1 shifted E2 bits to the right. If E1 unsigned then bits with the value 0 are inserted. If
E1 is a regular value then bits are inserted according to its bit sign.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.6. Comparisons

Comparisons are left associative.

comparison:
shift
| comparison < shift
| comparison <= shift
| comparison > shift
| comparison >= shift
;

The comparison operators return the long value 0 if the specified relation is false and 1 when the relation exists. The usual
arithmetic conversions are used.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.7. Equality comparisons

The operators == and != behave in the same way as the other comparison operators but have a lower priority.

equality:
comparison
| equality == comaprison
| equality != comparison
;

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.8. AND gating of bits

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 52 of 161

bit-and:
equality { & equality }
;

The & operator is commutative and associative. The usual arithmetic conversions are used.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.9. Exclusive OR gating of bits

bit-exclusive-or:
bit-and { ^ bit-and }
;

The ^ operator is commutative and associative. The usual arithmetic conversions are used.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.10. OR gating of bits

bit-or:
bit-exclusive-or { | bit-exclusive-or }
;

The | operator is commutative and associative. The usual arithmetic conversions are used.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.11. Logic AND gating

andif:
bit-or { && bit-or }
;

The && operator is left associative. The result is 1 when both operators are not 0, otherwise the result is 0. The right operand is
only evaluated when the left is not 0.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.12. Logic OR gating

binary:
andif { || andif }
;

The || operator is left associative. The result is 0 when both operators are 0, otherwise the result is 1. The right operand is only
evaluated when the left is 0.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.13. Assignments

Assignment operators are right associative. The left operand must always be an L value. The type of the result is always the type of
the left operand. An assignment operation returns the value in the left operand as the result.

assignment:
binary
| unary = assignment
| unary *= assignment
| unary /= assignment

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 53 of 161

| unary %= assignment
| unary += assignment
| unary -= assignment
| unary &= assignment
| unary ^= assignment
| unary |= assignment
;

With simple assignment the value of the right operand replaces the value of the object which designates the left operand. Before
assignment the right operand is converted to the type of the left operand.

The value of the assignment in the form E1 op= E2 can be derived from the assignment E1 = E1 op (E2). E1 is only evaluated
once however.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 4. Expressions

4.14. Lists of expressions

expression:
assignment {, assignment}
;

Two expressions separated by a comma are evaluated left to right. The type and value of the result are the type and value of the
right expression. This operation is left associative.

EDIABAS BEST Developer's Guide > BEST/2 Language Description

5. Declarations
Declarations define how BEST/2 interprets the individual names entered by the user. They take the following form:

declaration:
type-name initialized-declarator-list ;
| real identifier ;
;

Definitions reserve storage space (register) and contain information for the type of a list of declarators. The declarators contain the
names that are declared, possibly together with initializers.

More:

5.1. Type names

5.2. Declarators

5.3. Initializers

5.4. Predefined Macros

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 5. Declarations

5.1. Type names

The following type names exist:

type-name:
[unsigned] int
| [unsigned] long
| [unsigned] char
;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 54 of 161

extra-type-name:
data
string
real
;

A declaration can only contain one type name.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 5. Declarations

5.2. Declarators

A declaration contains a list of declarators separated by commas. In data definitions an initializer can also be specified after each
declarator.

initialized-declarator-list:
declarator [ = initializer ]
;

declarator:
identifier { '[' ']' }
| ( declarator )
;

If a declarator is followed by a pair of square brackets then an array variable was declared.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 5. Declarations

5.3. Initializers

Data can also be initialized in a definition. Each initializer is preceded by the character = and followed by an expression.

initializer:
assignment
;

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 5. Declarations

5.4. Predefined Macros

BEST/2 contains a number of predefined macros permitting the query of header definitions in BEST/2 jobs:

__ECU__ designation of the control unit

__ORIGIN__ author of the first version

__REVISION__ current version (corresponds to header definition revision)

__AUTHOR__ author

__LANGUAGE__ language

__USES__ basic description files

__ECUCOMMENT__ comment (1st line)

In BEST/2 jobs, the macros are to be used like global string constants. If one of the optional header definitions is not available, the
macro will supply a null string.

EDIABAS BEST Developer's Guide > BEST/2 Language Description

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 55 of 161

6. Statements
Unless otherwise specifically stated, statements are executed sequentially.

statement:
statement-prefix statement
| [expression] ;
| compound-statement
| if ( expression ) statement
| if ( expression ) statement else statement
| do statement while ( expression ) ;
| break ;
| continue ;
| return ;
;

statement-prefix:
while ( expression )
| switch ( expression )
| case constant-integer :
| default :
;

More:

6.1. Compiler instructions

6.2. Assignments and procedure calls

6.3. Blocks

6.4. "if" statements

6.5. "while" statement

6.6. "do" statement

6.7. "switch" statement

6.8. "break" statement

6.9. "continue" statement

6.10. "return" statement

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.1. Compiler instructions

All compiler instructions must be indicated at the beginning of a line.

More:

6.1.1. #include

6.1.2. #define

6.1.3. #undef

6.1.4. #asm #endasm

6.1.5. #pragma

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 56 of 161

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements > 6.1. Compiler instructions

6.1.1. #include

With the #include instruction, additional BEST/2 source files can be entered in BEST/2 description files. A line

#include "BEST/2 source file"

is replaced by the content of the desired file. If absolute and relative paths are indicated, DOS notation must be used.

If the indicated Include file name contains an absolute or relative path, the Include file must be located in the corresponding
directory. With relative paths, the path of the BEST/2 source file is used.

If the indicated Include file name contains no path, searching starts in the directory of the BEST/2 description file. With the
compiler, the search can be extended to other directories.

Behind the filename of an #include instruction only a comment is permitted. The comment has to end within the same line. A
comment over more than this line is not permitted.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements > 6.1. Compiler instructions

6.1.2. #define

In BEST/2 description files, text replacements can be defined with the instruction #define. A line

#define identifier text

causes the name to be replaced by the indicated text throughout the BEST/2 description file. It is possible to distribute a long
replacement text over several lines by placing the character \ at the end of the line. No text will be replaced within comments and
character strings.

The name is structured according to the rules for other BEST2 names.

Macros and Escape symbols are not supported.

Behind the text of an #define instruction only a comment is permitted. The comment has to end within the same line. A comment
over more than this line is not permitted.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements > 6.1. Compiler instructions

6.1.3. #undef

In BEST/2 description files, previously performed #define definitions can be undone with the instruction

#undef identifier

Behind the identifier of an #undef instruction only a comment is permitted. The comment has to end within the same line. A
comment over more than this line is not permitted.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements > 6.1. Compiler instructions

6.1.4. #asm #endasm

In BEST/2 description files, BEST/1 code can be entered. It will be inserted between the instructions #asm and #endasm.

#asm

BEST/1 code

#endasm

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 57 of 161

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements > 6.1. Compiler instructions

6.1.5. #pragma

With the #pragma instruction BEST/2 compiler features can be configured, and thus the resulting code and execution of the ECU
description file can be influenced at runtime.

More:

6.1.5.1. arraysize

6.1.5.2. best2_version

6.1.5.3. runtime_version

6.1.5.4. best2_type

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements > 6.1. Compiler instructions > 6.1.5.
#pragma

6.1.5.1. arraysize

The array size of a ECU description file can be preset using the pragma arraysize:

#pragma arraysize ( <array size> )

The pragma instruction must always be situated at the beginning of a line and never inside of comments, strings, tables and
constants.

The setting of the array size always refers to all arrays of a compiled ECU description file. In case of multiple and differing
definitions of the array size the greatest value will always be assumed within an ECU description file. The definition of array sizes
smaller than 1024 bytes or greater than 65536 bytes causes compiler errors.

Without setting of an array size the arrays of an ECU description file will be limited to 1024 Bytes.

The last data byte in Arrays can in principle not be addressed. This constraint is valid independently of the array size set by the
pragma arraysize.

The actually possible number of data bytes in ECU telegrams depends on the used interface and protocol.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements > 6.1. Compiler instructions > 6.1.5.
#pragma

6.1.5.2. best2_version

The pragma best2_version sets the minimum BEST2 compiler version required for the compilation.

The BEST2 major/minor version number has to be passed in the high/low byte, e.g. for BEST2-Version 7.0.x:

#pragma best2_version ( 0x0700 )

The pragma instruction must always be situated at the beginning of a line and never inside of comments, strings, tables and
constants.

In case of multiple and differing definitions of the BEST2 minimum version the greatest value will always be assumed within an
ECU description file. The interpretation is done at compilation time. A compilation with a lower BEST2-Compilerversion will
cause a compiler error.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements > 6.1. Compiler instructions > 6.1.5.
#pragma

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 58 of 161

6.1.5.3. runtime_version

The pragma runtime_version sets the minimum EDIABAS version at runtime.

The EDIABAS major/minor version number has to be passed in the high/low byte, e.g. for EDIABAS 6.10.x:

#pragma runtime_version ( 0x060a )

The pragma instruction must always be situated at the beginning of a line and never inside of comments, strings, tables and
constants.

In case of multiple and differing definitions of the EDIABAS minimum version the greatest value will always be assumed within
an ECU description file. The interpretation is done at runtime and may cause the EDIABAS error BIP-0009: BEST VERSION
ERROR.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements > 6.1. Compiler instructions > 6.1.5.
#pragma

6.1.5.4. best2_type

The pragma best2_type sets the BEST2 compiler type needed for compilation.

For setting the BEST2 compiler type for Win32 the pre-defined type identifier win32 must be given:

#pragma best2_type ( win32 )

The pragma instruction must always be situated at the beginning of a line and never inside of comments, strings, tables and
constants.

The interpretation is done at compilation time. A compilation with another BEST2 compiler type will cause a compiler error.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.2. Assignments and procedure calls

The calculation of an expression is the most commonly used statement; it takes the following form:

expression ;

Such statements are usually assignments or procedure calls.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.3. Blocks

A number of statements are assembled in a block. A block can always be specified instead of a single statement.

compound-statement:
{ {declaration} {statement} }
;

A block can contain declarations. If a name that was previously entered is declared then the previous declaration is replaced for
that area of the block and restored at the end of the block. This does not apply to array variables which apply globally for all blocks
as soon as they are defined.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.4. "if" statements

There are two types of if statement:

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 59 of 161

if (expression)
statement

and

if (expression)
statement
else
statement

In both cases the expression is evaluated first. If the result is not 0, then the first dependent statement is executed. In the second
case the second dependent statement is executed when and only when the result is 0. Else is assigned to the next if.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.5. "while" statement

The while statement has the following form:

while(expression)
statement

The dependent statement is repeated for as long as the value of the expression is not 0. The expression is evaluated each time
before the dependent statement is executed.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.6. "do" statement

The do statement has the following form:

Do
statement
while(expression);

The dependent statement is repeated for as long as the value of the expression is not 0. The expression is evaluated each time after
the dependent statement is executed. That means, the statement is executed at least once.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.7. "switch" statement

The switch statement ensures that the execution of the program is continued with one or more statements depending on the value
of an expression. The switch statement has the following form:

switch (expression)
statement;

The usual arithmetic conversions are used to evaluate the expression but the result must be an integer. The dependent statement is
typically a block. Each statement within the dependent statement can be preceded by any number of case labels:

case constant-integer:

Each of these constants can only occur once in a switch statement. A case label can also take the following form:

default :

To execute the switch statement the expression is evaluated and compared with all case constants. If a case constant is found that
has the same value as the expression, then the execution of the program is continued with the statement that follows the case label.
If no suitable case constant is found then execution is continued at a default case label if one exists.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 60 of 161

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.8. "break" statement

The

break;

statement aborts the nearest do-, while- or switch statement.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.9. "continue" statement

The

continue;

statement must be dependent on a do- or while- statement. It ensures that the execution of a program is continued from the point
where the repeat of the nearest statement is decided.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 6. Statements

6.10. "return" statement

If a job was called, the return statement within the job assures that exit is made from the job again. A string variable or string
constant can be specified along in the return statement. The runtime system assigns this value to the result JOBSTATUS in result
record 0. The return statement syntax is shown below:

return {constant-string | string-expression};

EDIABAS BEST Developer's Guide > BEST/2 Language Description

7. Global declarations
A BEST/2 description file consists of a header and a sequence of jobs:

program:
header
{ declaration }
job

More:

7.1. Header

7.2. Jobs

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 7. Global declarations

7.1. Header

The definition of a header is structured as follows:

header:
ecu : string;
origin : string;
revision : string;
author : string;
language : string;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 61 of 161

uses : string;
comment : string;

ecu specifies the exact designation of the ECU.

origin specifies the author and initial creation.

revision specifies the version as numeric pair separated by a dot.(e.g. 1.0). Both numbers has to be within the range 0-65535.

author specifies the author of the last change.

language specifies the language (optional).

uses specifies the basic description files (optional).

comment specifies a user comment, whereby several comment lines may be specified.

The header definitions can be queried in the BEST/2 jobs of the corresponding description file by means of PREDEFINED
MACROS.

EDIABAS BEST Developer's Guide > BEST/2 Language Description > 7. Global declarations

7.2. Jobs

The definition of a job takes the following form:

job:
job-header compound-statement

job-header:
job ( name : identifier ;
{ comment : string ; }
{[ argument : identifier ;
type : type-name | extra-type-name ;
{ comment : string ; } ]}
{[ result : identifier ;
type : type-name | extra-type-name ;
range : value |string ;
defrslt : value |string ;
{ comment : string ; } ]}
)

The job header defines the name of the job, the call parameters and possible results. The parameters are declarations with possible
initializers. These initializers are then evaluated as default results or call parameters. The declaration of default results is optional.

EDIABAS BEST Developer's Guide > BEST/2 Language Description

8. Areas of application
Global declarations apply to all jobs within the description file. These global declarations declare constants! These cannot be
modified!

Otherwise declarations only apply to the block in which they are described.

EDIABAS BEST Developer's Guide > BEST/2 Language Description

9. Runtime library
The runtime library provides functions for communication, string handling, error handling etc. The runtime library functions are
written in BEST/1 so cannot be created by the user himself.

They are described in the "BEST/2 FUNCTION PRIMER" manual.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 62 of 161

EDIABAS BEST Developer's Guide

BEST/2 Function Primer


More:

1. Revision history

2. Introduction

3. Overview

4. Clamp states

5. Library functions

LIST OF REFERENCES

EDIABAS BEST Developer's Guide > BEST/2 Function Primer

1. Revision history
Version 5b Revision history is new
New chapter 3 (chapter 3 renamed as chapter 4, etc.)
Version 5e New functions: rtoi, updateInfo, setProgressRange, incProgressRange
Version 5f New function: ascii2ascii
Version 6 New functions data_to_real, real_to_data, tab_suche_unsigned, ifinfoExt, realcomp,
AdjustKWP2000TesterPr-StartComm, GetKWP2000Block, GetKWP2000BlockIndex, linkPlugIn,
callPlugIn, callPlugInExt, set_communication_pars
Version 6a Description of GetKWP2000Block reworked, function GetKWP2000BlockIndex is dropped.
Version 6b In set_communication_pars concept KWP 2000* new.
Version 6c New function: tabsetext.
Version 6d Revised for EDIABAS V6.4.4
Version 7a Corrected get_error2.
New function enableClampHandling, Corrected waitex.
Changes in function waitex for EDIABAS V6.5.0.
New functions open_channel, close_channel, closeall_channel, switch_channel, send, receive for
EDIABAS V6.9.0.
Revision for EDIABAS V7.0.0.
New functions tabcolumns, tabrows.
Version 7b Generalization of various functions regarding EDIC interface.
Version 7c Revised for EDIABAS V7.2.0,
Enhanced description of set_communication_pars
Version 7d Revised for EDIABAS V7.2.0

EDIABAS BEST Developer's Guide > BEST/2 Function Primer

2. Introduction
More:

2.1. About the Runtime Library

2.2. Conventions

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 63 of 161

2.3. Special features, definitions, acronyms

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 2. Introduction

2.1. About the Runtime Library

The runtime library provides functions for control unit communication, string handling and error handling for use in BEST/2
description files. These functions provide

• access to the interface handler


• access to external data
• access to host system functions (e.g. time)
• and functions that are regularly needed for general programming tasks (e.g. strings).

This runtime library is very important because it provides facilities which the rudimentary BEST/2 language does not have.

All functions have been generated in BEST/1 to avoid performance losses!

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 2. Introduction

2.2. Conventions

The following typographical conventions are used in this manual:

Example Description
SAMPLE.B2V Upper case characters are used for filenames, registers and
operating system commands.
job, string, while Bold type is used for key words and operators of the
BEST/2 and BEST/1 languages and for API functions.

In syntax descriptions these words must be written as


shown.
Expression Italics designate placeholders for values to be entered by
the programmer; e.g., file names.
[option] Words enclosed in square brackets may be optionally
specified.
{ result | Curvy braces and vertical strokes characterize entries from
argument } which only one must be selected, except when in square
brackets.
[constant...] job... An ellipsis (three dots) which directly follows an
expression indicates that several expressions of the same
type can follow.
hallo="Test"; This syntax designates examples, user entries, program
outputs and error messages.
while() { A column or a row comprising three dots indicates that a
section of an example was intentionally omitted.
.

.}
[1] Reference to a document in References.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 2. Introduction

2.3. Special features, definitions, acronyms

The job INITIALISIERUNG (initialize) that is needed for correct operation has been omitted from all the examples in this

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 64 of 161

manual.

BEST/2 is the abstract name for the programming language for description files. However BEST2 refers to the compiler as a
command at operating system level (cf. "C" <-> "C-Compiler" <-> "CC").

The terms function, routine and command have equivalent status in this manual, and refer to self-contained function units in the
runtime library.

The term host refers to the computer and operating system on which the EDIABAS runtime system is started.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer

3. Overview
More:

3.1. Using the runtime library

3.2. Functions of the runtime library by categories

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview

3.1. Using the runtime library

More:

3.1.1. Calling library functions

3.1.2. Paths and filenames

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.1. Using the runtime library

3.1.1. Calling library functions

To use a library function in a BEST/2 description file we simply call it in a job with the required parameters. For example, we can
write the following job in a description file:

job ( name : SAMPLE; ... )

char buffer[];

...

getasciidate(buffer);

This job identifies the current date by means of the getasciidate function and writes it to the variable buffer.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.1. Using the runtime library

3.1.2. Paths and filenames

BEST2 uses B2RUNTIM.LIB as its default runtime library. Although this is expected to be in the same directory as the BEST/2
compiler, another library can be specified with the -L option when calling BEST2.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 65 of 161

BEST2 -L \test\dev\neulib.lib test.b2v

This command line calls the BEST/2 compiler which will compile the description file test.b2v in the current directory. It uses the
library NEULIB.LIB in the \TEST\DEV directory.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview

3.2. Functions of the runtime library by categories

BEST/2 library functions cover a range of job areas. If you know what the task is but do not know exactly which function you
need you can search for it in the following sections. The "library functions" section gives a complete function description including
syntax and examples.

Essentially, the following function categories are available:

• Communication functions
• Interface functions
• Result / parameter management
• String functions
• Conversion functions
• Data functions
• File functions
• Error handling
• Time handling
• Table handling
• Configuration
• Functions specific to the ECU
• Plugin functions

More:

3.2.1. Communication functions

3.2.2. Interface functions

3.2.3. Result and parameter management

3.2.4. String functions

3.2.5. Conversion functions

3.2.6. Real functions

3.2.7. Data functions

3.2.8. File functions

3.2.9. Sequence control

3.2.10. Error handling

3.2.11. Time handling

3.2.12. Table handling

3.2.13. Configuration

3.2.14. Control unit specific functions

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 66 of 161

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.1. Communication functions

Communication functions are used to communicate with the control unit. They provide the facility of the interface handler
contained in EDIABAS.

Function Purpose
Open_communication Opens communication with the interface
close_communication Closes communication with the interface
open_channel Opens an interface channel
close_channel Closes an interface channel
closeall_channel Closes all interface channels
switch_channel Switches the current interface channel
set_communication_pars Sets communication parameters
set_answer_length Sets the answer length of one or all telegrams
send_and_receive Sends and receives a telegram
recv_keybytes Gets the control unit key bytes
send_frequent Automatic repeat sending of a telegram
recv_frequent Receives a repeat telegram
stop_frequent Stops repeat sending
set_repeat_counter Sets the repeat counter for repeats in the event of an
error

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.2. Interface functions

Interface functions are used as an interface with the functions of the diagnostic bus interface. They provide the facility of the
interface handler contained in EDIABAS.

Function Purpose
get_battery_voltage Reads out the battery voltage
get_ignition_voltage Reads out the ignition voltage
set_program_voltage Sets the programming voltage
ifboot Resets the interface (warm start)
ifreset Resets the communication parameters
ifgetport Reads out a port
ifsetport Sets a port
ifloopt Tests the diagnostic lead
ifsireset Sets the SIA relay
ifrequeststate Reads out the interface state
iftype Reads out the interface type
ifvers Reads out the interface version
ifrawmode Transmits any desired characters to the interface
ifsend For debugging only
ifrecv For debugging only
ifinfo For debugging only
ifinfoExt For debugging only

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 67 of 161

3.2.3. Result and parameter management

These functions are used to manage results and parameters.

Function Purpose
new_set_of_results Signals a new result set
parcount Identifies the number of parameters
set_variable_result Produces a result with variable names
var_result_data Produces a data result with variable names
var_result_long Produces a "long" result with variable names
var_result_real Produces a "real" result with variable names
var_result_string Produces a "string" result with variable names
updateInfo Produces a "string" result as the job is being
processed
setProgressRange Sets a range for the progress counter
incProgressPos Increases the current position of the progress counter

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.4. String functions

The string functions are used to manage and process C-compatible strings. These strings must end with the zero character ('\0').

Function Purpose
strcat Catenates strings
strcut Shortens strings
strcmp Compares strings
strcpy Copies strings
strncpy Copies a string with length specification
strlen Identifies the string length
strerase Erases a part string
strinsert Inserts a part string
get_token Searches for a token
strrevers Reverses a string

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.5. Conversion functions

The conversion functions are used to convert data from an integer to a string form.

Function Purpose
ascii2hex Converts a string to a binary array
ascii2ascii converts characters to characters of a different code
page
atoi Converts a string to an integer
atoy Converts a string to a binary array
bcd2ascii Converts a BCD chain to a BCD string
hex2ascii Converts a hex chain to a hex string
itoad Converts an integer to a decimal string
uitoad Converts an unsigned integer to a decimal string
itoax Converts an integer to a hexadecimal string

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 68 of 161

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.6. Real functions

The real functions are used to process real numbers.

Function Purpose
itor Converts an integer to a real number
ator Converts a string to a real number
realcomp Compares two real numbers
realadd Adds two real numbers
realsub Subtracts two real numbers
realmul Multiplies two real numbers
realdiv Divides two real numbers
realresult Generates a real result
rtoa Converts a real number to a string
rtoi Converts a real number into an integer
data_to_real Converts data bytes into a real number
real_to_data Converts a real number into data bytes

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.7. Data functions

Data functions move and set data. Unlike strings this data does not end on a zero.

Function Purpose
datacat Appends data bytes to a buffer
dataclear Clears a buffer
datacmp Compare bytes of two buffers
datacopy Copies bytes from one buffer to another
dataerase Erase data bytes from a buffer
datainsert Inserts bytes into a buffer
datalen Identifies the length of a buffer
datarevers Reverses data in a buffer
dataset Sets bytes in a buffer
shdataget Read (get) the global data memory
shdataset Write (set) the global data memory

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.8. File functions

File functions provide read access to files in the host system.

Function Purpose
fopen Opens a file
fclose Closes a file

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 69 of 161

fread Reads a character from a file


freadln Reads a line from a file
fseek Sets the read position in a file (byte by byte)
fseekln Sets the read position in a file (line by line)
ftell Identifies the read position in a file (byte by byte)
ftelln Identifies the read position in a file (line by line)

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.9. Sequence control

This function enables access in the job sequence control; i.e., when and in which order standard jobs are called.

Function Purpose
doNewInit Forces the job INITIALISIERUNG before the next
job call

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.10. Error handling

The description file can handle error messages with these functions.

Function Purpose
clear_error Clears the error flag
get_error Identifies the error number
get_error2 Identifies the error number
make_error Issue an error
generateRunError Issues error “RUN-00XX”
set_trap_mask Sets the error trap mask
get_trap_mask Reads out the error trap mask
userbreak Produce the error message

"BIP-0008: BEST BREAK"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.11. Time handling

The time handling functions make it possible to access the current time and date, among other options.

Function Purpose
gettime Gets the current time
getdate Gets the current date
getasciitime Gets the current time as an ASCIIZ string
getasciidate Gets current date as an ASCIIZ string
gettickcount Gets tick counter value of milliseconds
wait Waits n seconds
waitex Waits n milliseconds

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 70 of 161

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.12. Table handling

These functions are used to evaluate the constant tables defined in BEST/2.

Function Purpose
tabset Initializes table handling
tabsetext Initializes table handling of an ECU description file
(SGBD)
tabseek Searches a string in the current table
tab_suche_index Searches an integer string in the current table
tab_suche_unsigned Searches an unsigned integer string in the current
table
tabline Jumps to the specified line in the table
tabget Reads out values from the current table line
tab2fix Reads out values from the current table line and
converts to an integer
tabcolumns Gets the column count of the current table
tabrows Gets the row count of the current table
bittest Special function for identifying bit results
bytetest Special function for identifying byte results

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.13. Configuration

These functions are used to set and read the EDIABAS configuration.

Function Purpose
enableIfhTrace Enable/disable the IFH-Trace
enableClampHandling Enable/disable the automatic clamp monitoring
enableIgnitionHandling Enable/disable the ignition monitoring
enableUbattHandling Enable/disable battery monitoring
getCfgInt Read (get) a configuration setting as an integer
getCfgString Read (get) a configuration setting as a string
isDebugLevel Interrogation of the configuration element
"BipDebugLevel"
isSimulation Interrogation of the configuration element
"Simulation"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 3. Overview > 3.2. Functions of the runtime library by
categories

3.2.14. Control unit specific functions

These functions are used to evaluate control unit answer telegrams.

Function Purpose
AdjustKWP2000TesterPr- Adapts the TesterPresent and StartCommunication
StartComm telegrams using the ECU address in the parameters
GetKWP2000Block Reads out a block from the response telegram of a
control unit with KWP 2000
getETXblock Reads out a block from the answer telegram of a

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 71 of 161

control unit

EDIABAS BEST Developer's Guide > BEST/2 Function Primer

4. Clamp states
All functions of the Interface Handler which communicate with the interface are listed below. Specification is made for each
function as to which error messages are generated based on the interface terminal states and which response is made to the error
message. If the UBattHandling or IgnitionHandling is disabled in configuration file EDIABAS.INI, neither the error messages
UBATT ON/OFF ERROR (or IGNITION ON/OFF ERROR) are generated due set history bits nor is the communication aborted
(and the terminal states reset) as response to this.
The system results IGNITIONCURRENT; UBATTCURRENT; IGNITIONHISTORY; UBATTHISTORY are only assigned the
values (0,1) for the current state of the terminal states when at least one of the following functions is executed in the job (except
the function ifrawmode). If none of the following functions are executed in the job, the system results above are always labelled
as undefined (-1).

Function Error messages Response


set_communication_pars WRONG UBATT Only in case of error:
UBATT ON/OFF ERROR
IGNITION ON/OFF ERROR Abort active communication
with the ECU and reset the
terminal states
send_and_receive WRONG UBATT Only in case of error:
UBATT ON/OFF ERROR
IGNITION ON/OFF ERROR Abort active communication
with the ECU and reset the
terminal states
recv_keybytes WRONG UBATT Only in case of error:
UBATT ON/OFF ERROR
IGNITION ON/OFF ERROR Abort the active
communication with the ECU
and reset the terminal states
send_frequent WRONG UBATT Only in case of error:
UBATT ON/OFF ERROR
IGNITION ON/OFF ERROR Abort the active
communication with the ECU
and reset the terminal states
recv_frequent WRONG UBATT Only in case of error:
UBATT ON/OFF ERROR
IGNITION ON/OFF ERROR Abort the active
communication with the ECU
and reset the terminal states
stop_frequent None None
get_battery_voltage None None
get_ignition_voltage WRONG UBATT None
set_program_voltage None None
ifboot None Always:

The active communication


with the ECU is always
aborted, and the terminal
states are always reset.
None
ifreset Always:

The active communication


with the ECU is always
aborted, and the terminal
states are always reset.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 72 of 161

ifgetport None None


None
ifsetport None
ifloopt None None
None
ifsireset None
ifrequeststate None None
ifvers None None
ifrawmode None None

EDIABAS BEST Developer's Guide > BEST/2 Function Primer

5. Library functions
More:

5.1. Using the function primer

AdjustKWP2000TesterPrStartComm

ascii2ascii

ascii2hex

atoi

ator

atoy

bcd2ascii

bittest

bytetest

clear_error

close_channel

closeall_channel

close_communication

data_to_real

datacat

dataclear

datacmp

datacopy

dataerase

datainsert

datalen

datarevers

dataset

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 73 of 161

doNewInit

enableIfhTrace

enableClampHandling

enableIgnitionHandling

enableUBattHandling

fclose

fopen

fread

freadln

fseek

fseekln

ftell

ftellln

get_battery_voltage

get_error

get_error2

get_ignition_voltage

get_token

get_trap_mask

generateRunError

getasciidate

getasciitime

getCfgInt

getCfgString

getdate

getETXblock

GetKWP2000Block

gettickcount

gettime

hex2ascii

ifboot

ifgetport

ifinfo

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 74 of 161

ifinfoExt

ifloopt

ifrawmode

ifrecv

ifrequeststate

ifreset

ifsend

ifsetport

ifsireset

iftype

ifvers

incProgressPos

isDebugLevel

isSimulation

itoad

itoax

itor

make_error

new_set_of_results

open_channel

open_communication

parcount

real_to_data

realadd

realcomp

realdiv

realmul

realresult

realsub

receive

recv_frequent

recv_keybytes

rtoa

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 75 of 161

rtoi

send

send_and_receive

send_frequent

set_answer_length

set_communication_pars

set_program_voltage

set_repeat_counter

set_trap_mask

set_variable_result

setProgressRange

shdataget

shdataset

stop_frequent

strcat

strcmp

strcpy

strcut

strerase

strinsert

strlen

strncpy

strrevers

switch_channel

tab2fix

tab_suche_index

tab_suche_unsigned

tabget

tabcolumns

tabline

tabrows

tabseek

tabset

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 76 of 161

tabsetext

uitoad

updateInfo

userbreak

var_result_data

var_result_long

var_result_real

var_result_string

wait

waitex

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

5.1. Using the function primer

This section describes the BEST/2 runtime library functions in alphabetical order. Related functions are described together in
many cases.

Each function description comprises the following sections:

• Summary Summarizes what the function does, illustrates its syntax and briefly describes its arguments.
• Remarks A detailed description of the function and its use.
• Return value Describes the value that is returned by the function.
• See also Refers the reader to related functions.
• Example Shows an extract from a job to explain the function's use.
• Result The results or effects of the example.

In the description of the arguments, (V) means that a variable must be specified, (C) means that a constant must be specified.

This section lists all the functions of the BEST/2 runtime library in alphabetical order.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

AdjustKWP2000TesterPrStartComm

Summary

void AdjustKWP2000TesterPrStartComm(char params[])

params KWP 2000 parameters in the raw format for EDIC API (V)

Remarks This function enters the control unit address in position 5 of the TesterPresent and StartCommunication
telegram parameters and recalculates the checksums in these telegrams.

Return value -

See also -

Example {

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 77 of 161

char parameter[];

parameter = kwp_2000_parameter;

parameter[5] = ecuAddress;

AdjustKWP2000TesterPrStartComm(parameter);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ascii2ascii

Summary Converts all text characters into another character set

void ascii2ascii(char codepage[],char text[])

codepage Character set

text String buffer(V)

Remarks This function converts all characters in the string into characters with another ASCII code. Characters
are converted according to the passed code page.

Return value -

See also -

Example

unsigned char codepage[] =

// 0 1 2 3 4 5 6 7 8 9 A B C D E F

/*0*/ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,

/*1*/ 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,

/*2*/ 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,

/*3*/ 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

/*4*/ 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,

/*5*/ 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,

/*6*/ 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,

/*7*/ 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0xE4,0xF6,0xFC,0xDF,0x7F,

/*8*/ 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,

/*9*/ 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,

/*A*/
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,

/*B*/
0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 78 of 161

/*C*/
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,

/*D*/
0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,

/*E*/
0xE0,0xE4,0xDF,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xF6,

/*F*/ 0xF0,0xF1,0xF2,0xF3,0xF4,0xFC,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF

};

unsigned char text[] = {0x7B,0xE1,0x7C,0xEF,0x7D,0xF5,0x7E,0xE2};

...

ascii2ascii(codepage,text);

...

Result text = {0xE4,0xE4,0xF6,0xF6,0xFC,0xFC,0xDF,0xDF} //ääööüüßß

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ascii2hex

Summary Converts a hex string into a sequence of bytes

long ascii2hex(char destin[],char source[],int pos)

destin Destination buffer(V)

source String buffer

pos Position in the Destination buffer

Remarks Converts a zero-terminated string source into a sequence of bytes and inserts these in destin beginning at
byte position pos. In this process, all characters of the string buffer are converted. Abortion occurs in
the case of invalid characters or in case of an uneven number of characters. In the case of an error,
destin contains all converted bytes up to the erroneous character.

Return value 0: Source contains invalid characters


1: Source contains only valid characters

See also atoi, atoy, bcd2ascii, itoad, itoax

Example {

char source[] = "00FF";

char destin[] = { 0x12, 0x34, 0x56, 0x78 };

ascii2hex(destin,source,1};

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 79 of 161

...

Result destin = { 0x12, 0x00, 0xFF, 0x78 }

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

atoi

Summary Converts a string to a value

long atoi(char number[]);

number The string to be converted

Remarks The atoi function converts a string into an integer. If the string begins with the characters "0x" or "0X"
then it is interpreted as a hexadecimal number. If the string begins with the characters "0y" or "0Y"
then it is interpreted as a binary number. In all other cases the string is interpreted as a decimal
number. Conversion is aborted at the first character that does not match the number format.

Return value The converted value (2^31 maximum).

See also atoy, itoad, itoax, bcd2ascii, hex2ascii, ascii2hex

Example {

long hexzahl;

long binzahl;

long dezzahl;

hexzahl=atoi("0x77");

binzahl=atoi("0y01110110");

dezzahl=atoi("014");

...

Result hexzahl = 0x77 = 119

binzahl = 0x76 = 118

dezzahl= 0x0e = 14

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ator

Summary Converts a string to a real number

void ator(real destin, char value[]);

destin Real number to accept the conversion result


(maximum double = 1.7E ± 308 (15 digits))

value The string to be converted

Remarks The ator function converts a string into an integer. The string is interpreted as a real number. It can have

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 80 of 161

the following format:

[{sign}][digits][{.|,}digits][{d|D|e|E}[sign]digits]

sign is either '+' or '-'.

digits are one or more digits.

Conversion is aborted at the first character that does not match the number format.

Return value -

See also itoi, realadd, realsub, realmul, realdiv, rtoa

Example {

real realzahl;

ator(realzahl,"1.22e01");

...

Result realzahl = 12.2

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

atoy

Summary Converts a string into a binary array

long atoy(char binary[],char ascii[]);

binary Buffer for binary data

ascii The string to be converted

Remarks The atoy function converts a string into a binary array. The ASCII string uses the format: [AA] { },{ }
[AB] { },{ } … Conversion is aborted at the first character which does not match the format.

Return value The number of binary data in binary.

See also atoi, itoad, itoax, bcd2ascii, hex2ascii, ascii2hex

Example {

char ascii[];

char binary[];

ascii="aa,bb,cc, ,01"

atoy(binary,ascii);

Result binary = { 0xAA, 0xBB, 0xCC, 0x00, 0x01 }

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

bcd2ascii

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 81 of 161

Summary Converts a chain of characters to a BCD string

void bcd2ascii(char destin[],char source[],int index, int count)

destin String buffer(V)

source Source buffer

index Position in source buffer

count Number of bytes to be converted

Remarks Converts a chain of bytes (two nibbles) from the source buffer source, starting from the byte position
index, into a zero-terminated BCD string destin. count nibbles are converted from the source buffer.
An '*' stands in the destination string for nibbles with a value greater than hexadecimal 9 (A..F).

Return value -

See also atoi, atoy, itoad, itoax, hex2ascii, ascii2hex

Example {

char source[]={ 0x12, 0x34, 0xFF, 0x78, 0x90 };

char destin[];

bcd2ascii(destin,source,1,3};

...

Result destin = "34**78"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

bittest

Summary Identifies bit results via a table

long bittest(char name[],char source[],long value)

name Result name

source Buffer to be analyzed

value Test result

Remarks You must have a table with the columns NAME, BYTE, MASK, VALUE. Table processing must first
have been set to this table using the tabset function. The BYTE column indicates which byte in
source is to be looked at. The appropriate bits (the bits to be looked at) must be masked in the
MASK column. In the VALUE column enter the value which the bits must have to make the status
NAME true. The result value is TRUE (1) when all the bits set in MASK have the value specified in
VALUE, otherwise it is FALSE (0).

Return value TRUE (1) when the result name was found in the table, otherwise FALSE (0)

See also bytetest

Example table bits[4][]={

{ "NAME", "BYTE" , "MASK" , "VALUE" },

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 82 of 161

{ "XEIN", "0", , "0x07" , "0x06" },

{ "XAUS", "0", , "0x07" , "0x01" } };

int xeinvalue; int xausvalue;

char buffer[];

buffer[0]=0x06;

tabset("bits");

bittest("XEIN",buffer,xeinvalue);

bittest("XAUS",buffer,xausvalue);

Result xeinvalue = 1

xausvalue = 0

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

bytetest

Summary Identifies byte results via a table

long bytetest(char name[],char source[],long value, long divs)

name Result name

source Buffer to be analyzed

value Test result

divs Divider

Remarks You must have a table with the columns NAME, BYTE, MIN, MAX, MINDEF, MAXDEF, A, B,
DIV. Table processing must first have been set to this table using the tabset function. The BYTE
column indicates which byte in source is to be looked at. The MIN und MAX columns indicate the
lower and upper limits of the byte in source. If the limits are breached then the value in the MINDEF
or MAXDEF columns is returned. If the value of the byte is within the defined limits then the
returned value is calculated according to the formula A*x + B. The divider in the DIV column is
returned in divs. It indicates the value by which the result has to be divided in order to get a correct
result.

Return value 0 = in valid range

1 = over range

-1 = under range

See also bittest


Example table bytes[3][]={

{ "NAME","BYTE","MIN","MAX","MINDEF","MAXDEF","A","B","DIV" },

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 83 of 161

{ "TEMP","0", "07" ,"254","-40", "120", "-4","8","1" } };

...

int tempvalue; int tempdivs; char buffer[]; buffer[0]=0x06;

tabset("bytes");

bytetest("TEMP",buffer,tempvalue,tempdivs);

Result tempvalue = -40

tempdivs = 1

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

clear_error

Summary Clears the error flag

void clear_error()

Remarks The clear_error function clears the error flag. This function must be called when an error has been
masked. It clears the entry in EDIABAS that an error had occurred.

Return value -

See also -

Example set_trap_mask(0x60000);

ifreset();

set_trap_mask(0x00);

clear_error();

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

close_channel

Summary Closes the current communication channel to the interface driver

void close_channel ()

Remarks The close_channel function closes the current communication channel formerly opened by
open_channel or selected by switch_channel. The default interface channel becomes the current
interface channel. If the current interface channel is the default interface channel it will not be closed
by close_channel.

Return value -

See also closeall_channel, open_channel

Example -

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 84 of 161

close_communication

Summary Closes the communication channel to the interface

void close_communication()

Remarks The close_communication function resets the interface’s communication parameters and closes the
driver. Interface channels, which are still open, will automatically be closed as in the function
closeall_channel. The default Interface channel will be closed as well. All the communication and
interface functions used after this function are answered with the error message IFH_0019 (except
open_communication).

Return value -

See also closeall_channel, open_communication

Example -

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

closeall_channel

Summary Closes all open communication channels to the interface driver

void closeall_channel ()

Remarks The closeall_channel function closes all interface channels formerly opened by open_channel and not
closed by close_channel. The default interface channel stays open and becomes the current interface
channel.

Return value -

See also close_channel, open_channel

Example -

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

data_to_real

Summary Converts data bytes into a real number

void data_to_real(real destin, char source[], long pos, long double, long byteorder);

destin Real number for recording the conversion result (V)

source Source buffer (V)

pos Position of the 1st data byte in the source buffer

double Real number precision:

0 = single-precision (4 data bytes IEEE)

<> 0 = double-precision (8 data bytes IEEE)

byteorder Memory format in the source buffer:

0 = Little Endian (Intel)

<> 0 = Big Endian (Motorola)

Remarks The data_to_real function converts 4 (double=0) or 8 data bytes (double=1) of the source buffer source

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 85 of 161

into the real number destin as of the indicated buffer position.

Return value -

See also real_to_data

Example {

unsigned char buffer[];

real realzahl;

buffer = { 0x66, 0xe6, 0xf6, 0x42 };

data_to_real(realzahl,buffer,0,0,0);

...

Result realzahl = 123.45

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

datacat

Summary Appends data bytes to a buffer

void datacat(unsigned char buffer[], unsigned char bytes[])

buffer Buffer to which the data bytes are appended (V)

bytes Data bytes which are appended

Remarks This function appends data bytes to a buffer.

Return value -

See also dataclear, datacopy, datacmp, dataerase, datainsert, datalen, datarevers, dataset

Example unsigned char buffer1[];

unsigned char buffer2[];

buffer1 = {0x01, 0x02, 0x03};

buffer2 = {0x04, 0x05, 0x06};

datacat(buffer1, buffer2);

Result buffer1 = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

dataclear

Summary Clears a buffer

void dataclear(unsigned char buffer[])

buffer Data buffer (V)

Remarks This function clears a data buffer.

Return value -

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 86 of 161

See also datacat, datacopy, datacmp, dataerase, datainsert, datalen, datarevers, dataset

Example unsigned char buffer[];

buffer = {0x01, 0x02, 0x03};

dataclear(buffer);

Result buffer = {};

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

datacmp

Summary Compares two data buffers

long datacmp(char d1[],char d2[])

d1 Data buffer 1 (V)

d2 Data buffer 2

Remarks The function compares the two data buffers d1 and d2. If the two buffer have the same length and
contain identical characters, they are considered equal, otherwise unequal.

Return value 0 if both data buffers are equal, <> 0 if not equal.

See also datacat, dataclear, datacopy, dataerase, datainsert, datalen, datarevers

Example {

int x; int y; int z;

unsigned char d1[];

d1 = {1,2,3}

x=datacmp(d1,{1,2,3});

y=datacmp(d1,{1,2,3,4});

z=datacmp(d1,{1,2,4});

Result x=0, y=1, z=1

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

datacopy

Summary Copies data from a source buffer to a target buffer

void datacopy (char destin[],char source[],long pos,long count)

destin Target buffer (V)

source Source buffer

pos Start position in source buffer

count Number of characters to be copied

Remarks The datacopy function copies count characters from position pos from the source buffer source to the
target buffer destin. Up to 1024 characters can be copied. The maximum number of characters, that

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 87 of 161

can be copied, depends on the string register size of the currently loaded ECU description file, i.e. string register size – 1 character.

Value ranges: 0 <= pos < max. buffer size

0 <= count <= max. buffer size

pos+count < max. buffer size

Up to EDIABAS V6.x.x: max. buffer size = 1024 characters

From EDIABAS V7.0.0: max. buffer size = 65536 characters (depends on string register size of the ECU
description file)

Exceeding the value range causes runtime error BIP_0001.

Return value -

See also datacat, dataclear, datacmp, dataerase, datainsert, datalen, datarevers, dataset

Example {

char source[]= { 0x12, 0x34, 0x56, 0x78, 0x90 };

char destin[];

datacopy(destin,source,2,3);

...

Result destin={0x56,0x78,0x90}

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

dataerase

Summary Erase data from a buffer

void dataerase (char buffer[],int pos,int count)

buffer Buffer to be modified (V)

pos Position at which erasing is to begin

count Number of characters to be erased (C)

Remarks The function dataerase erases an arbitrary number of characters from a buffer. The remaining parts of
the buffer are combined. Count characters will be erased beginning at position pos. The process is
aborted when the end-of-buffer is reached. Only the buffer to pos then remains as the rest.

Return value -

See also datacat, dataclear, datacopy, datacmp, datainsert, datalen, datarevers, dataset

Example {

char buffer[] = { 0x12,0x34,0xFF,0x56,0x78 };

dataerase(buffer,1,2);

...

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 88 of 161

Result buffer={ 0x12,0x56,0x78 }

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

datainsert

Summary Inserts data in a buffer

void datainsert (char destin[],char source[],int pos)

destin Buffer to be modified (V)

source Buffer to be inserted

pos Position to be inserted to

Remarks The function datainsert inserts the buffer source into the buffer destin. Insertion is done beginning with
position pos. If the buffer destin becomes longer than a string register, i.e., string register size – 1
character, this causes a runtime error BIP_0001.

Return value -

See also datacat, dataclear, datacopy, datacmp, dataerase, datalen, datarevers, dataset

Example {

char source[] = { 0xF0,0xF1 };

char destin[] = { 0x12,0x34,0x56,0x78 };

datainsert(destin,source,3);

...

Result destin={ 0x12,0x34,0x56,0xF0,0xF1,0x78 }

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

datalen

Summary Identifies the buffer length

long datalen(unsigned char buffer[])

buffer Buffer whose length is to be identified

Remarks This function identifies the length (number of characters) of a data buffer.

Return value Number of characters in the buffer.

See also datacat, dataclear, datacopy, datacmp, dataerase, datainsert, datarevers, dataset

Example long length;

unsigned char buffer[];

buffer = {0x01, 0x02, 0x03, 0x04};

length = datalen(buffer);

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 89 of 161

Result length = 4

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

datarevers

Summary Reverses a data buffer

void datarevers(unsigned char buffer[])

buffer Buffer whose data bytes are to be reversed (V)

Remarks This function reverses the sequence of data bytes in a buffer.

Return value -

See also datacat, dataclear, datacopy, datacmp, dataerase, datainsert, datalen, dataset

Example unsigned char buffer[];

buffer = {0x01, 0x02, 0x03, 0x04};

datarevers(buffer);

Result buffer = {0x04, 0x03, 0x02, 0x01}

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

dataset

Summary Sets the bytes in a buffer to a defined value

void dataset(char destin[],char data,long count)

destin Target buffer (V)

data Character to be set

count Number of bytes to be set

Remarks This function sets the number of bytes specified by count to the value data in the target buffer destin.

Values ranges: 0 <= count < max. buffer size

Up to EDIABAS V6.x.x: max. buffer size = 1024 characters

From EDIABAS V7.0.0: max. buffer size = 65536 characters (depends on string register size of the ECU
description file)

Exceeding the value range causes runtime error BIP_0001.

Return value -

See also datacat, dataclear, datacopy, datacmp, dataerase, datainsert, datalen, datarevers

Example {

char buffer[]={ 0x12, 0x34, 0x56, 0x78, 0x90 };

dataset(buffer,0x41,2};

...

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 90 of 161

Result buffer={ 0x41, 0x41, 0x56, 0x78, 0x90 }

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

doNewInit

Summary Forces the job INITIALISIERUNG before the next job call.

void doNewInit()

Remarks This function forces the standard job INITIALISIERUNG to be automatically called before executing
the next job.

Return value -

See also -

Example {

doNewInit();

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

enableClampHandling

Summary Enable/disable automatic clamp monitoring

void enableClampHandling(long enable)

enable 0 = disable / <>0 = enable

Remarks This function either enables or disables the automatic monitoring of clamps 15/30. If monitoring is
enabled, the clamps 15/30 will be monitored at every interface access. The current value can be read
with "getCfgInt("ClampHandling"). After the ECU description file is changed, this setting is reset
again to the application default.

The configuration of the automatic clamp state monitoring must be supported by the interface. With
interfaces not supporting automatic clamp state monitoring the configuration element
ClampHandling will be ignored (i.e. in that case the function has no effect).

Return value -

See also enableIfhTrace, enableUbattHandling, getCfgInt, getCfgString, IsDebugLevel, IsSimulation

Example unsigned char buffer[];

enableClampHandling(0);

iftype(buffer);

enableClampHandling(1);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

enableIfhTrace

Summary Enable/disable the IFH-Trace

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 91 of 161

void enableIfhTrace(long enable)

enable 0 = disable / <>0 = enable

Remarks This function either enables or disables the IFH-Trace. After changing the ECU description file, this
setting is reset again to the application default.

Return value -

See also enableIgnitionHandling, enableUbattHandling, getCfgInt, getCfgString, IsDebugLevel,


IsSimulation

Example unsigned char buffer[];

enableIfhTrace(1);

iftype(buffer);

enableIfhTrace(0);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

enableIgnitionHandling

Summary Enable/disable ignition monitoring

void enableIgnitionHandling(long enable)

enable 0 = disable / <>0 = enable

Remarks This function either enables or disables the ignition monitoring. If monitoring is enabled, the error "IFH-
0016: IGNITION ON/OFF ERROR" is issued after disabling the ignition at the next interface
communication. The current value can be read with "getCfgInt("IgnitionHandling"). After the ECU
description file is changed, this setting is reset again to the application default.

Return value -

See also enableIfhTrace, enableUbattHandling, getCfgInt, getCfgString, IsDebugLevel, IsSimulation

Example unsigned char buffer[];

enableIgnitionHandling(0);

iftype(buffer);

enableIgnitionHandling(1);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

enableUBattHandling

Summary Enable/disable battery monitoring

void enableUBattHandling(long enable)

enable 0 = disable / <>0 = enable

Remarks This function either enables or disables the battery monitoring. If monitoring is enabled, the error "IFH-

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 92 of 161

0015: UBATT ON/OFF ERROR" is issued after disabling the battery voltage at the next interface communication. The current
value can be read with "getCfgInt("UBattHandling");". After the ECU description file is changed,
this setting is reset again to the application default.

Return value -

See also enableIfhTrace, enableIgnitionHandling, getCfgInt, getCfgString, IsDebugLevel, IsSimulation

Example unsigned char buffer[];

enableUBattHandling(0);

iftype(buffer);

enableUBattHandling(1);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

fclose

Summary Closes a file

void fclose (int handle)

handle Reference to a file opened by fopen (V)

Remarks The fclose function closes a file opened with fopen. No further file operations are possible after fclose.
Error BIP_0006 is activated in the event of an error (failure by EDIABAS host file system) [4].

Return value -

See also fopen, fread, freadln, fseek, fseekln, ftell, ftellln

Example {

int handle;

handle=fopen("/test/div/test.dat");

...

/* file operations */

...

fclose(handle);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

fopen

Summary Opens a text file

int fopen(char filename[])

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 93 of 161

filename Name of file to be opened

Remarks Opens the specified text file for reading. Up to 5 files can be opened at the same time. A so-called
filehandle is returned if the open is successful. The filehandle refers to that and only that opened file
and must be specified with all other file operations. When opened, the file's read pointer is moved to
the first character of the file. Error BIP_0006 is activated in the event of an error (failure by
EDIABAS host file system) [4].

Return value Filehandle

See also fclose, fread, freadln, fseek, fseekln, ftell, ftellln

Example {

int handle;

handle=fopen("/usr2/test/test.dat");

...

/* Access to the file via the file handle */

...

fclose(handle);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

fread

Summary Reads a single character from a file

long fread(int handle)

handle Reference to a file opened with fopen (V)

Remarks The fread function reads a character from a file. It reads from the current position of the read pointer.
The read pointer is incremented by 1 after the character is read. If an attempt was made to read at the
end of a file, then -1 is returned as the value of the character and the read pointer is no longer
incremented.

Return value The read character (0x00 - 0xff) or -1.

See also fclose, fopen, freadln, fseek, fseekln, ftell, ftellln

Example {

int handle;

long c; long i=0;

handle=fopen("test.dat");

while((c=fread(handle)) != -1 )

i++;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 94 of 161

Result i = number of read characters

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

freadln

Summary Reads a line from a file

long freadln(char line[],int handle)

line Buffer to accept the read line (V)

handle Reference to a file opened with fopen (V).

Remarks The freadln function reads a line from a file. A line is all characters up to an LF character. It reads from
the current position of the read pointer. After the line is read the read pointer is incremented until it
points to the beginning of the next line. The function returns the length of the line. If an attempt was
made to read at the end of a file, then -1 is returned as the length of the line and the read pointer is no
longer incremented. Error BIP_0006 is activated in the event of an error (failure by EDIABAS host
file system) [4].

Up to 1023 characters per line are allowed!

Return value The number of characters in the read line.

See also fclose, fopen, fread, fseek, fseekln, ftell, ftellln

Example {

int handle;

char line[]; long i=0;

handle=fopen("Example.txt");

while(freadln(line,handle) != -1 )

i++;

Result i = number of read lines

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

fseek

Summary Sets the position of the read pointer byte by byte

long fseek(long pos,int handle)

pos New position of the read pointer in the file

handle Reference to a file opened with fopen (V)

Remarks The fseek function positions the read pointer on a certain byte in a file. It is always positioned right at
the start of the file. The position of the first character is 0. Error BIP_0006 is activated in the event of
an error (failure by EDIABAS host file system) [4].

Return value The new position in the file.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 95 of 161

See also fclose, fopen, fread, freadln, fseekln, ftell, ftellln

Example {

int handle;

int c;

handle=fopen("Filename");

c=fread(handle);

fseek(0,handle);

c=fread(handle);

...

Result The first character in the file is read twice.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

fseekln

Summary Sets the position of the read pointer line by line

long fseekln(long pos,int handle)

pos New line position of the read pointer in the file

handle Reference to a file opened with fopen (V)

Remarks The fseekln function positions the read pointer on a certain line in a file. It is always positioned right at
the start of the file. The number of the first line is 0. Error BIP_0006 is activated in the event of an
error (failure by EDIABAS host file system) [4].

Return value The new line position in the file.

See also fclose, fopen, fread, freadln, fseek, ftell, ftellln

Example {

int handle;

char line[];

handle=fopen("test.txt");

fseekln(10,handle);

freadln(line,handle);

...

Result The 11th line of the file is read.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 96 of 161

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ftell

Summary Identifies the position of the read pointer

long ftell(int handle)

handle Reference to a file opened with fopen (V)

Remarks The ftell function identifies the current position of the read pointer in bytes from the start of a file. The
position of the first character is 0. Error BIP_0006 is activated in the event of an error (failure by
EDIABAS host file system) [4].

Return value The current position in the file.

See also fclose, fopen, fread, freadln, fseek, fseekln, ftellln

Example {

int handle;

long c;

handle=fopen("Filename");

c=fread(handle);

c=fread(handle);

c=ftell(handle);

Result c=2, 2 bytes were read.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ftellln

Summary Identifies the position of the read pointer in lines

long ftellln(int handle)

handle Reference to a file opened with fopen (V)

Remarks The ftellln function identifies the current position of the read pointer in lines from the start of a file. The
position of the first line is 0. Error BIP_0006 is activated in the event of an error (failure by
EDIABAS host file system) [4].

Return value The current position in the file.

See also fclose, fopen, fread, freadln, fseek, fseekln, ftell

Example {

int handle; int c;

char line[];

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 97 of 161

handle=fopen("xxx.tst");

freadln(line,handle);

freadln(line,handle);

c=ftellln(handle);

Result c=2, 2 lines were read.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

generateRunError

Summary Generates a runtime error „RUN-00XX“

void generateRunError(long errornumber);

errornumber number of error that has to be issued

Remarks This function generates a runtime error „RUN-00XX“ determined by errornumber

Return value -

See also make_error, get_error

Example {

...

generateRunError(250); // generate „RUN-0000“

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

get_battery_voltage

Summary Reads out the battery voltage

long get_battery_voltage()

Remarks This function returns the voltage at clamp 30 (battery voltage) in millivolts.

Return value Voltage in millivolts

See also get_ignition_voltage

Example long voltage;

voltage = get_battery_voltage();

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

get_error

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 98 of 161

(get_trap_mask, set_trap_mask)
Summary Checks whether an error has occurred

long get_error(long nr)

nr Number of error to be checked

Remarks Normally, EDIABAS reacts to an error by automatically aborting the currently active job, and only an
error message is returned. In some cases, however, e.g. in case of control unit identification, you may
want to analyze certain errors in the control unit description file, and certain bits (trap bits) can be set
in the trap mask register for this purpose (see set_trap_mask). Each trap bit is assigned an error
message. When this bit is set, the job is not automatically aborted when an error occurs, but a trap bit
and the trap number are set in the condition code register. The get_error function now checks
whether the trap bit is set and whether the specified error agrees with the trap number. If it does,
get_error returns TRUE (!0); if not, it returns FALSE (0). If no = 0, it only checks whether the trap
bit is set. If it is, there is an error, and TRUE is returned. See set_trap_mask for a list of possible
trap numbers.

Return value TRUE if there was an error; FALSE, if not.

See also get_trap_mask, set_trap_mask, make_error

Example set_trap_mask(0xffffffff); //trap all errors

send_and_receive(destin,source);

if(get_error(0))

job_status="ERROR IN COMMUNICATION TO ECU";

else

job_status="COMMUNICATION TO ECU IS OK";

Result job_status="ERROR IN COMMUNICATION TO ECU" in case the ECU doesn’t respond.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

get_error2

Summary Checks whether an error has occurred

long get_error2()

Remarks Normally, EDIABAS reacts to an error by automatically aborting the currently active job, and only an
error message is returned. In some cases, however, e.g. in case of control unit identification, you
may want to analyze certain errors in the control unit description file, and certain bits (trap bits) can
be set in the trap mask register for this purpose (see set_trap_mask). Each trap bit is assigned an
error message. When this bit is set, the job is not automatically aborted when an error occurs, but a
trap bit and the trap number are set in the condition code register. The get_error2 function returns
the error number. For the list of available trap numbers see function set_trap_mask.

Return value number of error that occurred

See also get_error, get_trap_mask, set_trap_mask, make_error

Example long error;


set_trap_mask(0xffffffff); // trap all

// errors

send_and_receive(destin,source);

error = get_error2();

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 99 of 161

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

get_ignition_voltage

Summary Reads out the voltage at the ignition

long get_ignition_voltage()

Remarks This function returns the voltage at clamp 15 (ignition voltage) in millivolts.

Return value Voltage in millivolts

See also get_battery_voltage

Example long voltage;

voltage = get_ignition_voltage();

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

get_token

Summary Identifies a token in a string

void get_token(char destin[],char source[],char separator [],long nr)

destin Target buffer for the identified token (V)

source string to be analyzed

separator string with the possible token separators

no number of the token to be identified

Remarks A token is a coherent part of a character string that is limited by one or more characters from separator.
To split a normal text into tokens, the separator string separator must contain SPACE, TAB and CR.
The get_token function analyzes the source string and identifies the tokens within the string that are
defined by the characters in separator. The token number no is then copied to destin.

Return value -

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

char source[]; char destin[];

source="DIES IST EIN TEST FUER TOKENS";

gettoken(destin,source," ",4);

Result destin = "TEST"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

get_trap_mask

Summary Gets the current value of the trap mask register

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 100 of 161

long get_trap_mask()

Remarks The get_trap_mask function reads the current value of the trap mask register. This register decides
which errors will be reported to the runtime system and which will not.

See set_trap_mask for a full description of the trap mask register.

Return value The current value of the trap mask register

See also get_error, set_trap_mask

Example {

long x;

set_trap_mask(0x00180000);

x=get_trap_mask();

Result x=0x00180000

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

getasciidate

Summary Gets the current date as an ASCII string

void getasciidate(char date[])

date String buffer to take the date string (V)

Remarks From the system time this function identifies the current date as a string with the form

"wt tt.mm.jj KW kw"

wt = weekday = MO, DI, MI, DO, FR, SA, SO

The calendar week (KW) is identified according to generally applicable rules.

Return value -

See also getasciitime, getdate, gettime, wait

Example {

char date[];

getasciidate(date);

...

Result date="FR 31.12.92 KW 52" (example)

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

getasciitime

Summary Gets the current time as an ASCII string

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 101 of 161

void getasciitime(char time[])

time String buffer to take the time string (V)

Remarks From the system time this function identifies the current time as a string with the form

"hh:mm:ss"

Return value -

See also getasciidate, getdate, gettime, wait

Example {

char time[];

getasciitime(time);

...

Result time="12:51:15" (example)

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

getCfgInt

Summary Reads out a configuration element as integer

long getCfgInt(char cfg[])

cfg Configuration element

Remarks With this function, the setting of EDIABAS configuration elements can be determined.

Return value Current configuration setting

See also enableIIfhTrace, enableIgnitionHandling, enableUbattHandling, getCfgString, IsDebugLevel,


IsSimulation

Example long cfgvalue;

cfgvalue=getCfgInt("RetryComm");

Result cfgvalue=0..1 // automatic repetition ?

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

getCfgString

Summary Reads (gets) a configuration element as a string

long getCfgString(char cfgvalue[],char cfg[])

cfgvalue Buffer for configuration setting

cfg Configuration element

Remarks This function can be used to determine the setting of EDIABAS configuration elements.

Return value 0: Configuration element not found

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 102 of 161

1: Configuration element found

See also enableIIfhTrace, enableIgnitionHandling, enableUbattHandling, getCfgInt, IsDebugLevel,


IsSimulation

Example char cfgvalue[];

getCfgString(cfgvalue,"SimulationPath");

Result z.B.: cfgvalue="c:\ediabas\sim"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

getdate

Summary Gets the current time as an array structure

void getdate(char date[])

date Buffer to take the date structure (V)

Remarks From the system time this function identifies the current date as a structure with the form:

date[0] = day of month (1..31)

date[1] = month of year (1..12)

date[2] = year (0..99)

date[3] = calendar week (1..53)

date[4] = Weekday : (1 = Monday 7 = Sunday)

The calendar week is identified according to generally applicable rules.

Return value -

See also getasciidate, getasciitime, gettime, wait

Example {

char date[];

// Friday, 6th of August, 1999 (calendar week 31)

getdate(date);

...

Result date= { 06,08,63,1F,05 } (Example)

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

getETXblock

Summary Returns the data bytes of a block specified for a KWP 1281 ECU.

long getETXblock(unsigned char response[], long status, long block,


unsigned char daten[], long block length)

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 103 of 161

response ECU response message frame (V)

status In the function: Expected status byte of the block (V)


From the function: Actual status byte of the block (V)

block Block number beginning with 1

daten Data bytes of the block (V)

block length Number of data bytes in the block (V)

Remarks This function filters out the data bytes of a certain block from the response message of an ECU. In
addition, the block is checked for correctness by means of a passed status byte (expected status ==
actual status). If the expected (desired) status byte does no agree with the actual status byte, this
function returns the value 0, otherwise 1.

Return value 0 = error


1 = no error

See also -

Example unsigned char response[];


unsigned char buffer[];
unsigned char status = 0xfc;
char blockLen;

send_and_receive(response,tel_fslesen);

if (getETXblock(response,status,1,buffer,blockLen))
{

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

GetKWP2000Block

Summary Extracts the data component from a KWP 2000 telegram in the control unit response.

int GetKWP2000Block(int position, char response[],char format, char target, char source, int length, char data[])

position Initial position of a telegram in the control unit response (V)

response Control unit response

format KWP 2000 format byte in the header (V)

target KWP 2000 tester address in the 3-byte header. In a 1- byte header, 0 is entered. (V)

source KWP 2000 control unit address in the 3-byte header. In a 1-byte header, 0 is entered.(V)

length Length of the telegram data (including the ServiceID) (V)

data Telegram data (including the ServiceID) (V)

Remarks This function extracts the data component (including ServiceID) from a KWP 2000 telegram;
DataSegmentation is supported. Since the control unit response may consist of several telegrams,
position points to the beginning of a telegram. After execution of the function, position points to the
next telegram, if available. The function returns the value 1 as long as no error has occurred.

Return value 0: error


1: no error

See also -

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 104 of 161

Example {

unsigned char resonse[];

int position;

int format;

int source;

int target;

int length;

unsigned char data[];

unsigned char dataglobal[];

send_and_receive(resonse,request);

position = 0;

while(GetKWP2000Block(position,resonse,
format,source,target,length,data))

datacat(dataglobal,data);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

gettickcount

Summary Gets an internal tick counter of milliseconds.

unsigned long gettickcount()

Remarks This function gets an internal tick counter of milliseconds. Note: multiple calls of this function may
cause a counter overrun. In this case the counter starts again with 0. The precision of the function
gettickcount depends on the operating system:

Win16/32: milliseconds since system start

Unix: seconds since 00:00 o’clock

Return value value of milliseconds

See also getasciidate, getasciitime, getdate, wait, waitex

Example {

unsigned long ticks;

ticks=gettickcount();

...

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 105 of 161

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

gettime

Summary Gets the current time as an array structure

void gettime(char time[])

time Buffer to take the time structure (V)

Remarks From the system time this function identifies the current time as a structure with the form

time[0] = hour ( 0..23 )

time[1] = minute ( 0..59 )

time[2] = second ( 0..59)

Return value -

See also getasciidate, getasciitime, getdate, wait

Example {

char time[];

gettime(time);

...

Result time= { 14,52,10 } (example)

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

hex2ascii

Summary Converts a sequence of bytes to a hex string.

void hex2ascii(char destin[],char source[],int pos, int count)

destin String buffer(V)

source Source buffer

pos Position in source buffer

count Number of nibbles to be converted

Remarks Converts a chain of bytes from the source buffer source, starting from the byte position pos, into a zero-
terminated string destin. count nibbles are converted from the source string.

Return value -

See also atoi, atoy, bcd2ascii, itoad, itoax, ascii2hex

Example {

char source[]={ 0x12, 0x34, 0xFF, 0x78, 0x90 };

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 106 of 161

char destin[];

hex2ascii(destin,source,1,2};

...

Result destin = "34FF"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifboot

Summary Resets the interface

void ifboot()

Remarks This function returns the interface to initializing status and tests the diagnostic interface. The IDBSS will
not accept commands for about 2 seconds after this job.

Return value -

See also -

Example ifboot();

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifgetport

Summary Reads out a port

long ifgetport(long port)

port Port number (V,C)

Remarks This function reads out ports. With EDIC up to nine ports can be read out. Ports 0 - 7 are analog inputs
(results in millivolts), port 8 returns the value of the jumper field (each bit is a jumper).

EDIC:

Port 0 - 5 : Analog inputs 0 - 5 (voltage in mV)

Port 6: Analog input terminal 15 (voltage in mV)

Port 7 : Analog input terminal 30 (voltage in mV)

Port 8 : Jumper field (digital value)

Return value Value of the port

See also get_battery_voltage, get_ignition_voltage

Example long voltageCl30;

long jumper;

voltageCl30= ifgetport(7);

jumper = ifgetport(8);

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 107 of 161

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifinfo

Summary Function for the purpose of debugging

void ifinfo(char output[], char input[])

output Output data (V)


input Input data

Remarks This function only exists for the purpose of debugging. When developing EDIABAS, the internal
functionality over the description file can be influenced using this function. The functionality can
vary depending on the EDIABAS version. This function must not be used by the user and is only
explained for completeness.

Return value -

See also ifinfoExt

Example -

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifinfoExt

Summary Function for the purpose of debugging

long ifinfoExt(long funcID,char output[], char input[])

funcID Function ID (V)

output Output data (V)

input Input data

Remarks This function exists only for debugging purposes. During the development of EDIABAS, the function
can influence the internal functionality via the description file. This functionality can vary among the
different EDIABAS versions. The user may not use this function; it is only described here for
completeness.

Return value Status

See also ifinfo

Example -

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifloopt

Summary Tests the diagnostic lead

long ifloopt()

Remarks This function tests the diagnostic lead - there must be a short between the RD and TD leads.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 108 of 161

Return value 0: Test failed

1: Test OK

See also -

Example if (ifloopt())

/* execute diagnostic */

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifrawmode

Summary Passes data to the interface

void ifrawmode(unsigned char response[], unsigned char request[])

response response from the interface


request request to the interface

Remarks This function passes the transmitted data direct to the interface. The interface answer is returned un-
interpreted. The control bytes of an answer of the EIDBSS application of the EDIC interface are not
evaluated.

Return value -

See also -

Example unsigned char request[];

unsigned char response[];

request= {0x0A, 0x00}; /* read out version number of EDIC */

ifrawmode(response, request);

Result e.g. output: 0x00, 0x00, 0x03, 0x00

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifrecv

Summary Function for the purpose of debugging

void ifrecv(unsigned char response[], long time)

response Data from the serial interface (V)

time Waiting time in milliseconds

Remarks This function waits the specified time for characters on the serial interface. This function is only used for
the purpose of debugging. Never use this function, since it may vary depending on the EDIABAS
version.

Return value -

See also ifsend

Example -

Result -

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 109 of 161

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifrequeststate

Summary Interrogate the interface status

void ifrequeststate(unsigned char status[])

status Interface status (V)

Remarks This version interrogates the current status of the interface.

Return value -

See also -

Example

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifreset

Summary Resets the communication parameters

void ifreset()

Remarks This function breaks off communication with a control unit and resets the communication parameters.
Any control unit telegram that may be stored in the interface is erased.

Return value -

See also ifboot

Example ifreset();

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifsend

Summary Function for the purpose of debugging

void ifsend(unsigned char request[])

request Data to the serial interface

Remarks This function sends characters to the serial interface. It is used only for the purpose of debugging. Never
use this function, since it may vary depending on the EDIABAS version.

Return value -

See also ifrecv

Example -

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifsetport

Summary Sets a port

void ifsetport(long port, long value

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 110 of 161

port Port number

value Port value

Remarks Ports can be set with this function. Only port 9 can be set in EDIC (digital outputs).

Port 9 : Digital outputs

Return value -

See also ifgetport

Example long value;

value = 0xff;

ifsetport(9, value);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifsireset

Summary Switches the SI relay

void ifsireset(long time)

time Switching time in milliseconds

Remarks This function switches on the service interval relay of the interface for the specified time.

time = 0: Continuous off

time = -1: Continuous on

Return value -

See also -

Example ifsireset(100); /* switch for 100 ms */

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

iftype

Summary Returns the interface type as a string

void iftype(char type[])

type String to take the interface type (V)

Remarks This function returns the interface type as a zero-terminated string.

Return value -

See also ifvers

Example char typ[];

iftype(typ);

Result -

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 111 of 161

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

ifvers

Summary Returns the interface version number

long ifvers()

Remarks This job returns the version number of the interface

Return value Version number

See also -

Example unsigned int versionsnr;

versionsnr = ifvers();

Result versionsnr /* e.g. 0 */

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

incProgressPos

Summary Increases the current position of the progress counter.

void incProgressPos(long n)

n Value for which the current progress position is to be increased..

Remarks This function increases the current progress position by the value specified. It only has affect when the
progress counter has been previously initialized in a job with setProgressRange.

Return value -

See also setProgressRange

Example

setProgressRange(500);

incProgressPos(0); // start with 0 percent

incProgressPos(100); // 20 percent

: // processed

incProgressPos(300); // 80 percent

: // processed

incProgressPos(200); // 100 percent

// processed

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 112 of 161

///////////////////////////////////////////////////

// In the ENDE Job

setProgressRange(0); // Reset processing

// state

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

isDebugLevel

Summary Determines the debug level

long isDebugLevel()

Remarks This function can be used to determine the setting of the EDIABAS configuration element
"BipDebugLevel". By means of this value, certain actions can only be performed during the ECU
description file test.
Corresponds to: getCfgInt("BipDebugLevel");

Return value 0 = Debug OFF (default),


n = Debug level

See also enableIIfhTrace, enableIgnitionHandling, enableUbattHandling, getCfgInt, getCfgString,


IsSimulation

Example char response[];

// Output sent frame for testing purposes

if(isDebugLevel() > 3)

SEND_TEL=tel;

send_and_receive(response,tel);

// Output received frame for testing purposes

if(isDebugLevel() > 3)

RECV_TEL=response;

Result

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

isSimulation

Summary Determine whether simulation is enabled

long isSimulation()

Remarks This function can be used to determine the setting of the EDIBAS configuration element "Simulation".
By means of this value, certain actions can only be performed during the ECU description file test.
Corresponds to: getCfgInt("Simulation");

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 113 of 161

Return value 0 = Simulation OFF(default),


1 = Simulation ON

See also enableIIfhTrace, enableIgnitionHandling, enableUbattHandling, getCfgInt, getCfgString,


IsDebugLevel

Example char response[];

// Use other frame for testing purposes

if(isSimulation())

send_and_receive(response,tel_sim);

else

send_and_receive(response,tel);

Result

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

itoad

Summary Converts a number to a string in decimal notation

void itoad(char destin[],long value)

destin Buffer to take the string (V)

value Number to be converted

Remarks itoad converts the number value to a string with decimal notation with a sign. No leading zeroes are
output.

Return value -

See also atoi, atoy, bcd2ascii, hex2ascii, itoax, ascii2hex

Example {

char destin[];

itoad(destin,1143);

...

Result destin="1143"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

itoax

Summary Converts a number to a string in hexadecimal notation

void itoax(char destin[],long value)

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 114 of 161

destin Buffer to take the string (V)

value Number to be converted

Remarks itoax converts the number value to a string with hexadecimal notation with a sign. The output string
always has the format 0x########. All the positions are always output.

Return value -

See also atoi, atoy, bcd2ascii, hex2ascii, itoad, ascii2hex

Example {

char destin[];

itoax(destin,1143);

...

Result destin="0x00000477"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

itor

Summary Converts an integer to a real value

void itor(real destin, long value);

destin Real number to take the conversion result


(maximum double = 1.7E ± 308 (15 digits))

value Number to be converted

Remarks itor converts an integer to a real number.

Return value -

See also ator, realadd, realsub, realmul, realdiv

Example {

real realzahl;

itor(realzahl,122);

...

Result realzahl = 1.22e2

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

make_error

Summary Issues an EDIABAS error

void make_error(long trapnumber);

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 115 of 161

trapnumber number of the error to be issued

Remarks This function enters the trap number trapnumber in the Trap-Mask-Register and issues the
corresponding error in the runtime system.

Return value -

See also get_error

Example {

...

make_error(19); // Issue IFH_0009

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

new_set_of_results

Summary Opens a new set of results

void new_set_of_results()

Remarks The function new_set_of_results signals the start of a new result set to the runtime system. The results
of a job can be split up into several sets. The result information can be grouped in this way. For
instance, the results ERROR_NAME and ERROR_VALUE can be returned for each error contained
in the control unit without always having to use a new result name.

Return value -

See also parcount, realresult

Example ...

result: x ; type int ...

x = 1;

x = 2;

new_set_of_results();

x = 1;

...

Result Result set 1: x = 2;

Result set 2: x = 1;

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

open_channel

Summary Opens a communication channel to the interface driver

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 116 of 161

long open_channel(long useDefaultChannel)

useDefaultChannel Default channel or open new channel(C):

0 = Open new channel

1 = Use default channel

Remarks This function opens a communication channel to the interface driver. The opened interface channel
becomes the active channel. Optionally the default interface channel can be used (useDefaultChannel
<> 0). In that case just does a switch to the default interface channel. The opened interface channel or
the default interface channel becomes the active channel.

Return value Identifier of the active interface channel

See also close_channel, closeall_channel, switch_channel

Example long channel;

channel=open_channel(0);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

open_communication

Summary Opens the communication channel to the interface

void open_communication()

Remarks This function opens the interface driver. This function must be called before all other that access the
interface, and it is advisable to write it as the first function in the job INITIALISIERUNG. The
function open_communication automatically opens a default interface channel to the interface. It is
recommended to call this function as first function in the job INITIALISIERUNG. If
open_communication has not been called yet, then all communication and interface commands are
answered by error message IFH_0019.

Return value -

See also close_communication, open_channel

Example open_communication();

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

parcount

Summary Counts the number of parameters

long parcount()

Remarks Identifies the number of parameters sent as parameter 3 in apiJob or apiJobData. It always counts all the
parameters including the ones that are not valid, i.e. blank, so parcount returns the value 5 with
apiJob("...","...",";;;;","..."). It even returns 1 when a parameter exists that cannot be evaluated.

Return value The number of transmitted parameters

See also new_set_of_results, realresult

Example {

long x;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 117 of 161

x=parcount();

Result apiJob(...,"1;2;3",...); => x=3

apiJob(...,"1",...); => x=1

apiJob(...,";;",...); => x=3

apiJob(...,"1;2;",...); => x=3

apiJobData(...,"",5,...); => x=1

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

real_to_data

Summary Converts a real number into data bytes

void real_to_data(char destin[], real source, long pos, long double, long byteorder);

destin Target buffer for recording the conversion result (V)

source Real number (V)

pos Position of the 1st data byte in the target buffer

double Precision of the real number in the target buffer:

0 = single-precision (4 data bytes IEEE)

<> 0 = double-precision (8 data bytes IEEE)

byteorder Memory format in the target buffer:

0 = Little Endian (Intel)

<> 0 = Big Endian (Motorola)

Remarks The real_to_data function converts the real number source into 4 (double=0) or 8 data bytes
(double=1). The data bytes are copied to the target buffer destin as of the position pos.
In case of single-precision (double=0), the error BIP_0011 is triggered if the real number value is not
within the range 3.4E±38.

Return value -

See also data_to_real

Example {

unsigned char buffer[];

real realzahl;

realzahl = atof("123.45");

real_to_data(buffer,realzahl,0,0,0);

...

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 118 of 161

Result buffer = { 0x66, 0xe6, 0xf6, 0x42 }

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

realadd

Summary Adds two real numbers

void realadd(real destin, real source)

destin First operand and target of the addition (V)

source Second operand of the addition (V)

Remarks This function adds the real variables source and destin and writes the result to destin.
destin = destin + source

A computer overflow or underflow triggers error messages BIP_0011.

Return value -

See also ator, itor, realdiv, realmul, realsub

Example {

real real1;

real real2;

ator(real1,"1234e15");

ator(real2,"5678e13");

realadd(real1,real2);

Result real1 = 1.29078e18

real2 = 5.678e16

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

realcomp

Summary Compares two real numbers

long realcomp(real value1, char operator[], real value2)

value1 First operand of the comparison

operator String with relation operator:

"==", "!=", "<", "<=", ">" or ">="

value2 Second operand of the comparison

Remarks The function compares the real variables value1 and value2. The comparison to be carried through must
be defined with operator.

Return value 0 for an unsuccessful comparison, <>0 with a successful comparison.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 119 of 161

See also -

Example {

int cmp;

real real1;

real real2;

ator(real1,"1.00");

ator(real2,"2.00");

if (realcomp(real1,"<",real2))

cmp=1;

else

cmp=0;

Result cmp = 1

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

realdiv

Summary Divides two real numbers

void realdiv(real destin, real source)

destin Dividend and target of the division (V)

source Divisor (V)

Remarks This function divides the real variables source and destin and writes the result to destin.
destin = destin / source

A computer overflow or underflow triggers error messages BIP_0011.

Return value -

See also ator, itor, realadd, realmul, realsub

Example {

real real1;

real real2;

ator(real1,"1234e15");

ator(real2,"5678e13");

realdiv(real1,real2);

Result real1 = 21.7330045791

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 120 of 161

real2 = 5.678e16

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

realmul

Summary Multiplies two real numbers

void realmul(real destin, real source)

destin First factor and target of the multiplication (V)

source Second multiplication factor (V)

Remarks This function multiplies the real variables source and destin and writes the result to destin.
destin = destin * source

A computer overflow or underflow triggers error messages BIP_0011.

Return value -

See also ator, itor, realadd, realdiv, realsub

Example {

real real1;

real real2;

ator(real1,"1234e15");

ator(real2,"5678e13");

realmul(real1,real2);

Result real1 = 7.006652e34

real2 = 5.678e16

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

realresult

Summary Generates a real result

void realresult(char name[], long value, long adjust)

name Name of the result

value Value of result as a long integer number

adjust Correction factor for the result as a long integer number

Remarks This function generates a real result with result name name and the value value / adjust.

Return value -

See also new_set_of_results, parcount

Example ...result: x; type : int ... ) {

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 121 of 161

realresult("x",12345678,1000);

Result x = 12345,678

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

realsub

Summary Subtracts two real numbers

void realsub(real destin, real source)

destin Minuend and target of the subtraction (V)

source Subtrahend (V)

Remarks This function subtracts the real variables source and destin and writes the result to destin.
destin = destin - source

A computer overflow or underflow triggers error messages BIP_0011.

Return value -

See also ator, itor, realadd, realdiv, realmul

Example {

real real1;

real real2;

ator(real1,"1234e15");

ator(real2,"5678e13");

realsub(real1,real2);

Result real1 = 1.17722e18

real2 = 5.678e16

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

receive

Summary Receives a telegram

long receive(unsigned char response[])

response Answer telegram from the control unit (V)

Remarks This function checks if a control unit response to a previous call to the function send was received. If
there is a response, the received data are copied to the receive buffer response[] and the number of
copied bytes is returned. If there is no response, the function returns 0 (the content of the receive
buffer response[] is reset as in the function dataclear). The return value is always the size of the
receive buffer, i.e. return value = datalen(response).

Return value 0 in case of no response, otherwise number of received bytes

See also send, send_and_receive

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 122 of 161

Example unsigned char response[];

long len;

request = {0x0D, 0x00, 0x05, 0x00}; /* request telegram */

send(request);

len = 0;

while (len == 0)

len=receive(response);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

recv_frequent

Summary Receives a telegram in the frequent mode

void recv_frequent(unsigned char telegram[])

telegram Answer telegram from the control unit (V)

Remarks If repeat send and receive (frequent mode) has been started, the current control unit answer can be
requested from the interface with the recv_frequent function.

Return value -

See also send_frequent, stop_frequent

Example unsigned char response[];

send_frequent(request);

recv_frequent(response);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

recv_keybytes

Summary Reads out the control unit key bytes

void recv_keybytes(unsigned char keybytes[])

keybytes Control unit key bytes (V)

Remarks This function reads out the keybytes from a concept 2, concept 3 or concept 4 control unit. The control
unit is woken up automatically if it has not already done so.

Return value -

See also -

Example unsigned char keybytes[];

recv_keybytes(keybytes);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 123 of 161

rtoa

Summary Converts a real number into a string

long rtoa(char destin[],real value,int count);

destin String for storing the conversion result

value Real number to be converted

count Number of positions to be converted (without decimal point and minus character)

Remarks The rtoa function converts a real number into a string. In case of too few positions, the value is rounded
off. In case of too many positions, the string is filled with zeroes.
If 0 is used as count, the real number is converted into a string in exponential notation. With DOS,
there is NO conversion into exponential notation, but the value for count is internally set at 10.

Return value Number of the converted characters including terminated zero character.

See also ator

Example {

char destin[];

real realzahl;

int len;

ator(realzahl,"1.234";

...

len=rtoa(destin,realzahl,3);

...

Result destin="1.23";

len=5

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

rtoi

Summary Converts a real number into an integer

long rtoi(real value);

value Real number to be converted

Remarks The rtoi function converts a real number into an integer.

Return value Converted value as integer

See also itor

Example {

long destin[];

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 124 of 161

real realzahl;

ator(realzahl,"5.234";

...

destin=rtoi(realzahl);

...

Result destin=5;

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

send

Summary Sends a telegram

void send (unsigned char request[])

request Control unit request telegram

Remarks This function sends a telegram to the control unit. The control unit’s response has to be retrieved using
the function receive.

NOTE: The maximum telegram length is the same as in send_and_receive!

Return value -

See also receive, send_and_receive

Example unsigned char request[];

request = {0x0D, 0x00, 0x05, 0x00}; /* request telegram */

send(request);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

send_and_receive

Summary Sends and receives a telegram

void send_and_receive(unsigned char response[],


unsigned char request[])

response Control unit answer telegram (V)

request Control unit request telegram

Remarks This function sends a telegram to the control unit and receives the answer.

NOTE: Maximum length of telegram must not be exceeded!

Up to EDIABAS V6.x.x: max. 1018 Bytes

From EDIABAS V7.0.0: max. 65530 Bytes

(depends on string register size of the ECU description file)

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 125 of 161

Return value -

See also send_frequent, recv_frequent, stop_frequent

Example unsigned char request[];

unsigned char response[];

request = {0x0D, 0x00, 0x05, 0x00}; /* request telegram */

send_and_receive(response, request);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

send_frequent

Summary Sends and receives a telegram in the frequent mode

void send_frequent(unsigned char request[])

request Control unit request telegram

Remarks This function repeatedly sends the transmitted telegram to the control unit (frequent mode). In this mode
a further call of send_frequent or send_and_receive is answered by the error message IFH_0006.
The frequent mode is terminated with stop_frequent (send_frequent and send_and_receive can
now be called again).

NOTE: Maximum length of telegram must not be exceeded!

Up to EDIABAS V6.x.x: max. 1018 Bytes

From EDIABAS V7.0.0: max. 65530 Bytes

(depends on string register size of the ECU description file)

Return value -

See also recv_frequent, stop_frequent

Example unsigned char request[];

unsigned char response[];

request = {0x0D, 0x00, 0x05, 0x00};

send_frequent(request);

recv_frequent(response);

recv_frequent(response);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

set_answer_length

Summary Sets the telegram parameters/response length

void set_answer_length(int telparam[])

telparam Telegram parameter

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 126 of 161

Remarks To send a telegram, the interface needs telegram parameters. These parameters either control the
establishment of the connection to the control unit or transmit the information concerning the
expected response length and the response offset. During communication with the control unit, the
telegram parameters are generally identical for all control unit telegrams. They can be set by the user
with the function set_answer_length so that they do not have to be transmitted with each telegram.
During transmission of a telegram, the telegram parameters are always automatically set at the
beginning of the telegram. If the user indicates no telegram parameters, the default values that were
used to set the communication parameters will be used here as well. If only telegram parameters are
to be transferred to the interface, they must first be set with set_answer_length and then transmitted
to the interface with send_and_receive. In this case, the telegram to be sent is empty (buffer emptied
with dataclear).
telparam[0] Control code/response length:
In connection with the BMW protocols concept 1, concept 2, concept 3, concept 4, DS1 and DS2,
telparam[0] is interpreted as response length.
The response length supplies the length of the anticipated control unit response.
Concept 1, DS1, DS2 and Concept 3:

positive: Number of anticipated bytes in the control unit answer telegram


(fixed answer length)

negative: Position of answer length in the answer telegram (from byte 0)


(variable answer length)

Concepts 2 and 4: Maximum number of blocks containing the desired information.


In connection with KWP 2000 (KWP 2000 Standard, KWP 2000 BMW, BMW-FAST, KWP 2000*),
telparam[0] is interpreted as control code.
0x0000: Normal telegram interchange between the interface and the control unit is carried
through.
0xFFFF telparam[1] is interpreted as a command.
telparam[1] Command/response offset:
In connection with the BMW protocols concept 1, concept 2, concept 3, concept 4, DS1 and DS2,
telparam[0] is interpreted as a response offset.
Concept 1, DS1, DS2 with variable answer length only. In this case the answer length is computed as
follows:
Length = (answer length + 1) + answer offset
In combination with KWP 2000 (KWP 2000 Standard, KWP 2000 BMW, BMW-FAST, KWP
2000*), telparam[1] is interpreted as a command.
0x0000: Normal telegram interchange between the interface and the control unit is carried
through.
0x0010 If telparam[0]=0xFFFF, then “start communication” command.
0x0011 If telparam[0]=0xFFFF, then “stop communication” command.
For a detailed description of the telegram parameters, see the parameterization instructions for the
respective diagnostic protocol.
Default values for the telegram parameters after setting of the control unit parameters:
Concept 1 3 DS1,DS2 (5,6) 2,4 otherwise
Length -2 52 -1 1 0
Offset 0 0 0 0 0

Return value -

See also set_communication_pars

Example int awlen[] = {-2,0}; /* With concept 2 the answer length */

/* is at 2nd place in the telegram */

set_answer_length(awlen);

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 127 of 161

Result

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

set_communication_pars

Summary Sets the communication parameters

void set_communication_pars(unsigned int param[])

param Communication parameters

Remarks This function sets the communication parameters needed to communicate with the control unit. The
parameters have an interface-independent format. Once the parameters have been set with this
function, the user software does not have to be changed for an interface change. The concept
0x0000FF00 constitutes an exception. This concept is an identifier which informs the interface
driver that the subsequent parameters are transferred to the interface unchanged (raw data).

The parameters for a concept consist of a sequence of either character, integer or long values. The
more significant byte in the concept parameter (param[0]) determines the parameter format.

0x01xx: long values


0x00xx integer values
0xFF00 character values as raw data

The number and content of the parameters for a concept depend on the concept.

The function set_communication_pars must be called before a new control unit is addressed. As well as
the communication parameters the telegram header is assigned default values in EDIABAS according
to the preset concept. See set_answer_length for more details about the telegram header.

Character parameter for concept


OBDII / ISO 9141-Carb
This set of parameters is valid for the EDIC interfaces only.

param[0] Preamble for raw = 0x00 reserved


param[1] parameter set. = 0xFF reserved
param[2] = 0x00 reserved
param[3] = 0x00 reserved
param[4] Concept

= 0x07 OBDII / ISO 9141-Carb


param[5] Address

Diagnostic address for CARB


param[6] Settings for checksum handling und length check (bit
coded)
Bit 0 Checksum Generation
=0 The checksum of the telegram to be sent must
be created by the user.
=1 The checksum of the telegram to be sent is
generated by the interface
Bit 1 Checksum Verification
=0 The checksum of the received message is
checked.
=1 The checksum of the received message is not
checked.
Bit 2 Length of Telegram Verification

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 128 of 161

=0 The length information of the received


message is checked by the interface.
=1 The length information of the received
message is not checked by the interface.
param[7..4] = 0x00 reserved
param[15] Initialization
= 0x00 5 Baud Initialization prior to the first telegram
to be sent by the interface
= 0x01 No Initialization required
= 0x02 Fast Initialization prior to the first telegram to
be sent by the interface
param[16] = 0x00 reserved
param[17] Baud Rate Measurement
= 0x00 Baud rate will be set according to parameter
„Baud rate” (param[19/20].
= 0x01 Baud rate will be measured and set
automatically by the interface
param[18] = 0x00 reserved
param[19] Baud rate - low byte
param[20] - high byte
100 up to 30000 baud

0 in case of active measurement of the baud rate (param[17]


== 0x01)
param[21] W0 - low byte
param[22] - high byte
Timing, bus idle time [ms] before the interface starts the
communication to the ECU.
param[23] W1 - low byte
param[24] - high byte
Timing, timeout [ms] for reception of the SYNC byte from
the ECU.
param[25] W2 - low byte
param[26] - high byte
Timing, timeout [ms] for reception of KeyByte 1.
param[27] W3 - low byte
param[28] - high byte
Timing, timeout [ms] for reception of KeyByte 2.
param[29] W4 - low byte
param[30] - high byte
Timing, time [ms] between reception of KeyByte2 and its
inversion sent by the interface.
param[31] W4B - low byte
param[32] - high byte
Timing, timeout [ms] for reception of the inversion of the
address of the ECU.
param[33] W5 - low byte
param[34] - high byte
Timing, bus idle time [ms] after a communication error
before the interface restarts the communication to the ECU.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 129 of 161

param[35] P1 - low byte


param[36] - high byte
Timing, timeout [ms] for inter byte time of ECU response
param[37] P2 - low byte
param[38] - high byte
Timing, timeout [ms] for ECU response after request or
another ECU response.
param[39] P3 - low byte
param[40] - high byte
Timing, time [ms] between end of ECU response and start
of a new request from the interface.
param[41] P4 - low byte
param[42] - high byte
Timing, Inter byte time [ms] for requests sent by the
interface
param[43] = 0x00 reserved
param[44] = 0x00 reserved
param[45] ACK-Time - low byte
param[46] - high byte
Timing, time [ms] between the last response of an ECU and
the next ACK request sent by the interface.
param[47] ACK Request Length [bytes]

= 0x00 to 0x0B
param[48] = 0x00 reserved
param[49..59] ACK Request

Not used bytes has to be initialized with 0x00.

Character Parameter for Concept


BMW DS2 NNBr
This set of parameters is valid for the EDIC interfaces only.

param[0] Preamble for raw = 0x00 reserved


param[1] parameter set. = 0xFF reserved
param[2] = 0x00 reserved
param[3] = 0x00 reserved
param[4] Concept

= 0x08 BMW DS2 NNbr


param[5] Settings
Bit 0 Checksum Generation
=0 The checksum of the telegram to be sent must
be created by the user.
=1 The checksum of the telegram to be sent is
generated by the interface
Bit 1 Checksum Verification
=0 The checksum of the received message is
checked.
=1 The checksum of the received message is not
checked.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 130 of 161

Bit 6 TesterPresent
=0 TersterPresent request ist sent by the interface
automatically.
=1 TesterPresent will not by sent by the interface
Bit 7 Baud Rate Setting
=0 Baud Rate is set to 9600 baud.
=1 Baud rate is set according to the values of
param[32] and param[33].
param[6] Block-Timeout - low byte
param[7] - high byte
Timing, timeout [0.1 ms] for ECU to respond to a request
block.
param[8] Byte-Timeout - low byte
param[9] - high byte
Timing, inter byte time [0.1 ms] for response blocks from
the ECU
param[10] Regeneration Time - low byte
param[11] - high byte
Timing, time [0.1 ms] between a response block and the
next request block sent by the interface.
param[12] Inter Byte Time - low byte
param[13] - high byte
Timing, inter byte time [0.1 ms] for request blocks from the
interface.
param[14] ACKCycleTime - low byte
param[15] - high byte
Timing, time [ms] between the last response block and the
transmission of an ACK block by the interface.
param[16] BusyWait - low byte
param[17] - high byte
Timing, time [0.1 ms] between the reception of a busy block
and retransmission of the request block.
param[18] ACK block Length

Length [bytes] of the ACK block defined below.

0 up to 10 bytes
= 0x00 The default block „Keep up
Diagnostic Session“ is sent.
param[19..28] ACK Block

Complete ACK Block without EXOR checksum. Bytes not


used have to be initialized with 0x00.
param[29] = 0x00 reserved
param[30] = 0x00 reserved
param[31] = 0x00 reserved
param[32] Baud rate - low byte
param[33] - high byte
100 up to 30000 baud

Only used if param[5].bit7 == 1

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 131 of 161

param[34] Error Repeat

Number of retries after communication error.


= 0x00 No retry of block transmission. The
error is reported to the application
immediately.
<> 0x00 After a communication error
occurred the communication will be
repeated until either no error occurs
or the maximum count of retries
specified by “Error Repeat” is
reached. In the latter case the error
is reported to the application.

Character Parameter for Concept


BMW DS2 FNBr
This set of parameters is valid for the EDIC interfaces only.

param[0] Preamble for raw = 0x00 reserved


param[1] parameter set. = 0xFF reserved
param[2] = 0x00 reserved
param[3] = 0x00 reserved
param[4] Concept

= 0x09 BMW DS2 FNbr


param[5] Checksum
Bit 0 Checksum Generation
=0 The checksum of the telegram to be
sent must be created by the user.
=1 The checksum of the telegram to be
sent is generated by the interface
Bit 1 Checksum Verification
=0 The checksum of the received
message is checked.
=1 The checksum of the received
message is not checked.
param[6] Block-Timeout - low byte
param[7] - high byte
Timing, timeout [ms] for response of the ECU.

0 == 70 seconds timeout for response in case of flash


programming.
param[8] Byte-Timeout - low byte
param[9] - high byte
Timing, inter byte time [ms] for response blocks of the
ECU.
param[10] Regeneration Time - low byte
param[11] - high byte
Timing, time [ms] between a response block and the next
request block sent by the interface.
param[12] = 0x00 reserved
param[13] = 0x00 reserved
param[14] ACKCycleTime - low byte

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 132 of 161

param[15] - high byte


Timing, time [ms] between the last response block and the
transmission of an ACK block by the interface.

This parameter has to be 0 (zero) or greater than the


parameter “Regeneration Time”.

0 == No ACK Block is sent.


param[16] ACK Block Length

Length [bytes] of the ACK block defined below.

0 up to 10 bytes
param[17..26] ACK Block

Complete ACK Block without EXOR checksum.

Bytes not used have to be initialized with 0x00.


param[27] = 0x00 reserved
param[28] Baud rate - low word/ low byte
param[29] - low word/ high byte
param[30] - high word/ low byte
param[31] - high word/ high byte
9600 up to 125000 baud

Character Parameter for Concept


BMW EASY NBr
This set of parameters is valid for the EDIC interfaces only.

param[0] Preamble for raw = 0x00 reserved


param[1] parameter set. = 0xFF reserved
param[2] = 0x00 reserved
param[3] = 0x00 reserved
param[4] Concept

= 0x0A BMW EASY Nbr


param[5] Checksum
Bit 0 Checksum Generation
=0 The checksum of the telegram to be
sent must be created by the user.
=1 The checksum of the telegram to be
sent is generated by the interface
Bit 1 Checksum Verification
=0 The checksum of the received
message is checked.
=1 The checksum of the received
message is not checked.
param[6] Baud rate - low byte
param[7] - high byte
1200 up to 10400 baud
param[8] Block-Timeout - low byte
param[9] - high byte
Timing, timeout [0.1 ms] for response of the ECU.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 133 of 161

=0 65 sec timeout for response in case


of flash programming
param[10] Byte-Timeout - low byte
param[11] - high byte
Timing, inter byte time [0.1 ms] for response blocks of the
ECU.
param[12] Complement Timeout - low byte
param[13] - high byte
Timing, timeout [0.1 ms] for reception of the complement
of the wake up byte.
param[14] „Power On“ Byte - low byte
Timeout
param[15] - high byte
Timing, inter byte time [0.1 ms] for the “Power On” block
of the ECU.
param[16] Regeneration Time - low byte
param[17] - high byte
Timing, time [0.1 ms] between the response and the next
request telegram sent by the interface.
param[18] ACK Block - low byte
Regeneration Time
param[19] - high byte
Timing, regeneration time [0.1 ms] for consecutive ACK
blocks.
param[20] Inter Byte Time - low byte
param[21] - high byte
Timing, inter byte time [0.1 ms] for request blocks sent by
the interface.
param[22] Start Idle Time - low byte
param[23] - high byte
Timing, time [0.1 ms] between reception of the complement
of the wake up byte and transmission of the first byte by the
interface.
param[24] ACKCycleTime - low byte
param[25] - high byte
Timing, time [ms] between the last response block and the
transmission of an ACK block by the interface. This
parameter has to be 0 (zero) or greater than the parameter
“Regeneration Time”.

0 == No ACK Block is sent.


param[26] ACK Block Length

Length [bytes] of the ACK block defined below.

0 up to 10 bytes
param[27..36] ACK Block

Complete ACK Block without EXOR checksum. Bytes not


used have to be initialized with 0x00.

Integer parameters for the concepts


Concept 1

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 134 of 161

Concept 2 ISO 9141

Concept 3

Concept 2 DDE

Concept DS1

Concept DS2

Concept 2 Zuheizer
param[0] Concept
Concept 1 = 1
Concept 2 ISO 9141 = 2
Concept 3 = 3
Concept 2 DDE = 4
Concept DS1 = 5
Concept DS2 = 6
Concept 2 Zuheizer = 0x0E
param[1] baud rate
Evaluated with Concept 1, DS1, DS2 only
param[2] Wakeup address
Only evaluated by the interface for Concept 2, 3 and 4 but is needed for EDIABAS
param[3] Wakeup
Time in ms, 0 ms means no WakeUp
(Concept 1 only)
param[4] IdleTime
Time in ms between WakeUp and the start of the first telegram (Concept 1 with WakeUp only)
param[5] Timeout time
Time in ms in which the SG must have responded to a telegram from the interface
param[6] Regeneration time
Time in ms that must elapse after the answer from the control unit before another telegram can be
sent
param[7] Telegram end time
Time in ms by which the telegram end is decided
param[8] Byte to byte time (optional)
Byte to byte time for DS2 in ms
param[9] Checksum (optional)
Indicates how the telegram checksum must be created and checked. If nothing is specified the
checksum of the telegram to be sent is formed automatically by the interface and the checksum of the
received telegram is formed. Checksum handling is bit-coded.
Bit 0 = 0: The checksum of the telegram to be sent must be created by the user.
Bit 0 = 1: The checksum of the telegram to be sent is created by the interface (default).
Bit 1 = 0: The checksum of the received telegram is checked.
Bit 1 = 1: The checksum of the received telegram is not checked.

Long Parameters for the Concept BMW-Fast


param[0] Concept
BMW-FAST = 0x10F
param[1] baud rate
0 up to 115200 baud (= 115200 baud)
param[2] timeout
time in ms within which the control unit must have replied to a telegram from the interface (= 200
ms)

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 135 of 161

param[3] regeneration time


time in ms which must pass after the control unit response before transmission is again permitted (= 3
ms)
param[4] telegram termination time
time in ms after which a decision for telegram termination is made (= 3 ms)
param[5] number Negative response code 0x78
maximum number of Negative response code 0x78 responses of the control unit (= 2).
param[6] timeout Negative response code 0x78
time in ms within which the control unit must have responded after Negative response code 0x78 (=
5000 ms).
param[7] checksum (optional)
= 1 (default)
Information on how the telegram checksum is to be calculated and checked. If nothing is indicated,
the checksum of the telegram to be transmitted is automatically calculated by the interface and the
checksum of the received telegram is checked. Checksum handling is bit-coded.
Bit 0 = 0: The checksum of the telegram to be transmitted must be calculated by the user.
Bit 0 = 1: The checksum of the telegram to be transmitted is calculated by the interface.
Bit 1 = 0: The checksum of the received telegram is checked.
Bit 1 = 1: The checksum of the received telegram is not checked.

Long Parameters for the Concept KWP2000 BMW


param[0] Concept
KWP2000 BMW = 0x10C
param[1] baud rate
0 up to 115200 Baud (= 10400 Baud)
param[2] timeout
time in ms within which the control unit must have replied to a telegram from the interface (= 200
ms)
param[3] regeneration time
time in ms which must pass after the control unit response before transmission is again permitted (= 3
ms)
param[4] telegram termination time
time in ms after which a decision for telegram termination is made (= 3 ms)
param[5] time between bytes
time between bytes in ms (= 0 ms)
param[6] number Negative response code 0x78
maximum number of Negative response code 0x78 responses of the control unit (= 2)
param[7] timeout Negative response code 0x78
time in ms within which the control unit must have responded after Negative response code 0x78 (=
5000 ms).
param[8] TesterPresent Time
time in ms between the last control unit response and the next Tester Present telegram (= 3000 ms)
param[9] TesterPresent Telegram length
length of the TesterPresent telegram maximum 11 (= 5)
param[10]. to.
param[20] TesterPresent Telegram
TesterPresent telegram. If the telegram has less than 11 characters, the remaining characters must be
0.
param[21] StartCommunication Telegram length
length of the StartCommunication telegram maximum 11 (= 5)
param[22] to
param[32] StartCommunication Telegram
StartCommunication telegram. If the telegram has less than 11 characters, the remaining characters

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 136 of 161

must be 0.
param[33] Checksum (optional)
= 1 (default)
Information on how the telegram checksum is to be calculated and checked. If nothing is indicated,
the checksum of the telegram to be transmitted is automatically calculated by the interface and the
checksum of the received telegram is checked. Checksum handling is bit-coded.
Bit 0 = 0: The checksum of the telegram to be transmitted must be calculated by the user.
Bit 0 = 1: The checksum of the telegram to be transmitted must be calculated by the interface.
Bit 1 = 0: The checksum of the received telegram is checked.
Bit 1 = 1: The checksum of the received telegram is not checked.

Long Parameters for the Concept KWP2000 *


param[0] Concept
KWP2000 * = 0x10D
param[1] baud rate
0 up to 115200 baud (= 10400 baud)
param[2] timeout
time in ms within which the control unit must have responded to a telegram from the interface (= 200
ms)
param[3] Regeneration Time
time in ms which must pass after the control unit response before transmission is again permitted (= 3
ms)
param[4] Telegram Termination Time
time in ms after which a decision for telegram termination is made (= 3 ms)
param[5] Time Between Bytes
time between bytes in ms (= 0 ms)
param[6] Number Negative response code 0x78
Maximum number of Negative response code 0x78 responses of the control unit (= 2)
param[7] Timeout Negative response code 0x78
time in ms after Negative response code 0x78 within which the control unit must have responded (=
5000 ms)
param[8] TesterPresent Time (optional)
time between the last control unit response and the next Tester Present telegram in ms (= 3000 ms)
param[9] TesterPresent Telegram Length (Optional)
maximum length of the TesterPresent telegram 11 (= 6)
param[10]. to
param[20] TesterPresent Telegram
TesterPresent telegram. If the telegram has less than 11 characters, the remaining characters must be
0.
param[21] Checksum (optional)
= 1 (default)
Information on how the telegram checksum is to be calculated and checked. If nothing is indicated,
the checksum of the telegram to be transmitted is automatically calculated by the
interface and the checksum of the received telegram is checked. Checksum handling
is bit-coded.
Bit 0 = 0: The checksum of the telegram to be transmitted must be calculated by the user.
Bit 0 = 1: The checksum of the telegram to be transmitted is calculated by the interface.
Bit 1 = 0: The checksum of the received telegram is checked.
Bit 1 = 1: The checksum of the received telegram is not checked.

Long Parameters for the Concept KWP2000 Standard


param[0] Concept
KWP2000 Standard = 0x10B
param[1] Control unit address (0 to 0xFF)

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 137 of 161

param[2] Settings
Checksum:
Bit 0:
0: The checksum byte is not generated by the interface during transmission but must be
part of the request telegram.
1: The checksum byte is generated by the interface during transmission and may not be part
of the request telegram.
Bit 1:
0: The checksum byte is checked by the interface. A faulty checksum is considered an
error.
1: A faulty checksum is ignored.
Header Format:
Bit 2 to 4 (0,1,2,3,4)
The value must be set in any case.
The parameter determines which header is used when the header is generated by the interface.
0: CARB header
1: 1-Byte header
2: 1-byte header with length byte
3: 3-Byte header
4: 3-byte header with length byte
Addressing:
Bit 5:
0: physical addressing
1: functional addressing
TesterPresent Handling:
Bit 6:
0: The TesterPresent Request is transmitted according to the settings of TimeTesterPresent
and Tester Present Message.
1: TesterPresent is not transmitted automatically.
Reserved
Bit 7
param[3] BusyRepeatRequest repetitions (0 to 1000)
Max. number of repetitions if the control unit answers a request with
“BusyRepeatRequest“ (response code $21)
= 0: There is no repetition; the response is forwarded to the host.
<> 0: The request is repeated after P3max-5ms until either no BusyRepeatRequest is signalled
by the control unit anymore or until the maximum number of repetitions is reached.
The last response is forwarded to the host.
param[4] ErrorRepeat (0 to 1000)
Number of repetitions if a communication error occurs
= 0: There is no repetition; the error message is forwarded to the host.
<> 0: After a communication error, the communication process is repeated until either no
communication error occurs anymore or the maximum number of repetitions is
reached. If no communication error occurs anymore, the received response is
forwarded to the host; otherwise, an error message is transmitted.
param[5] P3max (10 to 65500)
Maximum waiting time between two requests; used with activated handling after ”Busy-
RepeatRequest“ (P3max-5ms) and “RequestCorrectlyReceived-ResponsePending” (P3max).
param[6] ResponsePending Repetitions (0 to 65535)
Maximum number of repetitions if the control unit answers a request with
“RequestCorrectlyReceived-ResponsePending“ (response code $78).
=0: The tester does not wait for the actual response; RequestCorrectlyReceived-
ResponsePending is forwarded as a response to the host.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 138 of 161

<> 0: After the response “RequestCorrectlyReceived-ResponsePending“, the waiting time


P3max is started. If another RequestCorrectlyReceived-ResponsePending is received
during P3max, P3max is restarted if the set number of repetitions is not yet reached.
If the control unit returns RequestCorrectly-Received-ResponsePending after the last
repetition as well, a timeout is signalled to the host.
param[7] Diagnosis Start Settings (0,1,2)
This parameter is evaluated during the Diagnosis Start service.
0: A 5-baud stimulation is carried through with the indicated control unit address. The
setting for Sync-Measurement is taken into account.
1: No stimulation is carried through; communication with the control unit begins with the
first request. The baud rate is fixed according to param[9].
2: A fast initialization via a wakeup pattern is carried through. This pattern is defined by
WUPt and WUPl. The baud rate is fixed according to param[9].
param[8] SyncMeasurement (0,1)
Only taken into account if param[7] = 0.
0: The baud rate is set according to param[9].
1: The baud rate is measured and adapted in accordance with the measurement.
param[9] Baud Rate
Set baud rate. Only effective if:
param[7]= 0 and SyncMeasurement = 1
or if:
param[7]<>0.
Recommended setting: 10416 b
param[10] W0 (5 to 6550 ms)
Waiting time before the communication is initialized (initialization according to the setting of param
[7], diagnosis start settings).
Recommended setting: 300ms
param[11] W1 (0 to 6550 ms)
Timeout: time between the end of the 5-baud stimulation address and the sync byte.
Recommended setting: 300ms
param[12] W2 (0 to 6550 ms)
Timeout: time between the end of the sync byte and the first key byte.
Recommended setting: 20ms
param[13] W3 (0 to 6550 ms)
Timeout: time between the end of the first key byte and the second key byte.
Recommended setting: 20ms
param[14] W4a (2 to 6550 ms)
Time between the second key byte from the control unit and the second key byte inverted by the
tester.
Recommended setting: 40ms
param[15] W4 (0 to 6550 ms)
Timeout: time between the inverted second key byte from the tester and the inverted address from
the control unit.
Recommended setting: 50ms
param[16] W5 (1 to 6550 ms)
Time before the tester starts stimulation after a communication error.
Recommended setting: 5000ms
param[17] P1 (0 to 6550 ms)
Timeout: time between individual bytes to be respected by the control unit within a response.
Recommended setting: 20ms
param[18] P2 (0 to 6550 ms)
Timeout: inter message timeout between tester request and control unit response or between two
control unit responses.
Recommended setting: 50ms

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 139 of 161

param[19] P3 (0 to 6550 ms)


Time between the control unit response and the next tester request.
P3<P2: only with a physical request and DataSegmentation switched off; otherwise, the tester waits
at least for P2.
Recommended setting: 55ms
param[20] P4 (0 to 3200 ms)
Interbyte time to be respected by the tester when sending a request.
Value 0 ... 0x7FFF: P4 in ms
Value 0x8000 ... 0xFFFF: P4 in 0,1 ms
0x8000 == 0 corresponds to no interbyte time
Recommended setting: 10ms
param[21] P3* (1 to 6550 ms)
Entry time when sending a request during periodic transmission
Recommended setting: P2min-5ms = 5..20ms
param[22] Time Tester Present (0 to 6550 ms)
If this time has passed after the last control unit response and the host has not sent a new transmission
request to the control unit, the TesterPresent request defined below is transmitted.
TimeTesterPresent >= P3
is always true.
In addition, the restrictions concerning P2 and P3 must be taken into account.
Recommended setting: 4000ms
param[23] Length of the TesterPresent Message (0 to 11)
0: The last tester request is used to maintain the connection.
1-11: Length of the request to be transmitted for maintaining the connection, including
checksum.
param[24] to
param[34] Characters of the Tester Present Message
If the TesterPresent message has less than 11 characters, the remaining characters must have the
value 0.
The checksum must always be indicated, independently of the setting for checksum generation
(param[2]).
The recommended setting depends on the header format (1-,2-,3-,4-byte header).
Example of a 3-byte header (physical addressing):
81H, <phys. control unit address>,<tester address>, 3EH,
<8-bit addition checksum>,
00H,00H,00H,00H,00H,00H
param[35] WUPt (15 to 65535)
Total duration of the wakeup pattern during fast initialization
Unit: 100µs
Recommended setting: 500
param[36] WUPl (15 to 65535)
Duration of the low level within the wakeup pattern. When TWupLow is over, the system waits for
TWupGes-TWupLow with the high level.
Unit: 100µs
Recommended setting: 250
param[37] Length of the StartCommunication Message (0 to 11)
Length of the telegram to be sent directly after the wakeup pattern
0: No StartCommunication request is transmitted. The wakeup pattern is followed directly
by the first request.
1-11: Length of the request to be transmitted for establishing the connection, including
checksum
Recommended setting: 5

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 140 of 161

param[38] to
param[48] Characters of the StartCommunication Message
Characters of the StartCommunication message. If the telegram has less than 11 characters, the
remaining characters must have the value 0.
The checksum must always be indicated, independently of the setting for checksum generation
(param[2]).
Example of physical addressing:
81H, <phys. control unit address>,<tester address>, 81H,
<8-bit addition checksum>,
00H,00H,00H,00H,00H,00H
param[49] Settings (0,1)
0: Acceptance of all parameters from SetECUPars. If SetECUPars is transmitted during
ongoing control unit communication, communication is interrupted and then re-
established.
1: Acceptance of all parameters relevant during ongoing communication
param[50] Settings
Arbitration Handling
Bit 0:
Arbitration handling (only with functional addressing)
0: Arbitration handling switched off. In case of transmission errors during response
reception, the tester does not wait whether the control units repeat transmission.
1: Arbitration handling activated. In case of transmission errors during response reception,
the tester waits for TimeArbitrationIdle until the reception is restarted.
5Baud Address Parity
Bit 1 and Bit 2 (0,1,2)
Setting the parity bit in the 5-baud stimulation address
0: The 5-baud address is transmitted without alteration (data format 8N1).
1: In the 5-baud address, the 8th bit (MSB) has odd parity (data format 7O1).
2: In the 5-baud address, the 8th bit (MSB) has even parity (data format 7E1).
DataSegmentation
Bit 3
DataSegmentation handling (only with physical addressing of the request). With functional request
addressing, all responses will be received.
0: DataSegmentation handling activated. After the reception of each response, P2 is
started. If no additional response is received during P2, all responses to the
transmitted request have been received and will be signalled to the host.
1: DataSegmentation handling deactivated. After reception of the first response, P3 is
started immediately instead of P2. The tester does not wait for additional responses
but the received response is signaled to the host.
TesterPresent Handling
Bit 4
Setting the behaviour in case of communication errors during Tester Present
0: Error or timeout during reception of the response(s) are ignored; communication with
the control unit is not interrupted.
1: In case of errors or timeout during reception of the response(s), communication with the
control unit is interrupted and will be re-established during the next request by the
host.
Recommended setting: 0
Header Generation
Bit 5
0: The header is not generated by the interface but the data in the command SendTelegram
must contain the entire header information.
1: The header is generated by the interface. The data in the command SendTelegram may
not contain any header information.
Recommended setting: 0

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 141 of 161

Baud rate Highbits


Bit 6 and Bit 7
Most significant bits of the baud rate
Example: The baud rate is 128000 (0x1F400) baud
param[9] = 62464 (0xF400)
bit 6 = 1, bit 7 = 0
param[51] ArbitrationIdle Time (1 to 6500 ms)
Time which passes after an arbitration until a useful bit on the bus is interpreted as the beginning of a
new message. If, after an arbitration error, more useful bits are received before the
TimeTesterArbitration has passed, the time is restarted. If arbitration takes place because of a
timeout (P1), the Time ArbitrationIdle is corrected, if possible. The following dependencies apply:
P1 >= TimeArbitrationIdle: TimeArbitrationIdle is
1ms, i.e. after P1, the tester waits for 1ms
P1 < TimeArbitrationIdle: TimeArbitrationIdle is used
as set.
Recommended setting:
P1max < TimeArbitrationIdle < P2min (21ms)
param[52] reserved
param[53] reserved
param[54] reserved
param[55] reserved
param[56] Tester Address
The tester address is used if the header is generated by the interface.
param[57] reserved
param[58] reserved
param[59] reserved

Long Parameters for the Concept BMW DCAN


param[0] Concept
BMW DCAN = 0x110
param[1] Baud Rate
param[2] Timing Bs [ms]
Timeout for reception of a Flow Control Frame after transmission of a First Frame or Consecutive
Frame.
param[3] Timing Br [ms]
Time between reception of a First or Consecutive Frame and transmission of the next Flow Control
Frame.
param[4] Timing Cs [ms]
Time between reception of a Flow Control Frame and transmission of the next Consecutive Frame.
param[5] Timing Cr [ms]
Timeout for reception of the first Consecutive Frame after transmission of a Flow Control Frame.
param[6] Timing Dr [ms]
Timeout for reception of Consecutive Frames.
param[7] Timing P2max [ms]
Timeout for start of the response of the ECU.
param[8] Timing P3min [ms]
Time between reception of the last response and transmission of a new request.
param[9] Timing P2* [ms]
Extended Timeout for reception of responses in case of reception of a negative response with NRC
0x78.
param[10] Maximum number of negative responses with NRC 0x78. If the maximum number of negative
responses with NRC 0x78 is reached the next received negative response is reported to the host

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 142 of 161

application.
param[11] Timing Es [ms]
Timeout for reception of a Flow Control Frame after reception of a Flow Control:WAIT Frame.
param[12] Timing Er [ms]
Time to wait before transmission of a Flow Control:Wait Frame.
param[13] Maximum number of Flow Control:Wait Frames received from an ECU.
param[14] Timing STminUsedByInterface [ms]
0x00 – 0x7F: 0 to 127 ms
0x80-0xF0: 127 ms
0xF1-0xF9: 100 to 900 µs
0xFA-0xFF: 127 ms
Fix value for the interface to use as wait time between the transmission of Consecutive Frames. This
parameter is only used in case param[15] == 1.
param[15] STmin Handling
= 0: The value STmin from the received Flow Control Frame from the ECU is used.
= 1: The value specified by “STminUsedByInterface” (param[14]) is used.
param[16] Timing TesterPresent [ms]
= 0: The interface does not send TesterPresent messages automatically.
> 0: The interface sends TesterPresent messages at intervals specified by this parameter
param[17] Length of the TesterPresent message defined below
0 to 11 Bytes
param[18] to
param[28] TesterPresent message. Bytes not used have to be initialized with 0x00.
param[29] TesterPresent Response Handling
= 0: No response expected.
= 1: Response expected.

Furthermore the concepts below are reserved:


0x30 = PMode-Protokoll (Continental)
0x0115 = None (no longer in use)
0x0120 = ISO9141UX (BMW motorbike)
0x0121 = KBUS (BMW motorbike)

Return value -

See also set_answer_length

Example unsigned int parameter[] = {1, 9600, 0x0D, 0, 0, 500, 100, 500};

set_communication_pars(parameter);

// parameters are forwarded to EDIC


unsigned char parameter[] = {0x00, 0xff, 0x00, 0x00, ...};

set_communication_pars(parameter);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

set_program_voltage

Summary Sets the programming voltage

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 143 of 161

void set_program_voltage(int voltage)

voltage Programming voltage in millivolts

Remarks This function switches the programming voltage on and off. The programming voltage level is specified
in millivolts (0 - 33000 mV). Voltage = 0 Volts means programming voltage is "off".

Return value -

See also -

Example set_program_voltage(12000); /* Voltage to 12 volts */

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

set_repeat_counter

Summary Sets the number of repeats for control unit communication

void set_repeat_counter(long count)

count Number of repeats

Remarks If an error occurs during control unit communication (IFH_0010 or IFH_0009) the communication
command to the interface handler is automatically repeated. The number of repeats can be set with
the set_repeat_counter function. 2 is default.

Return value -

See also open_communication, close_communication, set_communication_pars, set_answer_length,


send_and_receive, send_frequent, recv_frequent, recv_keybytes

Example {

/* fast decision whether CU is there */

set_repeat_counter(0); // no repeat

send_and_receive(...)

/* wait till CU is there */

set_repeat_counter(10000); // 10000 repeats

send_and_receive(...)

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

set_trap_mask

Summary Sets the trap mask register

long set_trap_mask(long mask)

mask Trap mask

Remarks The trap mask register decides which error messages will be reported to the runtime system and which
will be evaluated by the description file. A bit is reserved in the trap mask register for some error
messages. If this bit is 0, the error is reported to the runtime system. If it is 1 then the error can be

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 144 of 161

evaluated in the description file with get_error. set_trap_mask sets all bits of the trap mask register with the bit pattern of the
parameter mask at the same time. The default for all bits is 0, and the original status can be restored
at any time using set_trap_mask(0).

Trap mask: Mask = 2^(Trapbit0) + 2^(Trapbit1) + ...


Trapbit in Error number and Constant Trap-number
Register[1] f. get_error
error description [4]
BIT 00 ---------undefined---------- -- --
BIT 01 reserved -- --
BIT 02 BIP_0002: IFH call failed 0x00000004 02
BIT 03 reserved -- --
BIT 04 reserved --
BIT 05 reserved --
BIT 06 BIP_0006: User File error 0x00000040 06
BIT 07 reserved -- --
BIT 08 reserved -- --
BIT 09 BIP_0009: Version error 0x00000200 09
BIT 10 BIP-0010: Error during constant access 0x00000400 10
BIT 11 IFH_0001: Error at host interface 0x00000800 11
BIT 12 IFH_0002: Interface does not logon 0x00001000 12
BIT 13 IFH_0003: Data transfer to interface fault 0x00002000 13
BIT 14 IFH_0004: Command to interface fault 0x00004000 14
BIT 15 IFH_0005: Interface internal error (defect) 0x00008000 15
BIT 16 IFH_0006: Interface does not accept command 0x00010000 16
BIT 17 IFH_0007: Wrong supply voltage at D-bus 0x00020000 17
BIT 18 IFH_0008: Fault at interface to control unit 0x00040000 18
BIT 19 IFH_0009: Control unit does not respond 0x00080000 19
BIT 20 IFH_0010: Data transfer interface-CU failed 0x00100000 20
BIT 21 IFH_0011: Unknown interface 0x00200000 21
BIT 22 IFH_0012: Data buffer overflow 0x00400000 22
BIT 23 IFH_0013: Function not available in interface 0x00800000 23
BIT 24 IFH_0014: Concept is not supported 0x01000000 24
BIT 25 IFH_0015: Ubatt was interrupted briefly 0x02000000 25
BIT 26 IFH_0016: Ignition was switched 0x04000000 26
BIT 27 reserved -- --
BIT 28-31 reserved -- --

Table 1: Breakdown of trap mask register and corresponding trap numbers.

Return value The value of the trap mask register before it is called

See also geterror, get_trap_mask

Example {

set_trap_mask(0x00180000);

send_and_receive(.....);

if(get_error(19))

job_status="DIAGNOSE-FEHLER";

else

job_status="OKAY";

Result job_status = "DIAGNOSE-FEHLER" // if CU does not answer.

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

set_variable_result

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 145 of 161

Summary Output variable results

void set_variable_result(char ResultName[], long Resulttyp,


long longErg, real realErg, char stringErg[], unsigned char dataErg[])

ResultName Name of the result

Resulttyp Type of result:

1: long

2: real

3: string

4: data

longErg Result value when result type = 1

realErg Result value when result type = 2

stringErg Result value when result type = 3

dataErg Result value when result type = 4

Remarks This function can be used to return a variable result independent of the job sequence. The result name
and the result type must not be defined in the job header; it is determined only at runtime.

Return value -

See also var_result_long, var_result_real, var_result_string, var_result_data

Example {

char value[]="My result value";

unsigned char y[];

real x;

set_variable_result("RESULT",3,0,x,value,y);

Result Corresponds to RESULT = "My result value"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

setProgressRange

Summary Defines a progress range from 0 to range

void setProgressRange(long range)

range Value of the progress range

Remarks This function specifies a progress range. The current progress position can vary in this range. The
progress position is still undefined after called setProgressRange. It must subsequently be initialized
with incProgressPos. If the progress position exceeds the progress range, it is automatically
shortened to the maximum value.

Return value -

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 146 of 161

See also incProgressPos

Example

setProgressRange(500);

incProgressPos(0); // Start with 0 percent

incProgressPos(100); // 20 percent

: // processed

incProgressPos(300); // 80 percent

: // processed

incProgressPos(200); // 100 percent

// processed

///////////////////////////////////////////////////

// Within the ENDE-Job

setProgressRange(0); // Reset

// processing mode

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

shdataget

Summary Copies the contents of the global data memory into a destination buffer.

long shdataget(char id[], unsigned char destin[])

id ID of the global data memory

destin Destination buffer (V)

Remarks This function copies the entire contents of the global data memory into the destination buffer. The
destination buffer is cleared prior to copying the contents. The ID (name) of the data memory is an
Asciiz string (C-string) which has a maximum of 32 characters. Even an empty string is a valid ID. If
an empty string is used as ID, the contents of the data memory are always copied into the destination
buffer. Otherwise only the data memory is copied when the same ID has been used for the filling.

Return value TRUE (1) if the global data memory has been found and the contents have been copied.
FALSE (0) if the global data memory has not been found and the contents have not been copied.

See also shdataset

Example unsigned char local[];

shdataget("myID",local);

Result -

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 147 of 161

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

shdataset

Summary Fills the global data memory with the contents of the source buffer.

void shdataset(char id[], unsigned char source[])

id ID of the global data memory

source Source buffer

Remarks This function copies the entire contents of the destination buffer into the global data memory. The global
data memory is cleared prior to copying the contents. The ID (name) of the data memory is an Asciiz
string (C-string) with a maximum length of 32 characters. Even an empty string is a valid name.
When the data memory is subsequently read, either the passed ID or an empty string must be used.

The source buffer must not contain more than 1023 characters, otherwise the call will cause a runtime
error BIP_0001.

Return value -

See also shdataget

Example unsigned char source[];

shdataset("myID",source);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

stop_frequent

Summary Terminates the frequent mode

void stop_frequent()

Remarks This function terminates the repeat sending and receiving of telegrams.

Return value -

See also send_frequent, recv_frequent

Example -

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

strcat

Summary Appends one string to another

void strcat(char destin[],char source[])

destin Target string to which the source string is to be appended (V)

source Source string to be appended

Remarks The strcat function appends the string source to the existing zero-terminated string destin. Only so many
characters are appended so that destin including the zero character can fit in a string register, i.e.
maximum string register size – 1 characters. Both strings can have the length 0. The source string is
not changed.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 148 of 161

Return value -

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

char destin[]="01234";

char source[]="56789";

strcat(destin,source);

Result destin="0123456789" , source="56789"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

strcmp

Summary Compares two strings

long strcmp(char s1[],char s2[])

s1 String1 (V)

s2 String2

Remarks This function compares the two strings s1 and s2. If both strings are the same length and identical in all
characters, then the system decides they are equal, otherwise not equal.

Return value 0 when both strings are equal, <> 0 if not.

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

int x; int y; int z;

char s1[]="ABC";

x=strcmp(s1,"ABC");

y=strcmp(s1,"ABCD");

z=strcmp(s1,"abc");

Result x=0, y=1, z=1

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

strcpy

Summary Copies a string

void strcpy(char destin[],char source[])

destin String to which another is to be copied (V)

source String to be copied

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 149 of 161

Remarks strcpy copies the string source to destin. All characters of source up to the zero character are copied.
The target string destin is cleared first.

Return value -

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

char destin[]="ABC";

strcpy(destin,"XD");

Result destin= "XD"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

strcut

Summary Shortens a string

void strcut(char s[],int count)

s String to be shortened (V)

count Number of characters to be shortened

Remarks strcut shortens string s by count characters. The string cannot be less than 0 characters long.

Return value -

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

char buffer[]="ABCDF";

strcut(buffer,3);

Result buffer = "AB"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

strerase

Summary Erases characters in a string

void strerase(char s[],int pos,int count)

s String to be edited (V)

pos Position from which characters are to be erased

count Number of characters to be erased

Remarks strerase erases any desired number of characters from a string. The remaining parts of the string are
joined together. count characters are erased from position pos. The operation stops when the string
end is reached, leaving just the string up to pos.

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 150 of 161

Return value -

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

char buffer[]="ABCDEFGHIJKLM";

strerase(buffer,3,3);

Result buffer="ABCGHIJKLM"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

strinsert

Summary Inserts characters into a string

void strinsert(char destin[],char source[],long pos)

destin String to be edited

source String to be inserted

pos Position from which characters are to be inserted

Remarks strinsert inserts the string source into the string destin. The characters are inserted from position pos. If
the string destin is longer than a string register, i.e. string register size - 1 characters, the rest is cut
off.

Return value -

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

char buffer[]="ABCGHIJKLM";

strinsert(buffer,"DEF",3);

Result buffer = "ABCDEFGHIJKLM"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

strlen

Summary Identifies the length of a string

long strlen(char string[])

string String whose length is to be identified

Remarks strlen identifies the length of a string. The length of a string is the number of characters it contains,
except the terminating zero.

Return value The length of the string (0 .. string register size - 1)

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 151 of 161

char string[]="ABCDEF"

long x;

x=strlen(string);

Result x=6

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

strncpy

Summary Copies a number of characters from a string

void strncpy(char destin[], char source[], int count)

destin String to which another is to be copied (V)

source String to be copied

count Maximum number of characters to be copied

Remarks strncpy copies the string source to destin. If the string destin is longer than count, then only the first
count characters are copied. The target string is not cleared.

Return value -

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

char destin[]="ABCDEFGH";

strncpy(destin,"XYZABCDEF",3);

Result destin= "XYZDEFGH"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

strrevers

Summary Reverses a string

void strrevers(char string[])

string String to be reversed

Remarks strrevers turns the string round, i.e. the last character become the first and so on.

Return value -

See also get_token, strcat, strcmp, strcpy, strcut, strerase, strinsert, strlen, strncpy, strrevers

Example {

char destin[]="ABCDEFGH";

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 152 of 161

strrevers(destin);

Result destin = "HGFEDCBA"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

switch_channel

Summary Switches the active communication channel to the interface driver

void switch_channel(long channel)

channel Identifier of the interface channel to switch to

Remarks This function switches to the interface channel, which was given by channel and previously opened by
open_channel. The given interface channel becomes the active channel.

Return value -

See also open_channel

Example long channel;

channel=open_channel(0);

switch_channel(channel);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

tab_suche_index

Summary Searches in a table column for a value with the form 0x##

long tab_suche_index(char column[], char value)

column Column where the value will be searched

value Value to be searched

Remarks The function tab_suche_index converts value to a string with the form "0x##" and searches for it in the
column column. The search always begins with the second table line. If the search is successful the
function returns TRUE (<>0), otherwise FALSE (0). If the value is found, then the read pointer for
the table is on the line with the found value, if not it is on the last line in the table (important for
default values). The elements of this line can now be read using tabget. If the column does not exist
the error BIP_0010 (constant data access error) [4] is returned.

Return value TRUE when value is found, otherwise FALSE

See also tab_suche_unsigned, tabget, tabset, tabsetext

Example table TST[3][]={

{ "NAME", "VALUE", "NUMBER" },

{ "ONE", "1000", "0x00" },

{ "TWO", "2000", "0x03" }}

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 153 of 161

char buffer[];

tabset("TST");

tab_suche_index("NUMBER",3);

tabget(buffer,"NAME");

Result buffer = "TWO"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

tab_suche_unsigned

Summary Searches a table column for a predefined unsigned value

long tab_suche_unsigned(char column[], unsigned long value)

column column in which the value is to be searched

value unsigned-long value to be searched

Remarks The function tab_suche_unsigned searches the unsigned value in the column. As value, an unsigned
value must be passed; otherwise, an internal arithmetical conversion (if necessary, with sign
extension) is carried through. The table elements of the column are internally converted into
numerical values and compared with the unsigned-long value. If a table element starts with the
characters "0x" or "0X", it is interpreted as a hexadecimal number. In all other cases, the table
element is interpreted as a decimal number. The searching process always starts in the second table
row. After a successful search, the function returns TRUE (<>0); otherwise, FALSE (0). If the value
was found, the reading pointer for the table points to the line where the value is located; if not, it
points to the last table row (this is important for default values). The elements in this row can then be
read out with tabget. If the column does not exist, the error BIP_0010 (Constant Data Access Error)
[4] is triggered.

Return value TRUE if the value was found; otherwise, FALSE

See also tab_suche_index, tabget, tabset, tabsetext

Example table TST[3][]={

{ "NAME", "WERT", "NUMMER" },

{ "A", "0", "0x0000" },

{ "B", "768", "0x0300" }}

char buffer[];

unsigned long index;

tabset("TST");

index=0x300;

tab_suche_unsigned("NUMMER",index);

tabget(buffer,"NAME");

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 154 of 161

Result buffer = "B"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

tab2fix

Summary Reads the values from the current table line and converts them into a number

void tab2fix(long value, char column[])

value Value from the table changed to a number (V)

column Column in the table from which the value is taken

Remarks The function tab2fix reads a value from the current table line defined with tabseek or tab_suche_index
and converts it into a number. The text of column indicates from which column the value must be
taken. If the column does not exist the error BIP_0010 (constant data access error)[4] is returned.

Return value -

See also tabget, tab_suche_index, tabseek, tabset, tabsetext

Example int errorNo = 0x11;


unsigned long uw1;

tabset("FUmweltMatrix");
tab_suche_index("ORT", errorNo)
tab2fix(uw1, "UW1_NR");

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

tabcolumns

Summary Determines the column count of the current table

long tabcolumns()

Remarks The function tabcolumns determines the number of the columns of the current table. The table
processing must have been initialized previously by tabset or tabsetext (otherwise a count of 0 will
be returned).

Return value column count

See also tabset, tabsetext, tabrows

Example table TST[2][]={

{ "NAME", "WERT" },

{ "EINS", "1000" },

{ "ZWEI", "2000" }};

long n;

tabset("TST");

n=tabcolumns(); // n = 2

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 155 of 161

tabget

Summary Reads the values from the current table line

void tabget(char destin[],char column[])

destin String buffer to take the value (V)

column Column from which the value is taken

Remarks tabget reads a value from the current table line defined with tabseek or tab_suche_index. The value of
column indicates from which column value must be taken. If the column does not exist the error
BIP_0010 (constant data access error) [4] is returned.

Return value -

See also tab_suche_index, tabseek, tabset, tabsetext

Example see tabset

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

tabline

Summary Positions the read pointer on the specified line

long tabline(long line)

line Line number in the table (first line is 0)

Remarks tabline positions the read pointer on the specified line. The first line is numbered 0. If there is a line
which the number matches, the function return TRUE (!0), otherwise FALSE (0). If there is no line
which the number matches, the pointer is on the last line in the table (important for default values).
The elements of this line can now be read using tabget.

Return value TRUE when the line exists, otherwise FALSE

See also tab_suche_index, tabseek, tabset, tabsetext

Example see tabseek

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

tabrows

Summary Determines the row count of the current table

long tabrows()

Remarks The function tabrows determines the number of the rows (including header) of the current table. The
table processing must have been initialized previously by tabset or tabsetext (otherwise a count of 0
will be returned).

Return value row count

See also tabset, tabsetext, tabcolumns

Example table TST[2][]={

{ "NAME", "WERT" },

{ "EINS", "1000" },

{ "ZWEI", "2000" }};

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 156 of 161

long n;

tabset("TST");

n=tabrows(); // n = 3

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

tabseek

Summary Searches in a table column for a value

long tabseek(char column[], char value[])

column Column where the value will be searched

value Value to be searched

Remarks The function tabseek searches for the string value in the column column. The search always begins with
the second table line. If the search is successful the function returns TRUE (!0), otherwise FALSE
(0). If the value is found, then the read pointer for the table is on the line with the found value, if not
it is on the last line in the table (important for default values). The elements of this line can now be
read using tabget. If the column does not exist the error BIP_0010 (constant data access error) [4] is
returned.

Return value TRUE when value is found, otherwise FALSE

See also tab_suche_index, tabget, tabset, tabsetext

Example see tabset

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

tabset

Summary Sets and resets table processing

void tabset(char tabname[])

tabname Name of table you wish to work with

Remarks Tables are constant two-dimensional arrays of strings. The values in the first line name the columns. A
value can be searched in each column (tabseek, tab_suche_index). Each column can be read out of
the line in which the value was found (tabget). Table processing must be initialized, and this is done
with tabset which sets processing to a certain table. The name of the table must be defined as a
string. After tabset, tabseek or tab_suche_index must be called first before tabget can be used. If
the table does not exist the error BIP_0010 (constant data access error) [4] is returned.
Return value -
See also tab_suche_index, tabget, tabseek, tabset, tabsetext

Example table TST[3][]={

{ "NAME", "VALUE", "NUMBER"},

{ "ONE", "1000", "0" },

{ "TWO", "2000", "3" }};

char buffer[];

tabset("TST");

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 157 of 161

tabseek("NAME","ONE");

tabget(buffer,"NUMBER"); // buffer = "0"

tabget(buffer,"VALUE"); // buffer = "1000"

tabseek("NUMBER","3");

tabget(buffer,"NAME"); // buffer = "TWO"

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

tabsetext

Summary Set and reset of table handling.

void tabsetext(char tabfile[],char tabname[])

tabfile name of ECU description file with table tabname

tabname Name of table you wish to work with

Remarks Tables are constant two-dimensional arrays of strings. The values in the first line name the columns.
Table processing must be initialized, and this is done with tabset which sets processing to a certain
table. Is the table located in a different SGBD tabsetext has to be used. The parameters determine the
name of the SGBD and the name of the table. If the table resides in the same SGBD set an empty
string for tabfile (same functionality as tabset).

The search for tabfile starts in ECU directory, first for a variant SGBD. If it fails, a group SGBD is
searched for.

After tabsetext, tabseek or tab_suche_index must be called first before tabget can be used. A value can
be searched in each column (tabseek, tab_suche_index). Each column can be read out of the line in
which the value was found (tabget). The function call of tabsetext and the function calls for table
access have to be in the same job.
Return value -
See also tab_suche_index, tabget, tabseek, tabset
Example tabsetext("file","TST"); // file.prg/grp
Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

uitoad

Summary Convert an unsigned integer number to a string in decimal notation.

void uitoad(char destin[],unsigned long value)

destin Buffer to take the string (V)

value Number to be converted

Remarks uitoad converts the number value to a string with decimal notation without a sign. No leading zeroes are
output.

Return value -

See also itoad, atoi, atoy, bcd2ascii, hex2ascii, itoax, ascii2hex

Example {

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 158 of 161

char destin[];

uitoad(destin,4294967295);

...

Result destin="4294967295"

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

updateInfo

Summary Produces a string result during job processing

void updateInfo(char string[])

string String to be taken as result (V)

Remarks This function produces a string result which already can be interrogated as the job is being processed.

Return value -

See also -

Example updateInfo(”Job is running...”);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

userbreak

Summary Produces an error message "BIP-0008: BEST BREAK"

void userbreak()

Remarks The function produces the error message "BIP-0008: BEST BREAK".

Return value -

See also make_error

Example userbreak();

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

var_result_data

Summary Produces a data result not defined in the job header.

void var_result_data(char name[], char value[])

name Name of the result

value Value of the data result

Remarks The function produces a data result with the result name name and the value value. The result name
name is determined first at runtime.

Return value -

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 159 of 161

See also set_variable_result, var_result_long, var_result_real, var_result_string

Example char resultname[] = "X";

char resultvalue[] = { 0x12, 0x34, 0xFF };

var_result_data(resultname,resultvalue);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

var_result_long

Summary Produces a long result not defined in the job header.

void var_result_long(char name[], long value)

name Name of the result

value Value of the long result

Remarks The function produces a long result with the result name name and the value value. The result name
name is determined first at runtime.

Return value -

See also set_variable_result, var_result_data, var_result_real, var_result_string

Example char resultname[] = "X";

long resultvalue = 0x10;

var_result_long(resultname,resultvalue);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

var_result_real

Summary Produces a real result not defined in the job header.

void var_result_real(char name[], real value)

name Name of the result

value Value of the real result

Remarks The function produces a real result with the result name name and the value value. The result name name
is determined first at runtime.

Return value -

See also set_variable_result, var_result_data, var_result_long, var_result_string

Example char resultname[] = "X";

real resultvalue;

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 160 of 161

ator(resultvalue,"1.23");

var_result_real(resultname,resultvalue);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

var_result_string

Summary Produces a string result not defined in the job header.

void var_result_string(char name[], char value[])

name Name of the result

value Value of the string result

Remarks The function produces a string result with the result name name and the value value. The result name
name is determined first at runtime.

The value of the string result mustn’t contain more than 1023 characters, otherwise the call will cause a
runtime error BIP_0001.

Return value -

See also set_variable_result, var_result_data, var_result_long, var_result_real

Example char resultname[] = "X";

char resultvalue[] = "ABC";

var_result_string(resultname,resultvalue);

Result -

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

wait

Summary Wait n seconds

void wait(long time)

time Waiting time in second

Remarks The wait function waits time seconds. wait waits for a maximum of time seconds and a minimum of
time-1 seconds. If time = 0, there is no waiting.

Return value -

See also getasciidate, getasciitime, getdate, getdate

Example {

wait(1);

Result waits 1 second

EDIABAS BEST Developer's Guide > BEST/2 Function Primer > 5. Library functions

waitex

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020
EDIABAS BEST Developer's Guide Page 161 of 161

Summary Waits n milliseconds

void waitex(unsigned long time)

time Waiting time in millisecond

Remarks The waitex function waits time milliseconds. If time = 0, there is no waiting. The precision depends on
the operating system.
Under Win16 waitex is based on an internal counter which can overrun after 2^32 milliseconds after
system start. In case of a counter overrun waitex is cancelled.

Return value TRUE end of waiting time


FALSE counter overrun

See also gettickcount, getasciidate, getasciitime, getdate, getdate

Example {

waitex(1000);

Result waits 1 second

EDIABAS BEST Developer's Guide > BEST/2 Function Primer

LIST OF REFERENCES
[1] EDIABAS: BEST/1 Language and Interpreter

[2] EDIABAS: BEST/2 Language Description

[3] EDIABAS: API Interface Description

[4] EDIABAS: Error Reference

file:///C:/Users/sgtma/AppData/Local/Temp/~hhF948.htm 7/16/2020

You might also like