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

# AR Utility Data Log

> Defines platform agnostic APIs for logging data through a data transport(diag, tcpip, etc...)

**Header:** `ar_util/api/ar_util_data_log.h`

## Structures

### `ar_data_log_pcm_info_t`

PCM data format information for the logging utility user.

**Members**

**sampling\_rate** `uint32_t`

PCM sampling rate.

**num\_channels** `uint16_t`

Number of channels in the PCM stream.

**bits\_per\_sample** `uint8_t`

Bits per sample for the PCM data.

**interleaved** `uint8_t`

Specifies whether the data is interleaved.

**channel\_mapping** `uint16_t *`

Array of channel mappings.

### `ar_data_log_audio_fmt_info_t`

Format of the data being logged: PCM or bitstream.

**Members**

**pcm\_data\_fmt** `ar_data_log_pcm_info_t`

Format of the PCM data.

**media\_fmt\_id** `uint32_t`

Format of the bitstream data.

### `ar_data_log_alloc_info_t`

**Members**

**log\_code** `uint32_t`

The log code used for logging.

**buffer\_size** `uint32_t`

The length of the buffer to log.

**pkt\_type** `ar_log_pkt_type_t`

The type of packet to use for logging data.

### `ar_data_log_commit_info_t`

**Members**

**session\_id** `uint32_t`

The session id for the log packet.

**log\_tap\_id** `uint32_t`

The log tap point id.

**buffer\_size** `uint32_t`

The length of the buffer to log.

**pkt\_type** `ar_log_pkt_type_t`

The type of packet to use for logging data.

**pkt\_info** `void *`

Pointer to the packet info structure that is determined by pkt\_type.

**log\_pkt\_data** `void *`

Pointer to the data section of the log packet.

### `ar_data_log_submit_info_t`

**Members**

**log\_code** `uint16_t`

The log code used for logging.

**session\_id** `uint32_t`

The session id for the log packet.

**log\_tap\_id** `uint32_t`

The log tap point id.

**pkt\_type** `ar_log_pkt_type_t`

The type of packet to use for logging data.

**pkt\_info** `void *`

Pointer to the packet info structure that is determined by pkt\_type.

**buffer\_size** `uint32_t`

The length of the buffer to log.

**buffer** `int8_t *`

Pointer to the buffer to be logged.

### `ar_data_log_pcm_pkt_info_t`

Additional packet information for PCM/Bitstream packets used in conjunction with the pkt\_info field in ar\_data\_log\_submit\_info\_t and ar\_data\_log\_commit\_info\_t

**Members**

**log\_time\_stamp** `uint64_t`

Timestamp in microseconds.

**data\_info** `ar_data_log_audio_fmt_info_t`

Pointer to the data packet information.

**seq\_number\_ptr** `uint32_t *`

Reference to sequence number variable shared by client.

### `ar_data_log_generic_pkt_info_t`

**Members**

**log\_time\_stamp** `uint64_t`

Timestamp in microseconds.

**token\_id** `uint32_t`

Used to distinguish the logging source of a packet or set of packets.

**format** `ar_data_log_generic_fmt_t`

Specifies the command format to use in the generic log packet.

### `ar_data_log_blob_fmt_t`

**Members**

**data\_size** `uint32_t`

The length in bytes of the data that follows this header.

**data** `uint8_t`

The data.

## Functions

### `ar_data_log_init`

Initializes the data logging utility.

```cpp theme={null}
int32_t ar_data_log_init(void)
```

**Returns**

AR\_EOK : on success AR\_E\<other error> : on failure

### `ar_data_log_deinit`

Deitializes the data logging utility.

```cpp theme={null}
int32_t ar_data_log_deinit(void)
```

**Returns**

AR\_EOK : on success AR\_E\<other error> : on failure

### `ar_data_log_code_status`

Checks whether the log code is enabled.

```cpp theme={null}
bool_t ar_data_log_code_status(uint16_t log_code)
```

**Returns**

TRUE : is enabled FALSE : is disabled

### `ar_data_log_get_max_packet_size`

Returns the max log packet size.

\dependencies None

```cpp theme={null}
uint32_t ar_data_log_get_max_packet_size(void)
```

### `ar_data_log_alloc`

Allocates a data log packet.

```cpp theme={null}
void * ar_data_log_alloc(ar_data_log_alloc_info_t *info)
```

**Parameters**

**info** `ar_data_log_alloc_info_t *`

Contains the info needed to allocate a log packet

**Returns**

Pointer to the payload of the allocated log packet. Returns NULL if buffer allocation fails or log code is disabled.

### `ar_data_log_commit`

