DSETHRTLib Reference
DSETHRTLib Reference
RTLib Reference
Release 2024-A – May 2024
To access the Web version of this document, click the following link or scan the QR code:
https://www.dspace.com/dspace-help/Kwicf
To access the Web version, you must have a mydSPACE account. For more information on the
mydSPACE registration process, refer to https://www.dspace.com/faq?097.
How to Contact dSPACE
Mail: dSPACE GmbH
Rathenaustraße 26
33102 Paderborn
Germany
Tel.: +49 5251 1638-0
E-mail: info@dspace.de
Web: https://www.dspace.com
If possible, always provide the serial number of the hardware, the relevant dSPACE License
ID, or the serial number of the CmContainer in your support request.
Important Notice
This publication contains proprietary information that is protected by copyright. All rights
are reserved. The publication may be printed for personal or internal use provided all the
proprietary markings are retained on all printed copies. In all other cases, the publication
must not be copied, photocopied, reproduced, translated, or reduced to any electronic
medium or machine-readable form, in whole or in part, without the prior written consent
of dSPACE GmbH.
This publication and the contents hereof are subject to change without notice.
Contents
3
May 2024 DSETH RTLib Reference
Contents
Examples 43
Using the DSETH with a MicroAutoBox II and a DS867 LVDS-
Ethernet Cable.............................................................................................. 43
Using the DSETH with the ETH_TP1 Interface of a MicroAutoBox II................ 45
Index 49
4
DSETH RTLib Reference May 2024
About This Reference
Contents The DSETH Real-Time Library (RTLib) provides the C functions and macros you
need to program the DS867 LVDS‑Ethernet interface or the ETH_TP1 interface of
a MicroAutoBox II.
Symbol Description
Indicates a hazardous situation that, if not avoided,
V DANGER
will result in death or serious injury.
Indicates a hazardous situation that, if not avoided,
V WARNING could result in death or serious injury.
Indicates a hazardous situation that, if not avoided,
V CAUTION could result in minor or moderate injury.
Indicates a hazard that, if not avoided, could result in
NOTICE
property damage.
Indicates important information that you should take
Note
into account to avoid malfunctions.
Indicates tips that can make your work easier.
Tip
Indicates a link that refers to a definition in the
glossary, which you can find at the end of the
document unless stated otherwise.
Follows the document title in a link that refers to
another document.
5
May 2024 DSETH RTLib Reference
About This Reference
Naming conventions dSPACE user documentation uses the following naming conventions:
Special Windows folders Windows‑based software products use the following special folders:
Accessing dSPACE Help and After you install and decrypt Windows‑based dSPACE software, the
PDF files documentation for the installed products is available in dSPACE Help and as PDF
files.
dSPACE Help (local) You can open your local installation of dSPACE Help:
§ On its home page via Windows Start Menu
§ On specific content using context-sensitive help via F1
PDF files You can access PDF files via the icon in dSPACE Help. The PDF
opens on the first page.
6
DSETH RTLib Reference May 2024
Data Type Definitions
Predefined Symbols................................................................................... 8
Provides information on the defines, which are predefined in the
dseth.h, dseth_custom_ds867.h and dseth_custom_eth_tp1.h
include files.
DsEthCstmDS867SComHandle................................................................ 11
To define the initialization structure used for DSETH custom
communication object initialization if an LVDS-Ethernet link cable
(DS867) is used (forward declaration).
DsEthCstmEthTp1SComHandle................................................................ 12
To define the initialization structure used for DSETH custom
communication object initialization in connection with an ETH_TP1
interface (forward declaration).
DsEthSDataBufferObj............................................................................... 13
To define DSETH data buffer objects (forward declaration).
DsEthSObj............................................................................................... 15
To define DSETH communication objects (forward declaration).
DsEthSObjInit.......................................................................................... 17
To define the initialization structure used for DSETH communication
object initialization (forward declaration).
DsEthSSocketInit...................................................................................... 19
To define the initialization structure used for DSETH socket object
initialization (forward declaration).
DsEthSSocketObj..................................................................................... 21
To define DSETH socket objects (forward declaration).
pDsEthCstmDS867SComHandle.............................................................. 22
To define the initialization structure for DSETH custom communication
object initialization if an LVDS-Ethernet link cable (DS867) is used (pointer
declaration).
7
May 2024 DSETH RTLib Reference
Data Type Definitions
pDsEthCstmEthTp1SComHandle.............................................................. 23
To define the initialization structure for DSETH custom communication
object initialization if an ETH_TP1 interface is used (pointer declaration).
pDsEthSDataBufferObj............................................................................. 23
To define a DSETH data buffer object (pointer declaration).
pDsEthSObj............................................................................................. 24
To define a DSETH communication object (pointer declaration).
pDsEthSObjInit........................................................................................ 25
To define the initialization structure for DSETH communication object
initialization (pointer declaration).
pDsEthSpecific......................................................................................... 26
To define a specific parameter structure (for internal use).
pDsEthSSocketInit.................................................................................... 27
To define the initialization structure used for DSETH socket object
initialization (pointer declaration).
pDsEthSSocketObj................................................................................... 27
To define a DSETH socket object (pointer declaration).
Predefined Symbols
Introduction The following tables list the defines, which are predefined in the dseth.h,
dseth_custom_ds867.h and dseth_custom_eth_tp1.h include files.
8
DSETH RTLib Reference May 2024
Predefined Symbols
Object initialization
parameter defines
TX state defines
TX defines
9
May 2024 DSETH RTLib Reference
Data Type Definitions
10
DSETH RTLib Reference May 2024
DsEthCstmDS867SComHandle
DsEthCstmDS867SComHandle
Note
Members Version Version number of the structure. The current version number is 0.
Base Number of the connected ECU module (MicroAutoBox II) that provides
communication.
Example The following example shows how to initialize a DSETH custom communication
object if an LVDS-Ethernet link cable is used:
{
pDsEthCfgSComHandle pComHandle;
pDsEthSSocketObj pSocketObj;
comHandleDS867.Version = 0;
comHandleDS867.Channel = 1;
11
May 2024 DSETH RTLib Reference
Data Type Definitions
Predefined Symbols.................................................................................................................... 8
DsEthCstmEthTp1SComHandle
Note
Members Version Version number of the structure. The current version number is 0.
Example The following example shows how to initialize a DSETH custom communication
object if an ETH_TP1 interface is used:
{
pDsEthCfgSComHandle pComHandle;
...
12
DSETH RTLib Reference May 2024
DsEthSDataBufferObj
Predefined Symbols.................................................................................................................... 8
DsEthSDataBufferObj
Members Version Version number of the structure. The current version number is 0.
This member is implicitly handled by the buffer handling functions and must not
be changed.
SizeMax Maximum size of the data buffer (in bytes). This member is implicitly
handled by the buffer handling functions and must not be changed.
13
May 2024 DSETH RTLib Reference
Data Type Definitions
Handle Internal data buffer handle that the data of this buffer was sent with.
This member is implicitly handled by the buffer handling functions and must not
be changed.
TimeStamp Time (in seconds) the data buffer was sent (TX data buffer)
or received (RX data buffer). This member is implicitly handled by the buffer
handling functions and must not be changed.
TimeOut Timeout for sending the data buffer. The default is the
DsEthSSocketInit::TimeOutTX member value. This member is implicitly handled
by the buffer handling functions and must not be changed.
pNext Pointer to the next data buffer object. NULL terminates the chain. This
member is implicitly handled by the buffer handling functions and must not be
changed.
pBefore Pointer to the previous data buffer object. NULL terminates the
chain. This member is implicitly handled by the buffer handling functions and
must not be changed.
Predefined Symbols.................................................................................................................... 8
14
DSETH RTLib Reference May 2024
DsEthSObj
DsEthSObj
Note
15
May 2024 DSETH RTLib Reference
Data Type Definitions
16
DSETH RTLib Reference May 2024
DsEthSObjInit
Predefined Symbols.................................................................................................................... 8
DsEthSObjInit
Note
17
May 2024 DSETH RTLib Reference
Data Type Definitions
Members Version Version number of the structure. The current version number is 0.
Note
18
DSETH RTLib Reference May 2024
DsEthSSocketInit
Example The following example shows how to initialize a DSETH communication object:
{
DsEthSObjInit ObjInit = DSETH_OBJ_INIT_DEFAULT;
pDsEthSObj pDsEthObj = NULL;
...
pDsEthObj = dsEthObjInit("MyEthernetInterfaceName", &ObjInit);
}
Predefined Symbols.................................................................................................................... 8
DsEthSSocketInit
Introduction The DsEthSSocketInit structure is used for DSETH socket object initialization.
Note
Members Version Version number of the structure. The current version number is 0.
19
May 2024 DSETH RTLib Reference
Data Type Definitions
IPLocal Local IP address. Use the DSETHIPADDR macro to convert the data
format of a common IP address.
Example: SocketInit.IPLocal = DSETHIPADDR(192, 168, 0, 1)
PortLocal Local port address. The local port address describes the port
number incoming packets are received and outgoing packets are sent with
(source port) using the current socket.
Priority Socket priority. The higher the value, the lower the priority. When
new data arrives, data assignment is performed according to the socket priority.
This is important if there are several sockets matching an incoming data packet.
In that case, the resulting data buffer is assigned to the matching socket with the
highest priority.
Example The following example shows how to initialize a DSETH socket object:
{
DsEthSSocketInit SocketInit = DSETH_SOCKET_INIT_DEFAULT;
pDsEthSSocketObj pSocketObj = NULL;
...
pSocketObj = dsEthSocketObjInit(pDsEthObj, &SocketInit);
}
20
DSETH RTLib Reference May 2024
DsEthSSocketObj
Predefined Symbols.................................................................................................................... 8
DsEthSSocketObj
Note
Members Version Version number of the structure. The current version number is 0.
SocketNo Socket number, specifies the position in the socket list the socket is
saved to. The lower a socket number, the higher the priority of the socket.
21
May 2024 DSETH RTLib Reference
Data Type Definitions
pNext Pointer to the next socket element. NULL terminates the chain.
pBefore Pointer to the previous socket element. NULL terminates the chain.
CallbackProcess Flag indicating to process callback for this socket if data was
received. This parameter is implicitly handled within the DSETH API functions.
Predefined Symbols.................................................................................................................... 8
pDsEthCstmDS867SComHandle
22
DSETH RTLib Reference May 2024
pDsEthCstmEthTp1SComHandle
DsEthCstmDS867SComHandle................................................................................................. 11
pDsEthCstmEthTp1SComHandle
DsEthCstmEthTp1SComHandle................................................................................................. 12
pDsEthSDataBufferObj
23
May 2024 DSETH RTLib Reference
Data Type Definitions
DsEthSDataBufferObj................................................................................................................ 13
pDsEthSObj
24
DSETH RTLib Reference May 2024
pDsEthSObjInit
DsEthSObj................................................................................................................................ 15
pDsEthSObjInit
25
May 2024 DSETH RTLib Reference
Data Type Definitions
DsEthSObjInit........................................................................................................................... 17
pDsEthSpecific
Members None
26
DSETH RTLib Reference May 2024
pDsEthSSocketInit
pDsEthSSocketInit
DsEthSSocketInit....................................................................................................................... 19
pDsEthSSocketObj
27
May 2024 DSETH RTLib Reference
Data Type Definitions
DsEthSSocketObj...................................................................................................................... 21
28
DSETH RTLib Reference May 2024
Initialization and Controlling Functions
Introduction To get information on the functions used to perform the initialization process
and background executions, and to check the Ethernet connection.
dsEthBackground.................................................................................... 29
To process dsEth interface background executions.
dsEthConnectionCheck........................................................................... 30
To check if a DSETH device is available and connected to the Ethernet.
dsEthCstmDS867..................................................................................... 31
To create a communication handle for a dsEthCstmDS867 object.
dsEthCstmEthTp1.................................................................................... 31
To create a communication handle for a dsEthCstmEthTp1 object.
dsEthObjInit............................................................................................. 32
To initialize a DSETH communication object.
dsEthSocketObjInit.................................................................................. 32
To initialize a DSETH socket object.
dsEthSocketObjDelete............................................................................. 33
To destroy a DSETH socket object.
dsEthBackground
29
May 2024 DSETH RTLib Reference
Initialization and Controlling Functions
Parameters None
dsEthConnectionCheck
Description You can evaluate the return value to get information on whether the connection
is currently established.
30
DSETH RTLib Reference May 2024
dsEthCstmDS867
dsEthCstmDS867
DsEthSObjInit........................................................................................................................... 17
dsEthCstmEthTp1
31
May 2024 DSETH RTLib Reference
Initialization and Controlling Functions
DsEthSObjInit........................................................................................................................... 17
dsEthObjInit
dsEthSocketObjInit
32
DSETH RTLib Reference May 2024
dsEthSocketObjDelete
Parameters pDsEthObj Pointer to the DSETH communication object initialized using the
dsEthObjInit function
dsEthSocketObjDelete
33
May 2024 DSETH RTLib Reference
Initialization and Controlling Functions
34
DSETH RTLib Reference May 2024
Buffer Handling Functions
Introduction To get information on the functions used for sending and receiving data.
dsEthDataBufferRXObjFree...................................................................... 35
To free an RX data buffer object.
dsEthDataBufferRXObjGet....................................................................... 36
To receive an RX data buffer object.
dsEthDataBufferTXObjGet....................................................................... 37
To get a TX data buffer object which is to be sent subsequently.
dsEthDataBufferTXObjSend..................................................................... 38
To send a TX data buffer object.
dsEthDataBufferRXObjFree
35
May 2024 DSETH RTLib Reference
Buffer Handling Functions
Parameters pDataBufferObj Pointer to the dsEth data buffer object that was initialized
with the dsEthDataBufferRXObjGet function.
dsEthDataBufferRXObjGet........................................................................................................ 36
dsEthDataBufferTXObjGet........................................................................................................ 37
dsEthDataBufferTXObjSend...................................................................................................... 38
dsEthDataBufferRXObjGet
After the received data is used, you must free the RX buffer object. Refer to
dsEthDataBufferRXObjFree on page 35.
36
DSETH RTLib Reference May 2024
dsEthDataBufferTXObjGet
dsEthDataBufferRXObjFree....................................................................................................... 35
dsEthDataBufferTXObjGet........................................................................................................ 37
dsEthDataBufferTXObjSend...................................................................................................... 38
dsEthDataBufferTXObjGet
Description Data transmission is performed by getting and sending data buffer objects
(pDsEthSDataBufferObj).
dsEthDataBufferRXObjFree....................................................................................................... 35
dsEthDataBufferRXObjGet........................................................................................................ 36
dsEthDataBufferTXObjSend...................................................................................................... 38
37
May 2024 DSETH RTLib Reference
Buffer Handling Functions
dsEthDataBufferTXObjSend
Description Transmitting data is performed by getting and sending data buffer objects
(pDsEthSDataBufferObj).
Parameters pDataBufferObj Pointer to the DSETH data buffer object initialized via the
dsEthDataBufferTXObjGet function
38
DSETH RTLib Reference May 2024
dsEthDataBufferTXObjSend
dsEthDataBufferRXObjFree....................................................................................................... 35
dsEthDataBufferRXObjGet........................................................................................................ 36
dsEthDataBufferTXObjGet........................................................................................................ 37
39
May 2024 DSETH RTLib Reference
Buffer Handling Functions
40
DSETH RTLib Reference May 2024
Interrupt Handling Functions
Introduction To get information on the functions used for interrupt‑based data processing.
dsEthInterruptProcess
41
May 2024 DSETH RTLib Reference
Interrupt Handling Functions
42
DSETH RTLib Reference May 2024
Examples
Examples
Example The following example shows how to use the DSETH interface with a
MicroAutoBox II and a DS867 LVDS Ethernet link cable.
#include <Brtenv.h>
#include <dseth.h>
#include <dseth_custom_ds867.h>
#include <Int1401.h>
#define SOCKET_SEND_CONDITIONS (DSETH_USE_BACKGROUND | DSETH_USE_FOREGROUND | DSETH_FREE_OBJ_AFTER_SEND | \
DSETH_FREE_OBJ_AFTER_ERROR)
43
May 2024 DSETH RTLib Reference
Examples
void main(void)
{
pDsEthCfgSComHandle pComHandle;
pDsEthSSocketObj pSocketObj;
comHandleDS867.Version = 0;
comHandleDS867.Channel = 1;
SocketInit.ConfigFlags = DSETH_ACCESS_MODE_UDP_IP;
SocketInit.ConfigFlags |= DSETH_ACCESS_SOCKET_DIRECTION_RX;
SocketInit.ConfigFlags |= DSETH_ACCESS_SOCKET_DIRECTION_TX;
SocketInit.pSpecific = &LocalSocketID;
44
DSETH RTLib Reference May 2024
Using the DSETH with the ETH_TP1 Interface of a MicroAutoBox II
for(;;)
{
/* sending data every 5 seconds using udp socket */
if( (ts_time_read() - timeStamp) > SEND_PERIOD )
{
pDsEthSDataBufferObj pDataBuffer = dsEthDataBufferTXObjGet( pSocketObj );
timeStamp = ts_time_read();
}
/* reading all data from udp socket */
{
unsigned int LocalSocketID = *((unsigned int *)pSocketObj->pSpecific);
pDsEthSDataBufferObj pDataBufferObj = NULL;
Example The following example shows how to use the DSETH interface with the ETH_TP1
interface of a MicroAutoBox II.
#include <Brtenv.h>
#include <dseth.h>
#include <dseth_custom_eth_tp1.h>
#include <Int1401.h>
45
May 2024 DSETH RTLib Reference
Examples
46
DSETH RTLib Reference May 2024
Using the DSETH with the ETH_TP1 Interface of a MicroAutoBox II
for(;;)
{
/* sending data every 5 seconds using udp socket */
if( (ts_time_read() - timeStamp) > SEND_PERIOD )
{
pDsEthSDataBufferObj pDataBuffer = dsEthDataBufferTXObjGet( pSocketObj );
47
May 2024 DSETH RTLib Reference
Examples
48
DSETH RTLib Reference May 2024
Index
Index
C
Common Program Data folder 6
D
Documents folder 6
dsEthBackground 29
dsEthConnectionCheck 30
dsEthCstmDS867 31
DsEthCstmDS867SComHandle 11
dsEthCstmEthTp1 31
DsEthCstmEthTp1SComHandle 12
dsEthDataBufferRXObjFree 35
dsEthDataBufferRXObjGet 36
dsEthDataBufferTXObjGet 37
dsEthDataBufferTXObjSend 38
dsEthInterruptProcess 41
dsEthObjInit 32
DsEthSDataBufferObj 13
DsEthSObj 15
DsEthSObjInit 17
dsEthSocketObjDelete 33
dsEthSocketObjInit 32
DsEthSSocketInit 19
DsEthSSocketObj 21
L
Local Program Data folder 6
P
pDsEthCstmDS867SComHandle 22
pDsEthCstmEthTp1SComHandle 23
pDsEthSDataBufferObj 23
pDsEthSObj 24
pDsEthSObjInit 25
pDsEthSpecific 26
pDsEthSSocketInit 27
pDsEthSSocketObj 27
49
May 2024 DSETH RTLib Reference
Index
50
DSETH RTLib Reference May 2024