GetVoltage() unconditionally leaves I2C bus in EXTERNAL state — latent hazard
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
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de NorthernWidget/Okapi_Library
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Todos los issues de NorthernWidget/Okapi_Library
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
leanprover/lean4#15683 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
touhouworldcup/thprac#414 ·