> ## Documentation Index
> Fetch the complete documentation index at: https://notevil.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CAPLfunctionDoIPSelectVehicle

# DoIP\_SelectVehicle

[Valid for](../../../Shared/FeatureAvailability.md): CANoe DE

**Note**\
These functions only work if the tester program uses the built-in DoIP channels, i.e. they do not work if the tester program uses the [CAPL Callback Interface (CCI)](../CAPLfunctionsDiagnosticsConnectionCommunicationLayer.md).

## Function Syntax

```plaintext theme={null}
long DoIP_SelectVehicle(byte EID[6]);
long DoIP_SelectVehicle(char VIN[]);
```

## Description

Specify which vehicle the tester shall target, i.e. indicate in the Vehicle Identification Request Message, or select one of the responding vehicles for communication.

* If this function is called before a Vehicle Identification Request (VIR) Message is sent, it will set the Vehicle Identification Number (VIN) or Entity ID (EID) in the VIR messages.
* If this function is called during a vehicle identification phase, a matching vehicle will be selected if its Vehicle Identification Response (or Announcement Message, VAM) has been received. It is possible to call this function from the [DoIP\_VehicleIdentificationCompleteInd](CAPLfunctionDoIPVehicleIdentificationCompleteInd.md) callback.

To set the VIN and EID in an ECU simulation use the DoIP.DLL functions [DoIP\_SetEID](CAPLfunctionDoIPSetEID.md) and [DoIP\_SetVIN](CAPLfunctionDoIPSetEID.md).

## Parameters

* **EID**: (6 bytes) entity ID, typically an Ethernet MAC address.
* **VIN**: The vehicle identification number (17 characters). If an empty string is given, VIR messages without parameter are sent.

## Return Values

[Error code](../CAPLfunctionsDiagnosticsErrorCode.md)

## Example

```plaintext theme={null}
TestCase TC_AccessVehicle1
{
  diagRequest ReadEcuInfo req;

  DiagSetTarget( "ECU1"); // a DoIP description

  // --- start VIR targeting a specific vehicle via its VIN

  DoIP_SelectVehicle( "VECT0RVEH1CLE0123");

  req.SendRequest();
  // A VIR with VIN should be responded quite fast
  TestWaitForDiagResponse( req, 1000);

  diagCloseChannel(); // make sure that another VIR will be sent

  // --- send VIR without indicating a vehicle

  DoIP_SelectVehicle( ""); // no-parameter-VIR-message

  req.SendRequest();
  // A VIR without parameter may take a long time, including repeats
  TestWaitForDiagResponse( req, 9000);

  diagCloseChannel();
}
```
