Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

GetVoltage() unconditionally leaves I2C bus in EXTERNAL state — latent hazard

Abierto
#7 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
56/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
arduino, cpp
Área
embedded-iot

Línea de trabajo

Start at the GetVoltage() entry point and trace I2CState(INTERNAL) / I2CState(EXTERNAL), then inspect its AddDataPoint() call sites and the possible GetOnBoardVals() context. Done means GetVoltage() no longer changes the caller's I2C bus state when invoked from an INTERNAL context, while current EXTERNAL usage remains safe.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Issue

GetVoltage() now wraps the ADC read with I2CState(INTERNAL) / I2CState(EXTERNAL) (added in 7c04bf1) without saving or restoring the caller's I2C bus state. The EXTERNAL restore at the end is unconditional.

float Okapi::GetVoltage(uint8_t Pin) {
    I2CState(INTERNAL);
    float Val = ADC_Ext.readADC_SingleEnded(Pin) * 0.1875;
    I2CState(EXTERNAL);   // always left on EXTERNAL, regardless of caller state
    return Val;
}

Current status

All current call sites for GetVoltage() are in user Update() callbacks, which AddDataPoint() always invokes during the EXTERNAL phase — so the unconditional restore is safe for present usage.

Latent hazard

If GetVoltage() is ever called from setup() or any INTERNAL context (e.g., added to GetOnBoardVals() in the future), the bus will be left on EXTERNAL, corrupting subsequent BME280/RTC reads. There is nothing in the function signature or documentation to warn callers of this constraint.

Fix

Save and restore the caller's I2C state, or document the EXTERNAL-context-only precondition prominently.

Severity

Low (latent) — not triggered by current library code; risk increases as the API evolves.

🤖 Generated with Claude Code

Lenguaje dominante
C++
Estrellas
1
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NorthernWidget/Okapi_Library

Todos los issues de NorthernWidget/Okapi_Library

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.