udsonip.discovery
ECU discovery utilities for DoIP networks.
- class udsonip.discovery.ECUInfo(ip: str, logical_address: int, vin: str | None = None, eid: bytes | None = None, gid: bytes | None = None, further_action_required: int | None = None, vin_gid_sync_status: int | None = None)[source]
Bases:
objectInformation about a discovered ECU.
- connect(client_ip: str | None = None, **kwargs)[source]
Create a UdsOnIpClient connected to this ECU.
- Parameters:
client_ip – Optional client IP address
**kwargs – Additional arguments for UdsOnIpClient
- Returns:
UdsOnIpClient instance
- eid: bytes | None = None
Entity Identification (VIN or similar)
- further_action_required: int | None = None
Further action required byte
- gid: bytes | None = None
Group Identification
- ip: str
IP address of the ECU/gateway
- logical_address: int
ECU logical address
- vin: str | None = None
Vehicle Identification Number
- vin_gid_sync_status: int | None = None
VIN/GID Synchronization status
- udsonip.discovery.discover_ecus(interface: str | None = None, timeout: float = 3.0, protocol_version: int = 3) List[ECUInfo][source]
Discover ECUs on the DoIP network by broadcasting a Vehicle Identification Request and listening for unicast responses. This function implements a more robust discovery method: 1. Creates a single UDP socket bound to an ephemeral port. 2. Broadcasts a Vehicle Identification Request. 3. Listens on the same socket for direct unicast responses from all
ECUs for the entire timeout period.
This approach correctly captures all direct responses and is more efficient than the previous implementation. :param interface: Network interface to use for IPv6 (not typically required for IPv4). :param timeout: Discovery timeout in seconds. :param protocol_version: DoIP protocol version (default: 0x03).
- Returns:
List of discovered ECU information (duplicates filtered by IP and logical address).
- Raises:
DiscoveryError – If discovery fails due to network or protocol errors.
- udsonip.discovery.get_entity(ip: str, protocol_version: int = 3) ECUInfo | None[source]
Get entity information from a specific DoIP gateway/ECU.
- Parameters:
ip – IP address of the DoIP entity
protocol_version – DoIP protocol version (default: 0x03)
- Returns:
ECUInfo if successful, None otherwise
Example
>>> ecu = get_entity('192.168.1.10') >>> if ecu: ... print(f"ECU at {ecu.ip}: {ecu.logical_address:#x}")