> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sensor-bridge/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sensor-bridge/_mcp/server.

# hololink::emulation::sensors::TestSensor

> I2C-controlled test sensor for validation and development.

I2C-controlled test sensor for validation and development.

Register map (16-bit big-endian address, same transaction format as [Vb1940Emulator](vb1940emulator)):

```cpp showLineNumbers={false}
#include <hololink/emulation/sensors/test_sensor.hpp>
```

**Inherits from:** `hololink::emulation::I2CPeripheral` (public)

***

## Constructors

### TestSensor \[#testsensor]

```cpp showLineNumbers={false}
hololink::emulation::sensors::TestSensor::TestSensor()
```

### Destructor \[#destructor]

### \~TestSensor

```cpp showLineNumbers={false}
hololink::emulation::sensors::TestSensor::~TestSensor()
```

***

## Methods

### reset \[#reset]

```cpp showLineNumbers={false}
void hololink::emulation::sensors::TestSensor::reset()
```

### attach\_to\_i2c \[#attachtoi2c]

```cpp showLineNumbers={false}
void hololink::emulation::sensors::TestSensor::attach_to_i2c(
    I2CController &i2c_controller,
    uint8_t bus_address
) override
```

python:

`def `[`attach_to_i2c`](#attachtoi2c)`(self: hemu.I2CPeripheral, i2c_controller: hemu.I2CController, bus_address: int)`

attach the peripheral to the I2C controller. This should be called by client code before start() is called

**Parameters**

The I2C controller to attach to. Retrieved from [HSBEmulator](../../../classes/hsbemulator) with get\_i2c(controller\_address)

The bus address of the peripheral.

### i2c\_transaction \[#i2ctransaction]

```cpp showLineNumbers={false}
I2CStatus hololink::emulation::sensors::TestSensor::i2c_transaction(
    uint16_t peripheral_address,
    const uint8_t *write_bytes,
    uint16_t write_size,
    uint8_t *read_bytes,
    uint16_t read_size
) override
```

python:

`def `[`i2c_transaction`](#i2ctransaction)`(self: hemu.I2CPeripheral, peripheral_address: int, write_bytes: List[int], read_bytes: List[int]) -> hemu.I2CStatus`

perform an I2C transaction. This will be called by the [I2CController](../../../classes/i2ccontroller) when a transaction is requested.

read request size is the size of the read\_bytes vector as initialized by the caller

**Returns:** [I2CStatus](../../../enums/i2cstatus) The status of the transaction.

**Parameters**

The peripheral address to communicate with.

The bytes to write to the peripheral.

The size of the write bytes

The bytes to read from the peripheral. This shall be filled with 0s to the requested read size and replaced by peripheral. This is to ensure peripheral can get the read count from read\_bytes.size() and enough valid data is returned for no-ops.

The size of the read bytes

### is\_streaming \[#isstreaming]

```cpp showLineNumbers={false}
bool hololink::emulation::sensors::TestSensor::is_streaming() const
```

### get\_frame\_size \[#getframesize]

```cpp showLineNumbers={false}
uint32_t hololink::emulation::sensors::TestSensor::get_frame_size() const
```

### get\_frame\_rate\_hz \[#getframeratehz]

```cpp showLineNumbers={false}
uint32_t hololink::emulation::sensors::TestSensor::get_frame_rate_hz() const
```

### get\_pattern\_mode \[#getpatternmode]

```cpp showLineNumbers={false}
TestPatternMode hololink::emulation::sensors::TestSensor::get_pattern_mode() const
```

### get\_constant\_byte \[#getconstantbyte]

```cpp showLineNumbers={false}
uint8_t hololink::emulation::sensors::TestSensor::get_constant_byte() const
```

### fill\_frame \[#fillframe]

```cpp showLineNumbers={false}
void hololink::emulation::sensors::TestSensor::fill_frame(
    uint8_t *data,
    uint64_t frame_index
) const
```

Fill a frame buffer according to the current pattern configuration.

**Parameters**

Destination buffer (must be at least get\_frame\_size() bytes).

Frame sequence number used by the incrementing pattern.

### start \[#start]

```cpp showLineNumbers={false}
virtual void hololink::emulation::sensors::TestSensor::start()
```

start the peripheral.

This will be called when [I2CController](../../../classes/i2ccontroller) itself starts and should not be done by the client code

### stop \[#stop]

```cpp showLineNumbers={false}
virtual void hololink::emulation::sensors::TestSensor::stop()
```

stop the peripheral.

This will be called when the [I2CController](../../../classes/i2ccontroller) is stopped and should not be done by the client code

Peripheral should release all resources in case a subsequent start() is called.

### streaming\_reg \[#streamingreg]

```cpp showLineNumbers={false}
I2CStatus hololink::emulation::sensors::TestSensor::streaming_reg(
    const uint8_t *write_bytes,
    uint16_t write_size,
    uint8_t *read_bytes,
    uint16_t read_size
)
```

***

## Member variables

| Name                                 | Type       | Description |
| ------------------------------------ | ---------- | ----------- |
| `DEVICE_ID_REG` static constexpr     | `uint16_t` |             |
| `FRAME_SIZE_REG` static constexpr    | `uint16_t` |             |
| `PATTERN_MODE_REG` static constexpr  | `uint16_t` |             |
| `CONSTANT_BYTE_REG` static constexpr | `uint16_t` |             |
| `FRAME_RATE_REG` static constexpr    | `uint16_t` |             |
| `STREAMING_REG` static constexpr     | `uint16_t` |             |
| `STATUS_REG` static constexpr        | `uint16_t` |             |
| `memory_`                            | `uint8_t`  |             |