Skip to content

ism330dl: Use polling with timeout in _ensure_data() for consistency. #125

@nedseb

Description

@nedseb

Context

Part of the auto-trigger consistency harmonization (#44).

The ISM330DL _ensure_data() (merged in PR #124) uses a fixed sleep_ms(100) after restoring ODR, without polling STATUS_REG for data ready or raising on timeout. This is inconsistent with the pattern used by WSEN-HIDS, LIS2MDL, VL53L1X, and APDS9960 which all poll for data ready and raise OSError on timeout.

Current behavior

def _ensure_data(self):
    if self._is_power_down():
        self.configure_accel(self._accel_odr, self._accel_scale)
        self.configure_gyro(self._gyro_odr, self._gyro_scale)
        sleep_ms(100)

Expected behavior

def _ensure_data(self):
    if self._is_power_down():
        self.configure_accel(self._accel_odr, self._accel_scale)
        self.configure_gyro(self._gyro_odr, self._gyro_scale)
        for _ in range(50):
            if self.status()["accel_ready"]:
                return
            sleep_ms(10)
        raise OSError("ISM330DL data ready timeout")

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdriverConcerne un driver spécifiquereleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions