# utils

Python API: `modelconverter.platforms.rvc4.utils`

Helpers for addressing an RVC4 device.

DepthAI and ADB name the same device differently, so benchmarking and analysis have to translate between a DepthAI device ID and
an ADB serial, and work out an address for a device the user named by either.

## Functions

### adb_id_to_device_id

```python
def adb_id_to_device_id(adb_id: str) -> str:
```

Convert an ADB serial back into a DepthAI device ID.

> **Example**
> ```pycon
>>> adb_id_to_device_id("1c244d")
'1844301'
```

Parameters

 * `adb_id` (`str`): The serial ADB knows the device by.

Returns

 * `str`: The decimal form of the serial if it reads as a hexadecimal number, otherwise the ASCII text its bytes spell out.

### device_id_to_adb_id

```python
def device_id_to_adb_id(device_id: str) -> str:
```

Convert a DepthAI device ID into an ADB serial.

> **Example**
> ```pycon
>>> device_id_to_adb_id("1844301")
'1c244d'
```

Parameters

 * `device_id` (`str`): The device ID as DepthAI reports it.

Returns

 * `str`: The hexadecimal form of the ID if it is a number, otherwise the hex encoding of its ASCII bytes.

### get_device_info

```python
def get_device_info(device_ip: str | None, device_id: str | None) -> tuple[str | None, str | None]:
```

Work out how to reach the device the user asked for.

A device ID is looked up among the connected devices, and a mismatch between the address found there and the one that was passed
is only warned about. An address that does not come out of that lookup is connected to directly, to read the ID off the device.

Parameters

 * `device_ip` (`str | None`): Address of the device, if one was given.
 * `device_id` (`str | None`): Device ID or ADB serial of the device, if one was given.

Returns

 * `tuple[str | None, str | None]`: The address and the ADB serial of the device. Both are `None` when neither argument was given,
   and when only a device ID was given and no connected device matched it.