Commits a packet for logging.

The log header is populated by this call. The client fills in the data portion of the packet.

```cpp theme={null}
int32_t ar_data_log_commit(ar_data_log_commit_info_t *info)
```

**Parameters**

**info** `ar_data_log_commit_info_t *`

A pointer to the commit info structure that contains info needed to commit a packet.

**Returns**

0  Success

### `ar_data_log_submit`

Segments a buffer into log packets and commits each packet for data logging.

Log packet allocation and disposal are automatically taken care of.

```cpp theme={null}
int32_t ar_data_log_submit(ar_data_log_submit_info_t *info)
```

**Parameters**

**info** `ar_data_log_submit_info_t *`

A pointer to the submit info structure that contains the buffer to log as well as info for creating the log packet

**Returns**

0  Success Nonzero  Failure

### `ar_data_log_free`

Releases the memory allocated for a log packet.

```cpp theme={null}
void ar_data_log_free(void *log_pkt_payload_ptr, ar_log_pkt_type_t pkt_type)
```

**Parameters**

**log\_ptr**

: pointer to the payload of the data log packet

**pkt\_type** `ar_log_pkt_type_t`

: the type of packet that needs to be freed

**Returns**

None.

## Type Definitions

### `ar_log_pkt_type_t`

An enumeration of the log packet types supported by the utility.

```cpp theme={null}
typedef enum ar_log_pkt_type_t ar_log_pkt_type_t
```

### `ar_data_log_generic_fmt_t`

```cpp theme={null}
typedef enum ar_data_log_generic_fmt_t ar_data_log_generic_fmt_t
```

### `ar_data_log_pcm_info_t`

PCM data format information for the logging utility user.

```cpp theme={null}
typedef struct ar_data_log_pcm_info_t ar_data_log_pcm_info_t
```

### `ar_data_log_audio_fmt_info_t`

Format of the data being logged: PCM or bitstream.

```cpp theme={null}
typedef struct ar_data_log_audio_fmt_info_t ar_data_log_audio_fmt_info_t
```

### `ar_data_log_alloc_info_t`

Contains information needed to log a packet through the ar\_data\_log\_commit(...) API.

```cpp theme={null}
typedef struct ar_data_log_alloc_info_t ar_data_log_alloc_info_t
```

### `ar_data_log_commit_info_t`

Contains information needed to log a buffer through the ar\_data\_log\_submit(...) API.

```cpp theme={null}
typedef struct ar_data_log_commit_info_t ar_data_log_commit_info_t
```

### `ar_data_log_submit_info_t`

```cpp theme={null}
typedef struct ar_data_log_submit_info_t ar_data_log_submit_info_t
```

### `ar_data_log_pcm_pkt_info_t`

Additional packet information for PCM/Bitstream packets used in conjunction with the pkt\_info field in ar\_data\_log\_submit\_info\_t and ar\_data\_log\_commit\_info\_t

```cpp theme={null}
typedef struct ar_data_log_pcm_pkt_info_t ar_data_log_pcm_pkt_info_t
```

### `ar_data_log_generic_pkt_info_t`

```cpp theme={null}
typedef struct ar_data_log_generic_pkt_info_t ar_data_log_generic_pkt_info_t
```

### `ar_data_log_blob_fmt_t`

```cpp theme={null}
typedef struct ar_data_log_blob_fmt_t ar_data_log_blob_fmt_t
```

## Enumerations

### `ar_log_pkt_type_t`

An enumeration of the log packet types supported by the utility.

#### Values

| Name | Value | Description |
| - | - | - |
| `AR_DATA_LOG_PKT_TYPE_UNKNOWN` | = 0x00 | Unknown log packet. |
| `AR_DATA_LOG_PKT_TYPE_AUDIO_BITSTREAM` | = 0x01 | Bitstream log packet format. |
| `AR_DATA_LOG_PKT_TYPE_AUDIO_PCM` | = 0x02 | PCM Log packet. |
| `AR_DATA_LOG_PKT_TYPE_GENERIC` | = 0x03 | A general purpose log packets that adds headers for handling fragmentation and re-assembly. |
| `AR_DATA_LOG_PKT_TYPE_RAW` | = 0x04 | A raw data packet where data is sent as is. |

### `ar_data_log_generic_fmt_t`

#### Values

| Name | Value | Description |
| - | - | - |
| `AR_LOG_PKT_GENERIC_FMT_CAL_BLOB` | = 0x5043414C | 'P''C''A''L'. |
| `AR_LOG_PKT_GENERIC_FMT_RAW` | = 0x52415720 | 'R''A''W'''. |
