EDIABAS
Electronic Diagnostic Basic System
VERSION 6d
BEST2RTL.DOC
EDIABAS - BEST/2 FUNCTION PRIMER
CONTENTS
CONTENTS 2
1. Revision history 8
2. Introduction 9
2.1. About the Runtime Library 9
2.2. Conventions 10
2.3. Special features, definitions, acronyms 11
3. Overview 12
3.1. Using the runtime library 12
3.1.1. Calling library functions 12
3.1.2. Paths and filenames 12
3.2. Functions of the runtime library by categories 13
3.2.1. Communication functions 14
3.2.2. Interface functions 15
3.2.3. Result and parameter management 16
3.2.4. String functions 17
3.2.5. Conversion functions 18
3.2.6. Real functions 19
3.2.7. Data functions 20
3.2.8. File functions 21
3.2.9. Sequence control 22
3.2.10. Error handling 23
3.2.11. Time handling 24
3.2.12. Table handling 25
3.2.13. Configuration 26
3.2.14. Control unit specific functions 27
4. Clamp states 28
2
EDIABAS - BEST/2 FUNCTION PRIMER
4. Library functions 31
4.1. Using the function primer 31
ascii2ascii 33
ascii2hex 34
atoi 35
ator 36
atoy 37
bcd2ascii 38
bittest 39
bytetest 40
callPlugIn 41
clear_error 43
close_communication 44
datacat 46
dataclear 47
datacmp 48
datacopy 49
dataerase 50
datainsert 51
datalen 52
datarevers 53
dataset 54
doNewInit 55
enableIfhTrace 56
enableIgnitionHandling 57
enableUbattHandling 58
fclose 59
fopen 60
fread 61
freadln 62
fseek 63
3
EDIABAS - BEST/2 FUNCTION PRIMER
fseekln 64
ftell 65
ftellln 66
get_battery_voltage 68
get_error 69
get_error2 70
get_ignition_voltage 71
get_trap_mask 74
generateRunError 75
getasciidate 76
getasciitime 77
getCfgString 79
getdate 80
getETXblock 81
gettickcount 84
gettime 85
hex2ascii 86
ifboot 87
ifgetport 88
ifinfo 89
ifloopt 91
ifrawmode 92
ifrecv 93
ifrequeststate 94
ifreset 95
ifsend 96
ifsetport 97
ifsireset 98
iftype 99
ifvers 100
incProgressPos 101
4
EDIABAS - BEST/2 FUNCTION PRIMER
isDebugLevel 102
isSimulation 103
itoad 104
itoax 105
itor 106
make_error 108
new_set_of_results 109
open_communication 110
parcount 111
realadd 113
realdiv 115
realmul 116
realresult 117
realsub 118
recv_frequent 119
recv_keybytes 120
rtoa 121
rtoi 122
send_and_receive 123
send_frequent 124
set_answer_length 125
set_communication_pars 128
set_program_voltage 146
set_repeat_counter 147
set_trap_mask 148
set_variable_result 151
setProgressRange 152
shdataget 153
shdataset 154
stop_frequent 155
strcat 156
5
EDIABAS - BEST/2 FUNCTION PRIMER
strcmp 157
strcpy 158
strcut 159
strerase 160
strinsert 161
strlen 162
strncpy 163
strrevers 164
tab2fix 165
tab_suche_index 166
tabget 169
tabline 170
tabseek 171
tabset 172
tabsetext 173
updateInfo 175
userbreak 176
var_result_data 177
var_result_long 178
var_result_real 179
var_result_string 180
wait 181
waitex 182
6
EDIABAS - BEST/2 FUNCTION PRIMER
7
EDIABAS - 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
8
EDIABAS - BEST/2 FUNCTION PRIMER
2. Introduction
This runtime library is very important because it provides facilities which the
rudimentary BEST/2 language does not have.
9
EDIABAS - BEST/2 FUNCTION PRIMER
2.2. Conventions
Example Description
SAMPLE.C 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
argument } characterize entries from 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.
10
EDIABAS - BEST/2 FUNCTION PRIMER
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.
11
EDIABAS - BEST/2 FUNCTION PRIMER
3. Overview
This job identifies the current date by means of the getasciidate function and writes it
to the variable buffer.
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.
12
EDIABAS - BEST/2 FUNCTION PRIMER
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
13
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
14
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
15
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
16
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
17
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
18
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
19
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
20
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
21
EDIABAS - BEST/2 FUNCTION PRIMER
This function enables access in the job sequence control; i.e., when and in which
order standard jobs are called.
Function Purpose
22
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
23
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
24
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
25
EDIABAS - BEST/2 FUNCTION PRIMER
3.2.13. Configuration
These functions are used to set and read the EDIABAS configuration.
Function Purpose
26
EDIABAS - BEST/2 FUNCTION PRIMER
Function Purpose
27
EDIABAS - 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 EDIC 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
communicaiton aborted (and the terminal states reset) as response to this.
The system results IGNITIONCURRENT; UBATTCURRENT; IGNITIONHISTORY;
UBATTHISTORY are onlyassigned 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 labeled as undefined (-1).
28
EDIABAS - BEST/2 FUNCTION PRIMER
stop_frequent None
None
get_battery_voltage None
None
get_ignition_voltage None
WRONG UBATT
set_program_voltag None
None
e
29
EDIABAS - BEST/2 FUNCTION PRIMER
ifboot Always:
None
The active
communication with
the ECU is always
aborted, and the
terminal states are
always reset.
ifreset Always:
None
The active
communicaiton with
the ECU is always
aborted, and the
terminal states are
always reset.
ifgetport None
None
ifsetport None
None
ifloopt None
None
ifsireset None
None
ifrequeststate None
None
ifvers None
None
ifrawmode None
None
30
EDIABAS - BEST/2 FUNCTION PRIMER
4. Library functions
Summary Summarizes what the function does, illustrates its syntax and
briefly describes its arguments.
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.
31
EDIABAS - BEST/2 FUNCTION PRIMER
AdjustKWP2000TesterPrStartComm
Summary
params KWP 2000 parameters in the raw format for EDIC API (V)
Return value -
See also -
Example {
char parameter[];
parameter = kwp_2000_parameter;
parameter[5] = ecuAddress;
AdjustKWP2000TesterPrStartComm(parameter);
}
Result -
32
EDIABAS - BEST/2 FUNCTION PRIMER
ascii2ascii
Summary Converts all text characters into another character set.
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,
/*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
};
{
...
ascii2ascii(codepage,text);
...
}
33
EDIABAS - BEST/2 FUNCTION PRIMER
ascii2hex
Example
{
char source[] = "00FF";
char destin[] = { 0x12, 0x34, 0x56, 0x78 };
ascii2hex(destin,source,1};
...
}
34
EDIABAS - BEST/2 FUNCTION PRIMER
atoi
Summary Converts a string to a value
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.
Example
{
long hexnumber;
long binnumber;
long deznumber;
hexnumber=atoi("0x77");
binnumber=atoi("0y01110110");
deznumber=atoi("014");
...
}
35
EDIABAS - BEST/2 FUNCTION PRIMER
ator
Summary Converts a string to a real number
Remarks The ator function converts a string into an integer. The string is
interpreted as a real number. It can have the following format:
[{sign}][digits][{.|,}digits][{d|D|e|E}[sign]digits]
sign is either '+' or '-'.
digits are one or more digits.
Return value The converted value (maximum double = 1.7E ± 308 (15 digits)).
Example
{
real realnumber;
ator(realnumber,"1.22e01");
...
}
36
EDIABAS - BEST/2 FUNCTION PRIMER
atoy
Summary Converts a string into a binary array.
Example
{
char ascii[];
char binary[];
ascii="aa,bb,cc,00,01"
atoy(binary,ascii);
}
37
EDIABAS - BEST/2 FUNCTION PRIMER
bcd2ascii
Summary Converts a chain of characters to a BCD string
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 -
Example
{
char source[]={ 0x12, 0x34, 0xFF, 0x78, 0x90 };
char destin [];
bcd2ascii(destin,source,2,5};
...
}
38
EDIABAS - BEST/2 FUNCTION PRIMER
bittest
Summary Identifies bit results via a table
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)
Example
table bits[4][]={
{ "NAME", "BYTE" , "MASK" , "VALUE" },
{ "XON", "0", , "0x07" , "0x06" },
{ "XOFF", "0", , "0x07" , "0x01" } };
{
int xonvalue; int xoffvalue;
char buffer[];
buffer[0]=0x06;
tabset("bits");
bittest("XON",buffer,xonvalue);
bittest("XOFF",buffer,xoffvalue);
}
Result xonvalue = 1
xoffvalue = 0
39
EDIABAS - BEST/2 FUNCTION PRIMER
bytetest
Summary Identifies byte results via a table
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
and 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 div. It indicates the value by which the result has to be divided in
order to get a correct result.
Example
table bytes[3][]={
{"NAME","BYTE","MIN", "MAX", "MINDEF", "MAXDEF","A","B","DIV"},
{"TEMP","0", "07" , "254","-40", "120", "-4","8","1" }},
...
int tempvalue; int tempdiv; char buffer[]; buffer[0]=0x06;
tabset("bytes");
bytetest("TEMP",buffer,tempvalue,tempdiv);
}
40
EDIABAS - BEST/2 FUNCTION PRIMER
callPlugIn
Summary Calls the main function within the Plugin component.
Remarks The callPlugIn function calls the main function within the
Plugin component. The Plugin component provides the
content for the string variable dataOut.
Return value -
Example {
char name[];
char dataIn[];
char dataOut[];
long funcID;
long status;
...
linkPlugIn(name);
...
callPlugIn(dataOut,dataIn);
...
status = callPlugInExt(funcID,dataOut,dataIn);
...
}
Result -
41
EDIABAS - BEST/2 FUNCTION PRIMER
callPlugInExt
Summary Calls the main function within the Plugin component.
Example {
char name[];
char dataIn[];
char dataOut[];
long funcID;
long status;
...
linkPlugIn(name);
...
callPlugIn(dataOut,dataIn);
...
status = callPlugInExt(funcID,dataOut,dataIn);
...
}
Result -
42
EDIABAS - BEST/2 FUNCTION PRIMER
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 -
43
EDIABAS - BEST/2 FUNCTION PRIMER
close_communication
Summary Closes the communication channel to the interface
void close_communication()
Return value -
Example -
Result -
44
EDIABAS - BEST/2 FUNCTION PRIMER
data_to_real
Return value -
Example {
unsigned char buffer[];
real realzahl;
45
EDIABAS - BEST/2 FUNCTION PRIMER
datacat
Summary Appends data bytes to a buffer
Return value -
Example
unsigned char buffer1[];
unsigned char buffer2[];
buffer1 = {0x01, 0x02, 0x03};
buffer2 = {0x04, 0x05, 0x06};
datacat(buffer1, buffer2);
46
EDIABAS - BEST/2 FUNCTION PRIMER
dataclear
Summary Clears a buffer
Return value -
Example
unsigned char buffer[];
buffer = {0x01, 0x02, 0x03};
dataclear(buffer);
47
EDIABAS - BEST/2 FUNCTION PRIMER
datacmp
Summary Compares two data buffers
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.
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});
}
48
EDIABAS - BEST/2 FUNCTION PRIMER
datacopy
Summary Copies data from a source buffer to a target buffer
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.
Value ranges: 0 <= pos < 1024
0 <= count <= 1024
pos+count < 1024
Exceeding the value range causes runtime error BIP_0001.
Return value -
Example
{
char source[]= { 0x12, 0x34, 0x56, 0x78, 0x90 };
char destin[];
datacopy(destin,source,2,3);
...
}
Result destin={0x56,0x78,0x90}
49
EDIABAS - BEST/2 FUNCTION PRIMER
dataerase
Summary Erase data from a buffer
Return value -
Example
{
char buffer[] = { 0x12,0x34,0xFF,0x56,0x78 };
dataerase(buffer,1,2);
...
}
50
EDIABAS - BEST/2 FUNCTION PRIMER
datainsert
Summary Inserts data in a buffern
Remarks The function datainsert inserts the buffer source into the buffer
destin. Insertion is made beginning with position pos. If the buffer
destin becomes longer than a string register
Return value -
Example
{
char source[] = { 0xF0,0xF1 };
char destin[] = { 0x12,0x34,0x56,0x78 };
datainsert(destin,source,3);
...
}
51
EDIABAS - BEST/2 FUNCTION PRIMER
datalen
Example
long length;
unsigned char buffer[];
buffer = {0x01, 0x02, 0x03, 0x04};
length = datalen(buffer);
Result length = 4
52
EDIABAS - BEST/2 FUNCTION PRIMER
datarevers
Summary Reverses a data buffer
Return value -
Example
unsigned char buffer[];
buffer = {0x01, 0x02, 0x03, 0x04};
datarevers(buffer);
53
EDIABAS - BEST/2 FUNCTION PRIMER
dataset
Summary Sets the bytes in a buffer to a defined value
Remarks This function sets the number of bytes specified by count to the
value data in the target buffer destin.
Values ranges: 0 <= count < 1024
Exceeding the value range causes runtime error BIP_0001.
Return value -
Example
{
char buffer[]={ 0x12, 0x34, 0x56, 0x78, 0x90 };
dataset(buffer,0x41,2};
...
}
54
EDIABAS - BEST/2 FUNCTION PRIMER
doNewInit
Summary Forces the job INITIALISIERUNG before the next job call.
void doNewInit()
Return value -
See also -
Example
doNewInit();
Result -
55
EDIABAS - BEST/2 FUNCTION PRIMER
enableIfhTrace
Summary Enable/disable the IFH-Trace
Return value -
Example
unsigned char buffer[];
enableIfhTrace(1);
iftype(buffer);
enableIfhTrace(0);
Result -
56
EDIABAS - BEST/2 FUNCTION PRIMER
enableIgnitionHandling
Summary Enable/disable ignition monitoring
Return value -
Example
unsigned char buffer[];
enableIgnitionHandling(0);
iftype(buffer);
enableIgnitionHandling(1);
Result -
57
EDIABAS - BEST/2 FUNCTION PRIMER
enableUbattHandling
Summary Enable/disable battery monitoring
Return value -
Example
unsigned char buffer[];
enableUbattHandling(0);
iftype(buffer);
enableUbattHandling(1);
Result -
58
EDIABAS - BEST/2 FUNCTION PRIMER
fclose
Summary Closes a file
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 -
Example
{
int handle;
handle=fopen("\test\div\test.dat");
...
/* file operations */
...
fclose(handle);
}
Result -
59
EDIABAS - BEST/2 FUNCTION PRIMER
fopen
Summary Opens a text file
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].
Example
{
int handle;
handle=fopen("/usr2/test/test.dat");
...
/* file operations with handle */
...
fclose(handle);
}
Result -
60
EDIABAS - BEST/2 FUNCTION PRIMER
fread
Summary Reads a single character from a file
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.
Example
{
int handle;
long c; long i=0;
handle=fopen("test.dat");
while((c=fread(handle)) != -1)
i++;
}
61
EDIABAS - BEST/2 FUNCTION PRIMER
freadln
Summary Reads a line from a file
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 1024 characters per line are allowed!
Example
{
int handle;
char line[]; long i=0;
handle=fopen("beispiel.txt");
while(freadln(line,handle) != -1 )
i++;
}
62
EDIABAS - BEST/2 FUNCTION PRIMER
fseek
Summary Sets the position of the read pointer byte by byte
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].
handle=fopen("Filename");
c=fread(handle);
fseek(0,handle);
c=fread(handle);
...
}
63
EDIABAS - BEST/2 FUNCTION PRIMER
fseekln
Summary Sets the position of the read pointer line by line
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].
Example
{
int handle;
char line;
handle=fopen("test.txt");
fseekln(10,handle);
freadln(line,handle);
...
}
64
EDIABAS - BEST/2 FUNCTION PRIMER
ftell
Summary Identifies the position of the read pointer
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].
Example
{
int handle;
long c:
handle=fopen("Filename");
c=fread(handle);
c=fread(handle);
...
c=ftell(handle);
}
65
EDIABAS - BEST/2 FUNCTION PRIMER
ftellln
Summary Identifies the position of the read pointer in lines
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].
Example
{
int handle;
char line[];
handle=fopen("xxx.tst");
freadln(line,handle);
freadln(line,handle);
...
c=ftellln(handle);
}
66
EDIABAS - BEST/2 FUNCTION PRIMER
getasciitime
Summary Determines the current time as ASCII-String
"hh:mm:ss"
Return value -
Example {
char time[];
getasciitime(time);
...
}
67
EDIABAS - BEST/2 FUNCTION PRIMER
get_battery_voltage
Summary Reads out the battery voltage
long get_battery_voltage()
Example
long voltage;
voltage = get_battery_voltage();
Result -
68
EDIABAS - BEST/2 FUNCTION PRIMER
get_error
(get_trap_mask, set_trap_mask )
Summary Checks whether an error has occurred
69
EDIABAS - BEST/2 FUNCTION PRIMER
get_error2
Summary Checks whether an error has occurred.
long get_error2()
error = get_error2();
70
EDIABAS - BEST/2 FUNCTION PRIMER
get_ignition_voltage
Summary Reads out the voltage at the ignition
long get_ignition_voltage()
Example
long voltage;
voltage = get_ignition_voltage();
Result -
71
EDIABAS - BEST/2 FUNCTION PRIMER
get_token
Summary Identifies a token in a string
Return value -
Example {
char source[]; char destin[];
source="DIES IST EIN TEST FUER TOKENS";
gettoken(destin,source," ",4);
}
72
EDIABAS - BEST/2 FUNCTION PRIMER
getasciidate
Summary Determines the current date as ASCII string
Return value -
Example {
char date[];
getasciidate(date);
...
}
73
EDIABAS - BEST/2 FUNCTION PRIMER
get_trap_mask
Summary Gets the current value of the trap mask register
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.
Example
{
long x;
set_trap_mask(0x00180000);
x=get_trap_mask();
}
Result x=0x00180000
74
EDIABAS - BEST/2 FUNCTION PRIMER
generateRunError
Summary Generates a runtime error „RUN-00XX“
Return value -
Example {
...
generateRunError(250); // generate „RUN-
0000“
//
}
Result -
75
EDIABAS - BEST/2 FUNCTION PRIMER
getasciidate
Summary Gets the current date as an ASCII string
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 -
Example
{
char date[];
getasciidate(date);
...
}
76
EDIABAS - BEST/2 FUNCTION PRIMER
getasciitime
Summary Gets the current time as an ASCII string
Remarks From the system time this function identifies the current time as a
string with the form
"hh:mm:ss"
Return value -
Example
{
char time[];
getasciitime(time);
...
}
77
EDIABAS - BEST/2 FUNCTION PRIMER
getCfgInt
cfgvalue=getCfgInt("RetryComm");
78
EDIABAS - BEST/2 FUNCTION PRIMER
getCfgString
Summary Reads (gets) a configuration element as a string
Example
{
char cfgvalue[];
getCfgString(cfgvalue,"SimulationPath");
}
79
EDIABAS - BEST/2 FUNCTION PRIMER
getdate
Summary Gets the current time as an array structure
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 -
Example
{
char date[];// Friday, 6th of August, 1999
(calendar week 31)
getdate(date);
...
}
80
EDIABAS - BEST/2 FUNCTION PRIMER
getETXblock
Summary Returns the data bytes of a block specified for a KWP 1281
ECU.
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.
See also -
Example
{
unsigned char antwort[];
unsigned char buffer[];
unsigned char status = 0xfc;
char blockLen;
send_and_receive(antwort,tel_fslesen);
if (getETXblock(antwort,status,1,buffer,blockLen))
{
}
Result -
81
EDIABAS - BEST/2 FUNCTION PRIMER
GetKWP2000Block
Summary Extracts the data component from a KWP 2000 telegram
in the control unit response.
See also -
82
EDIABAS - BEST/2 FUNCTION PRIMER
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 -
83
EDIABAS - BEST/2 FUNCTION PRIMER
gettickcount
Summary Gets an iternal tick counter of milliseconds.
Example {
unsigned long ticks;
ticks=gettickcount();
...
}
Result -
84
EDIABAS - BEST/2 FUNCTION PRIMER
gettime
Summary Gets the current time as an array structure
Remarks From the system time this function identifies the current time as a
structure with the form
date[0] = hour (0..23)
date[1] = minute (0..59)
date[2] = second (0..59)
Return value -
Example
{
char time[];
gettime(time);
...
}
85
EDIABAS - BEST/2 FUNCTION PRIMER
hex2ascii
Summary Converts a sequence of bytes to a hex string.
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 -
Example
{
char source[]={ 0x12, 0x34, 0xFF, 0x78, 0x90 };
char destin [];
hex2ascii(destin,source,2,5);
...
}
86
EDIABAS - BEST/2 FUNCTION PRIMER
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 -
87
EDIABAS - BEST/2 FUNCTION PRIMER
ifgetport
Summary Reads out a port
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)
Example
long voltageCl30;
long jumper;
voltageCl30 = ifgetport(7);
jumper = ifgetport(8);
Result -
88
EDIABAS - BEST/2 FUNCTION PRIMER
ifinfo
Summary Function for the purpose of debugging
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 -
Example -
Result -
89
EDIABAS - BEST/2 FUNCTION PRIMER
ifinfoExt
Summary Function for the purpose of debugging
Example -
Result -
90
EDIABAS - BEST/2 FUNCTION PRIMER
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.
See also -
Example
if(ifloopt())
/* execute diagnostic */
Result -
91
EDIABAS - BEST/2 FUNCTION PRIMER
ifrawmode
Summary Passes data 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 are not
evaluated.
Return value -
See also -
Example
unsigned char input[];
unsigned char output[];
92
EDIABAS - BEST/2 FUNCTION PRIMER
ifrecv
Summary Function for the purpose of debugging
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 -
Example -
Result -
93
EDIABAS - BEST/2 FUNCTION PRIMER
ifrequeststate
Summary Interrogate the interface status
Return value -
See also -
Example -
Result -
94
EDIABAS - BEST/2 FUNCTION PRIMER
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 -
Example
ifreset();
Result -
95
EDIABAS - BEST/2 FUNCTION PRIMER
ifsend
Summary Function for the purpose of debugging
Return value -
Example -
Result -
96
EDIABAS - BEST/2 FUNCTION PRIMER
ifsetport
Summary Sets a port
Remarks Ports can be set with this function. Only port 9 can be set in EDIC
(digital outputs).
Port 9: Digital outputs
Return value -
Example
long value;
value = 0xff;
ifsetport(9, value);
Result -
97
EDIABAS - BEST/2 FUNCTION PRIMER
ifsireset
Summary Switches the SI relay
Remarks This function switches on the service interval relay of the EDIC for
the specified time.
time = 0: Continuous off
time = -1: Continuous on
Return value -
See also -
Example
ifsireset(100); /* switch for 100 ms */
Result -
98
EDIABAS - BEST/2 FUNCTION PRIMER
iftype
Summary Returns the interface type as a string
Return value -
Example
char typ[];
iftype(typ);
Result -
99
EDIABAS - BEST/2 FUNCTION PRIMER
ifvers
Summary Returns the interface version number
long ifvers()
Remarks This job returns the version number of the interface (EDIC,
IDBSS)
See also -
Example
unsigned int versionno;
versionno = ifvers();
100
EDIABAS - BEST/2 FUNCTION PRIMER
incProgressPos
Summary Increases the current position of the progress counter.
void incProgressPos(long n)
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 -
Example
setProgressRange(500);
incProgressPos(0); // Start with 0 percent
:
incProgressPos(100); // 20 percent processed
: //
///////////////////////////////////////////////////
// In the END job
setProgressRange(0); // Reset processing state
Result -
101
EDIABAS - BEST/2 FUNCTION PRIMER
isDebugLevel
Summary Determines the debug level
long isDebugLevel()
Example
{
char antwort[];
send_and_reveive(antwort,tel);
Result -
102
EDIABAS - BEST/2 FUNCTION PRIMER
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..
Example
{
char antwort[];
if(isSimulation())
send_and_reveive(antwort,tel_sim);
else
send_and_reveive(antwort,tel);
}
Result -
103
EDIABAS - BEST/2 FUNCTION PRIMER
itoad
Summary Converts a number to a string in decimal notation
Remarks itoad converts the number value to a string with decimal notation
with a sign. No leading zeroes are output.
Return value -
Example
{
char destin[];
itoad(destin,1143);
...
}
Result destin="1143"
104
EDIABAS - BEST/2 FUNCTION PRIMER
itoax
Summary Converts a number to a string in hexadecimal notation
Return value -
Example
{
char destin[];
itoax(destin,1143);
...
}
Result destin="0x00000477"
105
EDIABAS - BEST/2 FUNCTION PRIMER
itor
Summary Converts an integer to a real value
Return value -
Example
{
real realzahl;
itor(realzahl,122);
...
}
106
EDIABAS - BEST/2 FUNCTION PRIMER
linkPlugIn
Summary Loads a Plugin component
Win16: <Name>.dll
Win32: <Name>32.dll
Return value -
Example {
char name[];
char dataIn[];
char dataOut[];
long funcID;
long status;
...
linkPlugIn(name);
...
callPlugIn(dataOut,dataIn);
...
status = callPlugInExt(funcID,dataOut,dataIn);
...
}
Result -
107
EDIABAS - BEST/2 FUNCTION PRIMER
make_error
Summary Issues an EDIABAS error
Remarks This function enters the trap number trapnumber in the Trap-
Mask-Register and issues the corresponding error in the runtime
system.
Return value -
Example
{
...
make_error(19); // Issue IFH_0009
}
Result -
108
EDIABAS - BEST/2 FUNCTION PRIMER
new_set_of_results
Summary Opens a new set of results
void new_set_of_results()
Return value -
Example
...
result: ERROR_NAME ; type int ...
result: ERROR_VALUE ; type int ...
{
ERROR_NAME = „NAME1“;
ERROR_VALUE = 1;
new_set_of_results();
ERROR_NAME = „NAME2“;
ERROR_VALUE = 2;
...
}
109
EDIABAS - BEST/2 FUNCTION PRIMER
open_communication
Summary Opens the communication channel to the interface
void open_communication()
Remarks This function opens the 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. If
open_communication has not been called yet, then all
communication and interface commands are answered by error
message IFH_0019.
Return value -
Example
open_communication();
Result -
110
EDIABAS - BEST/2 FUNCTION PRIMER
parcount
Summary Counts the number of parameters
long parcount()
Example
{
long x;
x=parcount();
}
111
EDIABAS - BEST/2 FUNCTION PRIMER
real_to_data
Return value -
Example {
unsigned char buffer[];
real realzahl;
realzahl = atof("123.45");
real_to_data(buffer,realzahl,0,0,0);
...
}
112
EDIABAS - BEST/2 FUNCTION PRIMER
realadd
Summary Adds two real numbers
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 -
Example
{
real real1;
real real2;
ator(real1,"1234e15");
ator(real2,"5678e13");
realadd(real1,real2);
}
113
EDIABAS - BEST/2 FUNCTION PRIMER
realcomp
Summary Compares two real numbers
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
114
EDIABAS - BEST/2 FUNCTION PRIMER
realdiv
Summary Divides two real numbers
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 -
Example
{
real real1;
real real2;
ator(real1,"1234e15");
ator(real2,"5678e13");
realdiv(real1,real2);
}
115
EDIABAS - BEST/2 FUNCTION PRIMER
realmul
Summary Multiplies two real numbers
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 -
Example
{
real real1;
real real2;
ator(real1,"1234e15");
ator(real2,"5678e13");
realmul(real1,real2);
}
116
EDIABAS - BEST/2 FUNCTION PRIMER
realresult
Summary Generates a real result
Remarks This function generates a real result with result name name and
the value value / adjust.
Return value -
Example
...result: x; type : int ...){
realresult("x",12345678,1000);
}
Result x = 12345.678
117
EDIABAS - BEST/2 FUNCTION PRIMER
realsub
Summary Subtracts two real numbers
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 -
Example
{
real real1;
real real2;
ator(real1,"1234e15");
ator(real2,"5678e13");
realsub(real1,real2);
}
118
EDIABAS - BEST/2 FUNCTION PRIMER
recv_frequent
Summary Receives a telegram in the frequent mode
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 -
Example
unsigned char response[];
send_frequent(request);
recv_frequent(response);
Result -
119
EDIABAS - BEST/2 FUNCTION PRIMER
recv_keybytes
Summary Reads out the control unit key bytes
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 -
120
EDIABAS - BEST/2 FUNCTION PRIMER
rtoa
Summary Converts a real number into a string
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.
Example
{
char destin[];
real realzahl;
int len;
ator(realzahl,"1.234";
...
len=rtoa(destin,realzahl,3);
...
}
121
EDIABAS - BEST/2 FUNCTION PRIMER
rtoi
Summary Converts a real number into an integer
Example
{
long destin[];
real realzahl;
ator(realzahl,"5.234";
...
destin=rtoi(realzahl);
...
}
Result destin = 5;
122
EDIABAS - BEST/2 FUNCTION PRIMER
send_and_receive
Summary Sends and receives a telegram
Remarks This function sends a telegram to the control unit and receives the
answer.
Return value -
Example
unsigned char request[];
unsigned char response[];
request = {0x0D, 0x00, 0x05, 0x00}; // request telegram
send_and_receive(response, request);
Result -
123
EDIABAS - BEST/2 FUNCTION PRIMER
send_frequent
Summary Sends and receives a telegram in the frequent mode
Return value -
Example
unsigned char request[];
unsigned char response[];
request = {0x0D, 0x00, 0x05, 0x00};
send_frequent(request);
recv_frequent(response);
recv_frequent(response);
Result -
124
EDIABAS - BEST/2 FUNCTION PRIMER
set_answer_length
Summary Sets the telegram parameters/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.
125
EDIABAS - BEST/2 FUNCTION PRIMER
Return value -
126
EDIABAS - BEST/2 FUNCTION PRIMER
Example
int awlen[] = {-2.0}; //With concept 2 the answer length
// is at 2nd place in the telegram
set_answer_length(awlen);
Result -
127
EDIABAS - BEST/2 FUNCTION PRIMER
set_communication_pars
Summary Sets the communication parameters
Concept 1
Concept 2 ISO 9141
Concept 3
Concept 2 DDE
Concept DS1
Concept DS2
param[0] Concept
Concept 1 =1
Concept 2 ISO 9141 =2
Concept 3 =3
128
EDIABAS - BEST/2 FUNCTION PRIMER
Concept 2 DDE =4
Concept DS1 =5
Concept DS2 =6
param[1] Baudrate
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.
129
EDIABAS - BEST/2 FUNCTION PRIMER
130
EDIABAS - BEST/2 FUNCTION PRIMER
param[0] concept
BMW-FAST = 0x10F
param[1] baud rate
0 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)
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.
131
EDIABAS - BEST/2 FUNCTION PRIMER
param[0] concept
132
EDIABAS - BEST/2 FUNCTION PRIMER
param[22] to
param[32] StartCommunication Telegram
StartCommunication telegram. If the telegram has less
than 11 characters, the remaining characters 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.
133
EDIABAS - BEST/2 FUNCTION PRIMER
param[0] Concept
KWP2000 * = 0x10D
param[1] Baud Rate
0 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
134
EDIABAS - BEST/2 FUNCTION PRIMER
135
EDIABAS - BEST/2 FUNCTION PRIMER
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:
Bits 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
136
EDIABAS - BEST/2 FUNCTION PRIMER
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)
137
EDIABAS - BEST/2 FUNCTION PRIMER
138
EDIABAS - BEST/2 FUNCTION PRIMER
139
EDIABAS - BEST/2 FUNCTION PRIMER
140
EDIABAS - BEST/2 FUNCTION PRIMER
141
EDIABAS - BEST/2 FUNCTION PRIMER
142
EDIABAS - BEST/2 FUNCTION PRIMER
143
EDIABAS - BEST/2 FUNCTION PRIMER
144
EDIABAS - BEST/2 FUNCTION PRIMER
param[58] Reserved
param[59] Reserved
Return value -
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 -
145
EDIABAS - BEST/2 FUNCTION PRIMER
set_program_voltage
Summary Sets the programming voltage
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 -
146
EDIABAS - BEST/2 FUNCTION PRIMER
set_repeat_counter
Summary Sets the number of repeats for control unit communication
Return value -
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 -
147
EDIABAS - BEST/2 FUNCTION PRIMER
set_trap_mask
Summary Sets the trap mask register
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 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) + ...
148
EDIABAS - BEST/2 FUNCTION PRIMER
149
EDIABAS - BEST/2 FUNCTION PRIMER
interface
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 -- --
Return value The value of the trap mask register before it is called
Example
{
set_trap_mask(0x00180000);
send_and_receive(.....);
if(get_error(19))
job_status="DIAGNOSE-FEHLER";
else
job_status="OKAY";
}
150
EDIABAS - BEST/2 FUNCTION PRIMER
set_variable_result
Summary Output variable results
Return value -
Example
{
char wert[]="My result value";
unsigned char y[];
real x;
set_variable_result("ERGEBNIS",3,0,x,wert,y);
}
151
EDIABAS - BEST/2 FUNCTION PRIMER
setProgressRange
Summary Defines a progress range from 0 to Range
Return value -
Example
setProgressRange(500);
incProgressPos(0); // Start with 0 percent
:
incProgressPos(100); // 20 percent
// processed
:
incProgressPos(300); // 80 percent
// processed
:
incProgressPos(200); // 100 percent
// processed
///////////////////////////////////////////////////
// Im ENDE-Job
setProgressRange(0); // Reset
// processing mode
Result
152
EDIABAS - BEST/2 FUNCTION PRIMER
shdataget
Summary Copies the contents of the global data memory into a destination
buffer.
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.
Example
unsigned char local[];
shdataget("myID",local);
Result -
153
EDIABAS - BEST/2 FUNCTION PRIMER
shdataset
Summary Fills the global data memory with the contents of the 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.
Return value -
Example
unsigned char source[];
shdataset("myID",source);
Result -
154
EDIABAS - BEST/2 FUNCTION PRIMER
stop_frequent
Summary Terminates the frequent mode
void stop_frequent()
Return value -
Example -
Result -
155
EDIABAS - BEST/2 FUNCTION PRIMER
strcat
Summary Appends one string to another
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. 1023 characters max. Both strings can have the
length 0. The source string is not changed.
Return value -
Example
{
char destin[]="01234";
char source[]="56789";
strcat(destin,source);
}
156
EDIABAS - BEST/2 FUNCTION PRIMER
strcmp
Summary Compares two strings
s1 String1 (V)
s2 String2 (V)
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.
Example
{
int x; int y; int z;
char s1[]="ABC";
x=strcmp(s1,"ABC");
y=strcmp(s1,"ABCD");
z=strcmp(s1,"abc");
}
157
EDIABAS - BEST/2 FUNCTION PRIMER
strcpy
Summary Copies a string
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 -
Example
{
char destin[]="ABC";
strcpy(destin,"XD");
}
158
EDIABAS - BEST/2 FUNCTION PRIMER
strcut
Summary Shortens a string
Return value -
Example
{
char buffer[]="ABCDF";
strcut(buffer,3);
}
159
EDIABAS - BEST/2 FUNCTION PRIMER
strerase
Summary Erases characters in a string
Return value -
Example
{
char buffer[]="ABCDEFGHIJKLM";
strerase(buffer,3,3);
}
160
EDIABAS - BEST/2 FUNCTION PRIMER
strinsert
Summary Inserts characters into a string
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. 1024 characters, the rest is cut
off.
Return value -
Example
{
char buffer[]="ABCGHIJKLM";
strinsert(buffer,"DEF",3);
}
161
EDIABAS - BEST/2 FUNCTION PRIMER
strlen
Summary Identifies the length of a string
Remarks strlen identifies the length of a string. The length of a string is the
number of characters it contains, except the terminating zero.
Example
{
char string[]="ABCDEF"
long x;
x=strlen(string);
}
Result x=6
162
EDIABAS - BEST/2 FUNCTION PRIMER
strncpy
Summary Copies a number of characters from a string
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 -
Example
{
char destin[]="ABCDEFGH";
strncpy(destin,"XYZABCDEF",3);
}
163
EDIABAS - BEST/2 FUNCTION PRIMER
strrevers
Summary Reverses a string
Remarks strrevers turns the string round, i.e. the last character become the
first and so on.
Return value -
Example
{
char destin[]="ABCDEFGH";
strreverse(destin);
}
164
EDIABAS - BEST/2 FUNCTION PRIMER
tab2fix
Summary Reads the values from the current table line and converts them
into a number
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 spalte 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 -
Example
int errorNo = 0x11;
unsigned long value;
tabset("Table");
tab_suche_index("ERRORNO",errorNo);
tab2fix(value, "VALUE");
Result -
165
EDIABAS - BEST/2 FUNCTION PRIMER
tab_suche_index
Summary Searches in a table column for a value with the form 0x##
Example
table TEST[3][]={
{ "NAME", "VALUE", "NUMBER" },
{ "ONE", "1000", "0X00" },
{ "TWO", "2000", "0X03" },
}
{
char buffer[];
tabset("TEST");
tab_suche_index("NUMBER",3);
tabget(buffer,"NAME");
}
166
EDIABAS - BEST/2 FUNCTION PRIMER
tab_suche_unsigned
Summary Searches a table column for a predefined unsigned value
167
EDIABAS - BEST/2 FUNCTION PRIMER
{
char buffer[];
unsigned long index;
tabset("TST");
index=0x300;
tab_suche_unsigned("NUMMER",index);
tabget(buffer,"NAME");
}
168
EDIABAS - BEST/2 FUNCTION PRIMER
tabget
Summary Reads the values from the current table line
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 -
Result -
169
EDIABAS - BEST/2 FUNCTION PRIMER
tabline
Summary Positions the read pointer on the specified line
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.
Result -
170
EDIABAS - BEST/2 FUNCTION PRIMER
tabseek
Summary Searches in a table column for a value
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.
Result -
171
EDIABAS - BEST/2 FUNCTION PRIMER
tabset
Summary Sets and resets table processing
Return value -
Example
table TEST[3][]={
{ "NAME", "VALUE", "NUMBER"},
{ "ONE", "1000", "0" },
{ "TWO", "2000", "3" },
}
{
char buffer[];
tabset("TEST");
tabseek("NAME","ONE");
tabget(buffer,"NUMBER"); // buffer = "0"
tabget(buffer,"VALUE"); // buffer = "1000"
tabseek("NUMBER","3");
tabget(buffer,"NAME"); // buffer = "TWO"
}
Result -
172
EDIABAS - BEST/2 FUNCTION PRIMER
tabsetext
Summary Set and reset of table handling.
The search for tabfile starts in ECU directory, first for a variant
SGBD. If it failed then for a group SGBD.
Return value -
Result -
173
EDIABAS - BEST/2 FUNCTION PRIMER
uitoad
Summary Convert an unsigned interger number to a string in decimal notation.
Return value -
Example {
char destin[];
uitoad(destin,4294967295);
...
}
Result destin="4294967295"
174
EDIABAS - BEST/2 FUNCTION PRIMER
updateInfo
Summary Produces a string result during job processing
void updateInfo()
Return value -
See also -
Example
updateinfo();
Result -
175
EDIABAS - BEST/2 FUNCTION PRIMER
userbreak
Summary Produces an error message "BIP-0008: BEST BREAK"
void userbreak()
Return value -
Example
userbreak();
Result -
176
EDIABAS - BEST/2 FUNCTION PRIMER
var_result_data
Summary Produces a data result not defined in the job header.
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 -
Example
{
char resultname[] = "X";
char resultvalue[] = { 0x12, 0x34, 0xFF };
var_result_data(resultname,resultvalue);
}
Result -
177
EDIABAS - BEST/2 FUNCTION PRIMER
var_result_long
Summary Produces a long result not defined in the job header.
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 -
Example
{
char resultname[] = "X";
long resultvalue = 0x10;
var_result_long(resultname,resultvalue);
}
Result -
178
EDIABAS - BEST/2 FUNCTION PRIMER
var_result_real
Summary Produces a real result not defined in the job header.
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 -
Example
{
char resultname[] = "X";
real resultvalue;
ator(resultvalue,"1.23");
var_result_real(resultname,resultvalue);
}
Result -
179
EDIABAS - BEST/2 FUNCTION PRIMER
var_result_string
Summary Produces a string result not defined in the job header.
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.
Return value -
Example
{
char resultname[] = "X";
char resultvalue[] = "ABC";
var_result_string(resultname,resultvalue);
}
Result -
180
EDIABAS - BEST/2 FUNCTION PRIMER
wait
Summary Wait n seconds
Remarks The wait function waits time second. wait waits for a maximum of
time seconds and a minimum of time-1 seconds. If time = 0, there
is no waiting.
Return value -
Example
{
wait(1);
}
181
EDIABAS - BEST/2 FUNCTION PRIMER
waitex
Summary Waits n milliseconds
Example {
waitex(1000);
}
182
EDIABAS - BEST/2 FUNCTION PRIMER
LIST OF REFERENCES
183