OTX-Runtime for C++  
Diagnostics over IP (DoIP)

The DiagManager supports the diagnostic communication over Internet Protocol (DoIP), see ISO 13400-2. The following section describes how a DoIP communication can be established.

Basic Sequence

The OTX ComInterface extensions provides all actions and terms to establish a DoIP communication. The following diagram shows the basic sequence.

Note: For DoIP communication the Extended Mode is necessary, see Communication Modes. The DiagManager can switch implicit to the right mode.

Basic sequence to establish a DoIP communication

Pseudo Code Example

The basic proceeding how to establish a DoIP communication is described in the following pseudo code example.

// Pseudo-Code example to establish a DoIP communication
// =====================================================
// Please note that the exact syntax of C++, DotNet and Java is different!
void main()
{
// Sets a valid license key to active the DiagManager Server
OpenTestSystem.Otx.DiagManager.SystemApi.Util.SetLicenseKey(8888, Constants.LICENSE_KEY);
// Creates the OtxDiagApi of the DiagManager client, DiagManager has being started
OpenTestSystem.Otx.DiagManager.OtxDiagApi.IOtxDiag otxDiag = OpenTestSystem.Otx.DiagManager.OtxDiagApi.OtxDiagFactory.CreateSocketOtxDiag(8888);
// Creates the NoneOtxDiagApi of the DiagManager client
OpenTestSystem.Otx.DiagManager.NoneOtxDiagApi.INoneOtxDiag noneOtxDiag = OpenTestSystem.Otx.DiagManager.NoneOtxDiagApi.NoneOtxDiagFactory.CreateSocketNoneOtxDiag(8888);
// Gets the ComInterface (OTX Extension) from DiagManager
OpenTestSystem.Otx.DiagManager.OtxDiagApi.IComInterface comInterface = otxDiag.ComInterface;
// Gets the DiagCom (OTX Extension) from DiagManager
OpenTestSystem.Otx.DiagManager.OtxDiagApi.IDiagCom diagCom = otxDiag.DiagCom;
// Gets all available ComInterfaces (MCDInterface) as a list of String
List<String> comInterfaceNames = comInterface.GetComInterfaceNameList();
// Gets the ComInterface from the given name, whose Long-Name contains "connectiontype". Assume in this example, otxComInterface.LongName contains "connectiontype"
OpenTestSystem.Otx.DiagManager.OtxDiagApi.DataTypes.IComInterface otxComInterface = comInterface.GetComInterface(comInterfaceNames[0]);
try
{
// Connect to the selected ComInterface
comInterface.ConnectComInterface(otxComInterface);
// Activate the activation line
comInterface.ActivateEthernet(otxComInterface);
// Wait to give the controller time to start. The waiting time depends on machine and environment variables.
// It is also possible to poll until GetComInterfaceNameListFromEthernet gets the DoIP interface
Thread.Sleep(8000);
// Gets all available ComInterfaces (MCDInterface), including the ComInterface from Ethernet, as a list of String
List<String> comInterfaceNamesFromEthernet = comInterface.GetComInterfaceNameListFromEthernet(null, "PDU_IOCTL='PDU_IOCTL_VEHICLE_ID_REQUEST' PreselectionMode='None' PreselectionValue='' CombinationMode='DoIP-Entity' VehicleDiscoveryTime='1000' DestinationAddressCount='1' DA1='255.255.255.255'");
// Gets the ComInterface from the given Name, whose Long-Name contains "doip". Assume in this example, otxComInterfaceFromEthernet.LongName contains "doip"
OpenTestSystem.Otx.DiagManager.OtxDiagApi.DataTypes.IComInterface otxComInterfaceFromEthernet = comInterface.GetComInterface(comInterfaceNamesFromEthernet[1]);
// Connect to the selected ComInterface
comInterface.ConnectComInterface(otxComInterfaceFromEthernet);
// Sets the interface for DoIP in normal mode
noneOtxDiag.SetPreferedInterface(otxComInterfaceFromEthernet.ShortName);
// Gets the ComChannel
OpenTestSystem.Otx.DiagManager.OtxDiagApi.IComChannel comChannel = comInterface.GetComChannel("LL_Gateway", "", true);
// Gets the ComChannel - Alternative for extended mode - NoneOtxDiagApi.SetPreferedInterface is not necessary here
// OpenTestSystem.Otx.DiagManager.OtxDiagApi.IComChannel comChannel = comInterface.GetComChannelFromComInterface(otxComInterface, "LL_Gateway", "", true);
// Creates a DiagService
OpenTestSystem.Otx.DiagManager.OtxDiagApi.IDiagService diagService = diagCom.CreateDiagServiceByName(comChannel, "ReadSparePartNumber");
// Execute the DiagService
diagCom.ExecuteDiagService(diagService);
// Close the ComChannel and release all resources
diagCom.CloseComChannel(comChannel);
}
catch (OpenTestSystem.Otx.DiagManager.OtxDiagApi.DataTypes.DiagRuntimeException e)
{
throw e;
}
finally
{
// Release the activation line
comInterface.DeactivateEthernet(otxComInterface);
// Close ComInterface
comInterface.CloseComInterface(otxComInterface);
}
}
Namespace containing all objects which are standardized according to ISO 13209 (OTX)
Namespace containing all objects related to testing inside automotive industry