Skip to main content

TLP — Target-Link-Protocol — Standard Protocol

In case there is no library available yet for your control system, you can emulate the protocol between control system and Connector by referring to the following documentation. Please contact us first in this case, as we are continuously developing libraries for additional control systems.

Standard Protocol

With each SQL request to the database, the Connector is provided with information prior to execution.

Request to the Connector

AttributeData TypeDescriptionDefault
MRPNullterminierter StringMax Return Parameter
<MRP Value>Nullterminierter StringMinimum 1Nicht optional
MRNull-terminated StringMax Rows
<MR Value>Null-terminated StringMinimum 1Not optional
MCNull-terminated StringMax Columns
<MC Value>Null-terminated StringMinimum 1Not optional
MSNull-terminated StringMax String
<MS Value>Null-terminated StringMinimum 1Not optional
MBNull-terminated StringMax Buffer
<MB Value>Null-terminated StringMaximum amount of data in bytes which the control system can readNot active
CTNull-terminated StringConnector Timeout
<CT Value>Null-terminated String0 = no Timeout, Connection remains open, >0 = Timeout in secondsNot active
CNNull-terminated StringColumn Names
<CN Value>Null-terminated String0 = no Column names, 1 = Column names (default 1)1
CSNull-terminated StringCut String
<CS Value>Null-terminated StringString of each value is shortened to length CSNot active
SNull-terminated StringString (SQL Request)
<S Value>Null-terminated StringMinimum 1 characterNot optional
TNull-terminated StringTransmit Request
<MRP><NUL><MRP Value><NUL>Maximum number of return parameters which can be stored in the control system
<MR><NUL><MR Value><NUL>Maximum number of datasets which can be stored in the control system
<MC><NUL><MC Value><NUL>Maximum number of columns which can be stored in the control system
<MS><NUL><MS Value><NUL>Length of the string variable in the control system
<MB><NUL><MB Value><NUL>Maximum amount of data in bytes which the control system can read (optional)
<CT><NUL><CT Value><NUL>Timeout Connector (optional)
<CN><NUL><CN Value><NUL>A database request also returns the column names in addition to the data, or not. (optional)
<CS><NUL><CS Value><NUL>A database request also returns data if the size of the database value exceeds the defined maximum string length (MS). The value will be cut off after the CS value, and the error is ignored. (optional)
<S><NUL><S Value><NUL>SQL request string
<S><NUL><S Value><NUL>If the SQL request string is too large for the control system, it can be sent to the connector in a dissected form. (optional)
<T><NUL>Start command to send the SQL request string to the database

Examples:

MRPNUL15NULMRNUL80NULMCNUL40NULMSNUL255NULSNULSELECT id, iParam1, fParam2, sText1 FROM tTable1NULTNUL

MRPNUL15NULMRNUL80NULMCNUL40NULMSNUL255NULCS NUL80NULCNNUL0NUL
SNULSELECT id, iParam1, fParam2, sText1 FROM tTable1NUL
SNULWHERE id < 4NUL
TNUL

Response from the Connector

AttributeData TypeDescription
RSNull-terminated StringReturn State
<RS Value>Null-terminated String
RPNullterminierter StringReturn Parameter
<RP Value>Nullterminierter String
RRNull-terminated StringResult Rows
< RR Value>Null-terminated String
RCNull-terminated StringResult Columns
< RC Value>Null-terminated String
RNNull-terminated StringResult Column names
< RN Values>Null-terminated String
RDNull-terminated StringResult Data
< RD Values>Null-terminated String
<RS><NUL><RS Value><NUL>RS Value = 0: Okay, data will follow.
RS Value > 0: Error code, no data will follow.

If RS Value = 0:

<RP><NUL><RP Value><NUL>RP Value = Number of return parameters
<RR><NUL><RR Value><NUL>RR Value = Number of datasets
<RC><NUL><RC Value><NUL>RC Value = Number of columns

Only if RP Value > 0 return parameter will follow (RPD)

RPDNUL
123NUL321NULabcNUL

If RC Value > 0 data will follow, else RR Value contains the number of the processed datasets (Update, Delete…)

<RN><NUL>Followed by all column names
<RD><NUL>Followed by all data

Column names (RN) are enumerated as:

For iC = 1 to RC
<RN Value[iC]><NUL>
Next iC

Data values (RD) are enumerated as:

For iR = 1 to RR
For iC = 1 to RC
<RD Value[iR, iC]><NUL>
Next iC
Next iR

Example:

RSNUL0NULRPNUL3NULRRNUL3NULRCNUL4NUL
RPDNUL
123NUL321NULabcNUL
RNNUL
idNULiParam1NULfParam2NULsText1NUL
RDNUL
1NUL501NUL10.1NULText Example 1NUL
2NUL502NUL10.2NULText Example 2NUL
3NUL503NUL10.3NULText Example 3NUL

Error Codes Return-Value

Error NumberError Description
0No error, request data to follow
1Unknown SQL Command
2Request returns more datasets than defined by MaxRows, modify request or increase MaxRows
3Request returns more columns than defined by MaxColumns, modify request or increase MaxColumns
4Request returns more data than defined by buffer size (only with target type Siemens)
Modify request or increase Buf. Size in the Connector and in the application.
5Request returns minimal one value that is bigger than defined by MaxStringLength, modify request or increase MaxStringLength
10Internal Connector error
11Internal Connector error, cannot open database
23Request string is empty
24Number MaxRows not defined
25Number MaxColumns not defined
29Size MaxStringLength not defined
>100Error numbers of the ODBC database connection (some known error numbers are attached)
40002General error during SQL request, request string is invalid

Handshake

Error-free Request

Timing diagram of an error-free request: xExecute rises, xReady drops then rises again, xBusy rises while processing, xDone pulses once the request is complete.

Abortion during Request

Timing diagram of an aborted request: xExecute rises, xAbort is set while xBusy is active, causing xReady to rise again without xDone or xError being triggered.

Error during Request

Timing diagram of a request that fails: xExecute rises, xBusy is active, and xError pulses instead of xDone once processing finishes.